I have written the following function to concatenate the parts of a name to produce the full name:
/**
* Returns the full name of the Person.
* @param boolean $includeTitle Whether to include the Person's title.
* @param boolean $includeMiddleNames Whether to include the Person's middle names...
I'm creating a PHP website for a non-profit. They have some restrictions (no MySQL or pre-installed CMS) so I'm creating a CSS menu displayed by an unordered list where all of the elements are stored in a multi-dimensional array.
I've gotten it to work but being new to PHP, I'm certain it's not ...
@nhgrif Starred your github project. I'll drop by and take a look every once in a while. Perhaps I'll be able to catch up on my Objective-C skills as well.
Here is an "enhanced" Listview class, you can just add it your project and you're good to go.
It's not perfect by any means, so any input is appreciated.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using...
I wrote this quick script to convert a genotype file into a BED file. Running it seems to be taking a very long time.
#BED file format
#http://genome.ucsc.edu/FAQ/FAQformat.html#format1
#1.chrom - The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671).
#2.ch...
I've been working through the problems on Coderbyte and this on has me stuck. The assignment is to built a piece of code that processes a string and returns True if all lowercase alphabetical characters are surrounded by plus "+" signs (e.g. +d++e+==+d+) and returns False if even one is not (e.g....
find_value_from_key
The core method find_value_from_key looks functional for the limited specification you have given. I am not a great fan of the specification though, I think the function should try to be a bit smarter about identifying values in the input strings. The two items I find most co...
@syb0rg now you can (as a C++ person) tell me to keep out of places I don't belong... ;-)
I am not sure what I am missing. I am pretty new to C++, and GLSL, so I am not sure if I am screwing something up with the C++ in general, or if I am failing to handle the OpenGL context correctly?
The main function (code for handling window creation is missing. If you think you may need to, jus...
I am not sure what I am missing. I am pretty new to C++, and GLSL, so I am not sure if I am screwing something up with the C++ in general, or if I am failing to handle the OpenGL context correctly?
The main function (code for handling window creation is missing. If you think you may need to, jus...
I've contacted SE yesterday to burninate a few tags. Something apparently went wrong, causing these tags to "recreate themselves" and appear as new, with a few questions left over. One of these questions only had these tags (automatically giving it untagged), and I've fixed that by giving it a ...
I was in a meeting with my boss and technical support leader and they asked me for a database model to a very simple application. That application requires: employees information, some location data, and etc, etc, etc.
One of their database table was:
employee
id
name
lastname
usernam...
The Wikipedia article on the union find problem gives a very simple implementation, which I ported to C# and tested.
I know that the code should be, in the aggregate, asymptotically almost linear. But is it... a real-world implementation? What can I do to make it faster? Is there a way to cut do...
The biggest problem with using a for-loop to do this is that you are wasting CPU power.
When using sleep, the CPU can, in a sense, take a break (hence the name "sleep") from executing your program. This means that the CPU will be able to run other programs that have meaningful work to do while y...
In December 2013 we held a bunch of weekly weekend-challenge events, which was fun, and generated posts that made it to the site's newsletter, week after week. One may want to tweak this query so as to filter posts created before December 30th, 2013.
Some weekend-challenge stats up to that date:...
In software engineering, don't repeat yourself (DRY) is a principle of software development, a principle aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures. The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." The principle has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. They apply it quite broadly to include "database schemas, test plans, the build system, even documentation." When the DRY principle is applied su...
@rolfl has mentioned some great points, so I won't repeat those. I'll address some C++-specific things I've found, keeping in mind that Boost and C++11 shouldn't be mentioned.
These:
using std::cout;
using std::endl;
using std::string;
are okay to use, but I'd just use std:: where needed, e...
I'm builing a bin tree. Exmple: key AAAA1.ETR, value 1.
I'm reading files with this structure:
DataLength Block-SequenceNummer FLag Start Data Ende
4 Bytes 8 Bytes 1 Byte S Datalength E
Data can be compressed or uncompressed(this is saved in flag). Data contain mor...
I have an array of integers and a number n. I want to sum the elements of the array and return the index where the sum passes n, as efficiently as possible.
For example, assume:
theString = "6-7-7-10-7-6"
theNumber = 33
expected result: 5
This does the trick but not very efficiently: (and e...
While trying to create an "admin" backend (to allow for CMS like functionality) to a site using AngularJS on the frontend, I came across an issue with routes.
In order to allow the admin to create new content, ie install new component (view/controller), change menu item href locations etc, I wou...
I was working with this problem and here is my code.
Basically the problem is to find the number fo zeros at the end of any factorial.
#include<bits/stdc++.h>
using namespace std;
int main(){
int numCases,num,zeroCount=0,mulFive,temp,i=0;
cout<<numeric_limits<int>::max()-1000000000<<endl;...
Program must to find duplicate files (by content) in a given directory(and subdirectories).
I collect all data in Map<Long, ArrayList<String>> map where Key is the size of file and Value is the List of paths to files with the same size.
public static void main(String[] args) {
long start ...
I have written an implementation of the merge sort algorithm in Java.
Here is the MergeSort class that I created.
public class MergeSort{
public static void sort(Comparable[] a){
Comparable[] b = new Comparable[a.length];
sort(a, b, 0, a.length-1);
}
private static...
Code no longer relevant but I want to know how I can make it faster. It use only about 10% of my CPU. Any advice about best practices, better algorithms, or how to make the existing one faster are welcome.
This is purely for the purpose of personal learning.
public class BruteForce {
public stat...
I am very beginning in PHP and Design Patterns. I have been studying the beautiful book "Head first: Design pattern" and I have been working in some of the codes originally presented in Java in order to learn more about PHP-OOP. The code below presents a kind of Observer Pattern. It is working we...
I am (in the process of) creating a system to store People and their details - names, date of birth (dob), addresses, phone numbers, etc. - and I'm curious how it is best achieved. Below is an an example of some of the SQL code with test data (the PHP classes match the structure in the db):
CREA...
I'm learning C for mainly for fun and to get a better understanding of how things work under the hood (most of my experience lies with high-level languages). I've been following quite a few books and working through the exercises. For extra practice, I've implemented a linked list using the knowl...
The code is working fine... But I want to get some advice on how to display an alphabetized list of the words available for the paragraph, including the number of times each word was used when the button is clicked.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3...
Im trying to build my own framework in php. Could someone say if im doing good?
I don't need to hear that i should not build my own framework because if i build my own i can extend it my own way. So if anyone have tips for my framework just let me know. Thanks!
http://code.rovox.nl/jora/src
Gree...
The biggest problem with using a for-loop to do this is that you are wasting CPU power.
When using sleep, the CPU can, in a sense, take a break (hence the name "sleep") from executing your program. This means that the CPU will be able to run other programs that have meaningful work to do while y...
It's sort of like that hockey, you have a men's team, and a women's team, and the objective is to slide this round thing on the ice and get it in to a designated target area.
Your code fails with IndexOutOfBoundsException if the input list is empty:
private void create (List<Integer> items) {
root = new TreeNode(null, items.get(0), null, null);
validate your inputs!!
Then, once you have created your tree, you have three methods to 'link' the siblings in the tr...
Here is what I have. I have it outputting most of the sums just so i can check there values. I think the problem is with the value of the elements in the array storing the column sums. I would greatly appreciate any feedback.
#include <iostream>
#include <cmath>
using namespace std;
void fi...
I use JQuery 2.0.3 and my IDE can't format ("auto-indent") this structure but when I used JSPretty I now have an indentation that I think is right.
$.ajax({
type: "POST",
url: "/submit",
data: JSON.stringify({
Confirmed: confirmed
}),
conte...
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
I wrote the following code with help of some Java 8, I'll explain the equivalent to Java 7 under the code. I'd like general comments.
public class ProjectEuler {
private fi...
Prompt the user to enter 3 sides of a triangle.
You only want values > 0 for each side, so use a
separate method to obtain the input. The method should get
input, test the input, and return the input when valid. Next, determine what type of triangle the user has entered. You will do this by sendi...
I am a newbie to Javascript (as in, this is my first time trying it). I want to make a GPA calculator, so I modified a textbook example of another calculation problem to fit my needs. However, I cannot get my code to work. I'm sure the problem must be in my variables, but I've rewritten them doze...
I think the downvote tooltip for a question should say something more relevant than "This question does not show any research effort; it is unclear or not useful"
program that can sort a list of names and telephone numbers alphabetically. Persons are sorted alphabetically by their first names. Persons with the same first name are sorted by their last names.
I want correction in this code.
#include<iostream.h>
using namespace std;
int main()
struct Person...
@rolfl has mentioned some great points, so I won't repeat those. I'll address some C++-specific things I've found, keeping in mind that Boost and C++11 shouldn't be mentioned.
These using statements:
using std::cout;
using std::endl;
using std::string;
are okay to use, but I'd still use std...
Your improvedBinary.vbproj specifies:
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
Your comment to Comintern said,
VB.NET with Strict Off (the case in this code), does allow you to write a function without return statement (although shows a warning).
This comment o...
They keep going on about how they were robbed of that empty-net goal, but don't acknowledge that the linesman body-checked the player who was supposed to be there...
Drat ... Jamal closed a question part way through an answer ... ;-)
@Mat'sMug: I've seen some feature requests on that, but nothing was ever completed. I don't know if they're still working on that. I know they're still working on a different feature to help improve the flag queue.
@rolfl: I was about to answer that as well, until I noticed how broken the program is. It is not clear how it's really supposed to work without a functioning main(). Clearly it wasn't tested prior to posting, so I gave it my -1.
I have articles on my website (built in PHP) and when an article is viewed the number of views is recorded back in the database. The SQL code snippet of my load method is:
SELECT *
FROM article
WHERE id = :id;
UPDATE article
SET views = views + 1
WHERE id = :id;
This works fine, but I've only ...
Question Downvote Tooltip
Recently I downvoted a question that was just dumping code on reviewers without any effort to put readers in context or anything whatsoever. There's a tooltip on the downvote button that is very useful on most Stack Exchange Q&A sites:
Downvote tooltip
Howev...
I had already received a request to migrate it, but I decided not to do that. I was tempted to lock it, though. We get a hot question, and we still dispute over close reasons. That seems embarrassing, especially for a site that may graduate soon.
Question Downvote Tooltip
Recently I downvoted a question that was just dumping code on reviewers without any effort to put readers in context or anything whatsoever. There's a tooltip on the downvote button that is very useful on most Stack Exchange Q&A sites:
Downvote tooltip
Howev...
Sigh. There's nothing more frustrating than being 1 of 3 answers to a SO question. The other two answers are wrong. You leave comments explaining why they're wrong and point them to your own answer for more clarity... and what do they do? Just insist that they're right.
And say "I don't care about downvotes. I just want to help."
When the fact of the matter is, a downvote is a pretty clear indication that you're not helping actually.
One of the answerers even commented that I should try his solution to see whether or not it works... to which the only reply is "Did you try it for yourself?"
Time to Answer
This query breaks down the average standard deviation of time to answer by month (questions' date asked), for the top 5 tags:
Average time to answer per tag
http://data.stackexchange.com/codereview/query/170387/time-to-answer#graph
Stdev time to answer per ta...
I am trying to convert over to mysqli and wanted expert advice. Is the enclosed code 100% oop and also how secure is the code against attacks? I know nothing is 100% secure, but how good/safe is it? How and what can I make better? This is just a generic query as I wanted to get a basic model ...
I have a PHP code structure where I cash some pages in sessions.
Example:
I have a page which shows last 10 user posts, what I do is to load 10 posts and store then in session:
Page Class:
class Page
{
var $posts; //array of Post Objects
public function __construct( posts_per_page )...