All Questions
0
votes
0answers
5 views
How should I store a list of groups of webpages with metadata?
I'm programming an entity-based web crawler, where I need to collect webpages on different people. Right now I'm iterating through a List of EntityWebpageBundles (a class I created with a label field ...
0
votes
0answers
7 views
Better implementation of Excel's SUMIFS using pandas, the Python Data Analysis Library
I've implemented Excel's SUMIFS function in pandas using the following code. Is there a better—more Pythonic—implementation?
from pandas import Series, DataFrame
import pandas as pd
df = ...
2
votes
2answers
29 views
Get contents from file
The following PHP code does exactly what I need it to do but, as a complete PHP novice, I am wondering: what can be improved here?
$theurl='./section-1.html';
function getbody1($filename) {
$file = ...
0
votes
0answers
12 views
Move a red square around a canvas? The square will not appear or move! [on hold]
This javascript code should me a rectangle around the screen with the arrow keys. It is not doing that and I am not certain as to why that is the case. Is there something that I have missed that has ...
5
votes
2answers
34 views
C++ object class review
I have implemented a basic object class in C++, and I was making sure that I have implemented everything efficiently and safely, as I made a few mistakes while making it, which I corrected, but I ...
0
votes
2answers
25 views
Same function but use different array data
I have these two carousels that randomly pick up pictures. [fiddle] Each of them picks up pictures and links from their own different inner array. It works fine as it is, but I was just wondering if ...
3
votes
1answer
17 views
Could this template function be improved?
I'm writing wrapper functions for some of the functions in <algorithm>.
While the following works perfectly, I'm not sure if this is the best way to approach it:
template<class ...
2
votes
1answer
43 views
Call to external web service
The architecture is showing a call to an external Web Service which is called by me. Then I will expose the data using WCF to be callable from another WCF client. But I really don't like how it's ...
1
vote
0answers
14 views
Queue with “unlimited” buffer in Go
This is small piece of bigger puzzle, but usable by its own.
It an attempt to have a nonblocking queue with "unlimited" (besides memory size) buffer length.
Got unit-tests 100% statement coverage, it ...
0
votes
1answer
12 views
DRYing Up RSpec
How would you DRY up this RSpec code?
require "spec_helper"
describe InvoiceMailer do
let(:user) { create(:user) }
let(:student) { create(:student, user: user) }
let(:body) { "And I for one ...
1
vote
1answer
24 views
Is this a model? What is controlling it (controller?) and how does the data get to the view?
My goal is to instantiate a class based on the request and call a method on it based on the request verb. The classes I'm referring to will have methods such as getAll, getOne, post, and so on. If a ...
2
votes
0answers
28 views
C# 5.0 TPL - Chaining Tasks with async/await
I've been trying to learn how to use the TPL for quite some time now.
Basically I'm trying to fire off a group of Tasks, wait for them to complete and then fire off another group of tasks, waiting for ...
4
votes
3answers
426 views
Making a word processor
The Word Processor I had in mind would be similar to Microsoft's word and OpenOffice. I am trying to keep my logic separated from the User Interface and that separated from the controller, basically ...
6
votes
3answers
291 views
Customised Java UTF-16
I have implemented customized encoding mechanism for javaUTF16. Does this implementation support all the characters?
public class Encoding {
public static void main(String[] args) {
...
5
votes
5answers
112 views
Fluent interface and polymorphism
I would like to improve the interfaces of some polymorphic classes going from positional to named parameters and I came up with the fluent interface.
The following is the most clean, compact and ...
3
votes
2answers
49 views
PDO MySQL spaghetti coding
I'm new to this PDO PHP and I have coded this spaghetti style. I hope you can give me idea how to improve using prepared statements. I'm not a lazy person, but I really need your help to improve my ...
-3
votes
0answers
21 views
counting occurrences of system arguments, character was expected, but received a string of x length [on hold]
import sys
from scanner import *
def main():
print("the name of the program is", sys.argv[0])
for i in range(1,len(sys.argv),1):
print("argument", i, "is", sys.argv[i])
...
7
votes
0answers
26 views
UltimateTicTacToe - ActionScript Style!
In an effort to complete this month's code challenge, I've started off with the basics. Below I have for review, a class that I can call to create the square/button a user would click to mark a spot ...
-1
votes
0answers
12 views
fputcsv is not working [on hold]
I have a html form which collects, name, place, email on submission it posts to csv file. But the php file creates a file without any data. Can any body help me in correcting the code. The full code ...
2
votes
1answer
95 views
Listing with JSON or plain HTML
I have a website which has reviews about games. Right now, to list the advantages (+) and disadvantages (-) of that game, there's a textarea in the admin panel with a WYSIWYG editor with only ...
4
votes
1answer
58 views
Thread-safe prime number source
I am working on some multi-threaded code that requires a prime-number source.
The following code keeps an array of primes in memory, extending it as needed. It works in the 'int' domain, being ...
1
vote
0answers
18 views
Objective-C CGColor causing problems in application [on hold]
I am currently working on an iPad application and have a piece of code that's causing BAD_EXC_Calls. I am trying to create the mask layer for these pages however it keeps causing errors when I run my ...
0
votes
0answers
10 views
My code should simulate three class that i want to set as threads in a class of its own? An error has occurend? [on hold]
I want to create three threads and thus have created three class that implement Runnable and then implement the run() method.
I was under the understanding that if a class implements the Runnable ...
1
vote
0answers
9 views
Irssi script to print ZNC *buffextras correctly
I'm almost entirely sure that the mechanism of action (printformat) is the only way to accomplish this.
I'm not familiar enough with Perl, however, to know if there's a more idiomatic way to write ...
1
vote
1answer
15 views
Loading Recent Posts In Session? [on hold]
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 ...
4
votes
2answers
54 views
Does this generic query follow good OOP standards?
I am trying to convert over to MySQLi and wanted expert advice. Is the enclosed code 100% OOP. Also, how secure is the code against attacks? I know nothing is 100% secure, but how good/safe is it? ...
1
vote
2answers
28 views
Validating an input string against some enum fields
I have this enum below
public enum TestEnum {
h1, h2, h3, h4;
public static String forCode(int code) {
return (code >= 0 && code < values().length) ? values()[code].name() ...
2
votes
0answers
15 views
Updating number of article views - potential concurrent access issue?
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 ...
-1
votes
0answers
29 views
Sort list of names and telephone numbers alphabetically [on hold]
This program sorts 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 ...
0
votes
0answers
18 views
Triangle class for determining the type of triangle and its area [on hold]
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 ...
3
votes
1answer
36 views
Project Euler “Largest prime factor” (#3) in Java
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 ...
1
vote
0answers
17 views
How to indent a jQuery 2.0.3 $.ajax? [on hold]
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: ...
1
vote
1answer
28 views
Test whether or not a 4x4 matrix is a magic square
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 ...
-1
votes
0answers
40 views
Snake game in C
Here is a very basic snake game in C. I just want to make this better.THe game is working perfectly but it is very annoying because when playing it, it is always blinking(I don't know how to describe ...
4
votes
2answers
63 views
Linked list implementation in C
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 ...
2
votes
1answer
39 views
Best structure for a Person in PHP classes (and databse)
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 ...
1
vote
0answers
31 views
How to deal with some of the dependencies?
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 ...
6
votes
2answers
789 views
How can I make this brute force faster?
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 ...
3
votes
1answer
22 views
Is there anything to improve in this MergeSort code in Java?
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){
...
5
votes
2answers
138 views
Optimization of file scanner
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 ...
1
vote
1answer
24 views
Number of zeroes at the end of a Factorial
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 ...
2
votes
1answer
38 views
Dynamic routing with lazy load controllers
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 ...
4
votes
2answers
44 views
Return index of array where sum first passes n
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 = ...
1
vote
0answers
27 views
Reading messages. What can be done better?
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 ...
4
votes
1answer
46 views
Is this UnionFind code efficient?
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. ...
0
votes
0answers
6 views
General table name for Person Inf [migrated]
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, ...
0
votes
0answers
11 views
Unable to figure out why my Vao+indexed vbo+shaders are failing to produce object on-screen [on hold]
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?
...
-1
votes
1answer
24 views
Determine if string's lowercase letters are surrounded by plus signs [on hold]
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 ...
3
votes
1answer
73 views
Speed up file format conversion
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 - ...
1
vote
0answers
29 views
Winforms Enhanced ListView Class
Here is an "enhanced" Listview class. You can just add it your project and you're good to go. Most of the code came from here and there. It's not perfect by any means, so any input is appreciated.
...