instruction stringlengths 71 71.9k |
|---|
I need a valid and semantic HTML structure for the user-account (user-panel) section of the overall layout of my web application.
What I saw in other web apps include:
User title (or email, or username)
A thumbnail (on which you can click to change your picture)
A notifications icon (with the number of notifications ... |
What this should do is wait for dataBlockSize bytes to be ready and then continue, but wait for 10ms if they are not ready yet to not block the CPU, but not the first time as I do not want to wait once even if the bytes are ready.
Is there a better way of doing this?
while (!cancellationToken.IsCancellationRequested)
{... |
int count;
int gcdCount;
int testCase = 5;
while (testCase > 0)
{
int n = 5;
count = 0;
gcdCount = 0;
// to get two random numbers a and b a<=n and b<=n
//get probablity of gcd(a,b) ==b
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
count++;
... |
Can I create a method to do work with these five sections? I'm doing binding operations so many times. Do you have an idea on how to make this code prettier?
ddlModelValue -> ASP.NET DropDownList
var dtModel = Session[SystemConstant.ModelSessionKey] as DataTable;
ddlModelValue.DataSource = dtModel;
ddlModelValue... |
Can someone give me suggestions on how to improve this program?
The objective is to find the sum of all the multiples of 3 or 5 below 1000.
#include <stdio.h>
main()
{
int S, s3,s2,S1;
int a=333,b=3,c=999, i=5,j=995, k=199, m = 15, n= 66, o= 990;
S1= a*(b+c)/2;
s2= k*(i+j)/2;
s3= n*(m+o)/2;
S= ... |
Please explain the relationship between pointers and arrays. In this tutorial, they change int c by changing *r in the function. How is that possible?
Also, please review my code for reversing a string. The string variable belongs to the main() function, and I would like to pass a pointer to let the strreverse() fun... |
I have a situation in which a program, communicating over the network, can timeout or otherwise fail to establish a connection through no fault of my application or its user. If and when this happens, an exception is thrown. The solution is obvious; simply try again a couple more times, and if multiple tries don't work... |
After learning a lot about programming, I've decided to write some code pertaining to scripting and use of different functions. I've come to a point where I'd like others to verify my code for correctness. Is there anything I can do better, different, or easier, to make my code more efficient?
My main goal is to dete... |
It seems like there's no good library function I can use for popen with array of arguments instead of single shell-interpreted shell. So I implemented my own one: c h.
popen_arr.h
#pragma once
struct FILE;
// Implemented by Vitaly _Vi Shukela in 2013, License=MIT
/**
* Fork and exec the program, enabling stdio acces... |
In my small application, I need to use a variety of visual themes.
The simplified structure of this class:
Theme
|
.__ menu
| |
| .__ screenBackground
| .__ itemsColor
| .__ getRandomItemAnimation()
|
.__ game
| |
| .__ screenBackground
| .__ gameBoardBackground
| ... |
I'd appreciate some feedback on my latest PHP script. It is supposed to work like this:
When obtained, it checks whether the cache is still up-to-date
IF YES, return the cache; IF NOT, reset the cache
Get all JS scripts in the parent directory
Minimize the code
Add it to the cache
Return the cache
// Script combines... |
I made a small web application with a search box. I wanted to highlight the words found in the search.
foreach my $article (@{$search_articles}) {
my @result;
foreach my $word (split(' ', $article->{content})) {
if ( $word =~ params->{search} ) {
push(@result,
'<span style="... |
This is not, strictly speaking, code review, but I think my question can be asked here.
This is a request to find out what seems to be the cleanest. This project is a blog engine that uses the file system. There are still many things to do to improve the code (it's not great). I have such a class article at initializ... |
I have the following code. It's purpose is to add up and sort another columns Data. I tweaked it to fulfil my purpose, but I'm sure it can be cleaned up.
The only problem I have with its function is it leaves a trailing zero if the last item in the referenced list is text.
Can this be changed without altering how it c... |
I'm trying to brush up on my Dynamic Programming by doing some example problems. I've got the following...
Given an array of integers, print the longest decreasing segment.
For example {4,3,2,1,5,6,7,6,5,4,3,2,1} would print "7, 6, 5, 4, 3, 2, 1"
The following is my solution.. I think it looks okay and it has a decent ... |
The program is behaving like expected, but I think something better can be done since I'm a novice C programmer. I suspect that the interrupt handler can use some other way of calling the hardware instead of direct memory. Can you look and tell me what can be improved?
#include <stdio.h>
#include "system.h"
#include "... |
I am trying to use IXMLDOMDocument for XML reading/writing. I am not good COM, and I am not aware that I am doing things right or wrong. I am very unsure that there could be some problems with COM initialization and relase. Here is my code below and let me know If there are any possibles bugs / memory leaks here due to... |
I'm relatively new to PHP and have recently created a small website for friends and family to upload and share photos, protected by a very simple login system.
While I'm aware what I'm doing isn't best practice and you'd never use this in a "published" site, I'd like to use this as learning experience to improve my cod... |
I'm try to implement the SSIM method. This method has already been implemented in Python (source code), but my goal is implement it with using only Python and NumPy.
My goal is also to use this method on big images (1024x1024 and above). But filter2 works very slow (approx. 62 sec. for 1024x1024). cProfile gives me inf... |
The idea is to write a function that reads string of unknown size from stdin, keep it in dynamically allocated array of unknown size and return a copy of that array.
Is this the right approach? Could I be more clear? Would reading the input char-by-char be better than getting bigger chunks at once?
#include <stdlib.h>
... |
This is my solution for an exercise from a book. It's a simple Golf class with member variables fullname and handicap. The constructor sets the variables to the provided name and handicap using values passed as arguments. The setgolf() function solicits name and handicap from user, creates a temporary Golf object and ... |
I'm working in my project with the following script:
;(function($, doc, win) {
"use strict";
// cache the window object
var jQuerywindow = $(window);
$('section[data-type="background"]').each(function(){
// declare the variable to affect the defined data-type
var jQueryscroll = $(this);
$(window).scrol... |
I'm learning F# and I'm trying the following exercise (exercise 4.10 of Functional Programming Using F#).
Declare an F# function prefix: 'a list -> 'a list -> bool when a:equality. The value of the expression prefix[x_0;x_1;...;x_m] [y_0;y_1;...;y_n] is true if m<=n and x_i=y_i for 0<=i<=m, and false otherwise.
I wan... |
Is there a more reliable way of getting the content elements for each SVG element?
#-----------------------------------------------------------------------
# Get Element content from SVG specification from:
# http://www.w3.org/TR/2011/REC-SVG11-20110816/single-page.html
# Philip R Brenan at gmail dot com, Appa Apps Ltd... |
Is there a more reliable way of building a hash of the attributes associated with each SVG element?
#-----------------------------------------------------------------------
# Hash of SVG elements, attributes,animation from:
# http://www.w3.org/TR/2011/REC-SVG11-20110816/attindex.html
# Philip R Brenan at gmail ... |
I'm just getting started with XNA and game development in general. I followed these instructions to create a basic game, then this article to get sprite animations working.
Now, I'm trying to abstract my design, in particular the stuff with sprite animations. Before I get much deeper, I want to make sure I have a good ... |
Below is the code for my templated callback implementation. Currently it works for a single parameter. One thing I was going to try and do next was increase the argument to the function from 1..N arguments. Ideally this would be as simple as adding Args... everywhere using variadic templates. I don't have a lot of expe... |
I was trying to write code which does a validation for the below wildcards:
'?' ------> The question mark indicates there is zero or one of the preceding
element. For example, colou?r matches both "color" and "colour".
'*' ------> The asterisk indicates there is zero or more of the preceding element. For exampl... |
There is an e-commerce site that I'm working on that has thousands of pages in it (mostly product pages). I've got some jQuery that I'm running on about 1300 of these products. Only specific products need the code to run so what I've done is set up the product codes (which display in the URL of the product) in a JSON d... |
Question 1: functionxxx_as_string() is used below. How else could it be more elegantly named?
Question 2: Is the static char* array method adopted below the only solution? Best solution? Any suggestions?
Generally, I have this issue where my list of enums will be from 3 - say 50 items, mostly less than 20 items and ... |
Can the below foreach loop be improved? Since I use the same method twice, maybe use continue or break?
int? index = null;
int count = 0;
foreach (Break b in breaks)
{
if (index.HasValue)
{
if (index == count)
b.Remove();
}
else
{
b.Remove();
}
count++;
}
So I t... |
I am creating a performant C# socket server. I'd like it to be able to accept as many simultaneous connections as possible. I've tested with 100 clients and all clients are fine. With 1000 however, clients begin to stop connecting. Is it possible to improve something to increase the number of simultaneous connections? ... |
Here's my version of singly linked list. Any constructive criticism is highly appreciated.
First header file "sll.h":
#ifndef _SLL_H_
#define _SLL_H_
#include <stdio.h>
#include <stdlib.h>
/* declaration of node in Singly linked list */
typedef struct node{
int value;
struct node * next;
}NODE;
/* declaration of ... |
I am writing an open-source application for real-time messaging in web. In my application clients from browser can subscribe on channels. But every channel belongs to a certain namespace which determines channel's settings:
client.subscribe('/football/news', function(message) {
// message from channel received
});
... |
I was wondering what would be the most appealing way of achieving this goal.
I have a blackbox. I give it a supported type and it returns a random value base off of the type.
For my supported types, I have an enum defined as follows:
public enum Types
{
INTEGER,
DOUBLE,
BIGINTEGER,
BIGDECIMAL,
STRI... |
How to improve this kind of redundancy?
$nid = isset( $_GET['nid'] ) ? $_GET['nid'] : 0;
I want to avoid to repeat $_GET['nid']
Example of useful use case:
$nid = isset( $node->field_mymodule_extended_nid['und'][0]['target_id'] ) ? $node->field_mymodule_extended_nid['und'][0]['target_id'] : 0;
|
This program calculates the min and the max value and the average of the items of a vector. It's an exercise from a book so I can't change the header file.
Is this code proper?
sales.h
#include <vector>
class Sales
{
private:
std::vector<double> sales;
double average;
double maximum;
... |
i have an vector<tuple<A,b> > v and want to make a map<A,B> from it
i came up with 3 variants:
std::transform(v.begin(),v.end(), std::inserter(map,map.begin()),[](std::tuple<int,char> t){
return std::make_pair(std::get<0>(t),std::get<1>(t));
});
std::for_each(v.begin(), v.end(), [](std::tuple<int,char> t){
m... |
So I came up with a problem In C. Our compiler is pre c99 and wasn't identifying functions that are never called. So I ended up writing this script and decided to post it up to be critiqued and to help people who might be in the same predicament. The script works great for me and finished the job that I needed it to do... |
This solves an algorithm that we have. The script is used by an ArcGIS tool as well as another tool that takes this script and cycles through roughly 6,000 bridges.
Note: I didn't separate the code intentionally into configs and testing code for you to review the whole thing in one screen.
"""
This file solves the alg... |
I worked on a Red-Black tree implementation in C++, and it works as it should. However, I want to see what else I can do to make this code faster/more clean, etc.
Any particular suggestions?
Edit: code I want most looked at is below (insertion into the RBtree)
/******************************
RBInsert
Purpose: Insert ... |
I'm learning C and have made this very simple function to compare two strings. I would like to know how it can be improved:
int match(char* string1, char* string2)
{
size_t i = 0;
while (string1[i] != '\0' || string2[i] != '\0') {
if (string1[i] != string2[i]) {
return 0;
}
... |
if (progressBar1.Value == 1) { progressLabel.Text = "1%"; }
if (progressBar1.Value == 10) { progressLabel.Text = "10%"; }
if (progressBar1.Value == 20) { progressLabel.Text = "20%"; }
if (progressBar1.Value == 30) { progressLabel.Text = "30%"; }
if (progressBar1.Value == 40) { progressLabel.Text = "40%"; }
if (progress... |
I have just made a simple script which spawns an alien that chases the player. I want to move as much of the script into functions so as to minimize the amount of code, to make it run better when my game gets a lot bigger. I am new to functions and classes, and I want to know what can be turned into a class in another ... |
I've been playing around and reading up on some sorting algorithms, and I've decided to try writing my own. It turned out to be quite fast (compared to the others shown in the image below).
I'm very curious to know a little bit about it:
Does my algorithm already have a name?
What are the downsides to it (other than ... |
The class is responsible for wrapping requests to a WCF Data Service, which tidies up calling code. Transactions are implicitly supported. It should efficiently send just updates to the services (only changed values). The next step is to modify it and allow named properties to be queried, rather than all fields.
Pleas... |
I have been teaching myself programming, mainly in Java, for about 6 months. I'm looking for some feedback on this implementation of the Game of Life, which runs entirely in the terminal. Specifically, where does it not follow best practices, is it over-engineered, etc?
The entry point:
public class GameOfLife {
... |
The following program is intended to "watchdog" a child process, and all subprocesses the child spawns.
The intended behavior is:
A child process (as specified on the command line) is run in a dedicated process group.
If that process exits, or if it stops producing heartbeat output, the entire process group is killed ... |
I just completed K&R (2nd Ed.) ex 1-18. I'm fairly new to C, but have had experience in other languages (Perl, C++, Java, Common Lisp, PHP, etc) and really want to learn the C idiom as opposed to translating the idioms I already know.
What do you think about this approach to 1-18?
/*
Exercise 1-18 in K&R 2nd Editio... |
This is one of my first real apps I've made with javascript(jQuery) so I know my approach probably isn't the best and my lengthy code shows. I created this simple app that spits out what customers can expect to pay if they purchase our software, but it has a TON of price points and with my limited knowledge this was th... |
I am facing a issue with an API to handle dates in Java. I am not a very experienced programmer and my English is very bad.
Problem
I'm working in a large project with many subsystems, and I want to make a Date Utility library to manage all dates in the system.
Requirements
Platform
The front end is a JSF page with Ri... |
I have been staring at this code for awhile now and I am thinking there is a way to optimize it (namely the if-else statement with the for-loops).
Additionally, this needs to be done with an array list as that is my assignment requirement. I have all my code working, and it is not due for a few days, so I am looking f... |
I managed to create my first wordpress plugin template page collecting various code snippets to make the page function.
Everything works fine, but I need hear comments from PHP & wordpress experts to see if it's well-coded.
Here's the code.
<?php
/*
Plugin Name: name
Plugin URI: http://www.example.com
Description: desc... |
I was writing a program and I needed a function that could ordinate the argv according to my preferences. That way, getopt would parse the options as needed. I couldn't find any, so I wrote one. I would be very thankful if you guys could have a look and say what you think about it. I'm a C beginner, so don't save c... |
x = int(input("Choose the number of times you want to spam. "))
y = input("What message do you want to spam? ")
w = x + 1
for i in range(1,w):
print(y)
Any way to make this program better? I'm currently learning Python.
|
I am calling defvar in the middle of a function definition. And so far I've always seen its use, with defparameter for global variable. Like *error-output* or *standard-output*.
(defun consume-socket-reply (socket end-test-form)
(do* ((line "" (read-line (usocket:socket-stream socket) nil))
(text "" (concaten... |
I'm beginning to learn Haskell. I've implemented the Graham Scan algorithm for detection of convex hull following the Real World Haskell book.
I'm looking for general advice regarding the style and convention of my code, as well as best practices and ways to refactor several ugly places:
Vector2D and its accessors. It... |
Are there any ways to make this calculator script for Python better or simpler?
thelist = ["Add", "add", "Multiply", "multiply", "Divide", "divide","Subtract", "subtract"]
def Multiply(x,y):
z = x * y
print(z)
def Divide(x,y):
x = float(x)
y = float(y)
z = x / y
print(z)
def Add(x,y):
z = x + y
print(z)
def Subtrac... |
This is a simple mixed drink calculator written in Haskell.
There are two input files. The drinks file contains a list of simply formatted recipes for mixed drinks:
screwdriver:vodka,orange juice
white russian:vodka,coffee liqueur,cream
greyhound:gin,grapefruit juice
...
The ingredients file contains a line-separated... |
Currently I have a game that does this and then checks for victory conditions in victoryTable
victoryTable[0] = rows[0][0] + rows[0][1] + rows[0][2];
victoryTable[1] = rows[1][0] + rows[1][1] + rows[1][2];
victoryTable[2] = rows[2][0] + rows[2][1] + rows[2][2];
victoryTable[3] = rows[0][0] + rows[1][0] + rows[2][0];
vi... |
I am trying to write code to convert properties of an Entity Framework entity to strings and back.
Here is the code so far that converts back from strings to the object properties.
I am stuck trying to figure out how to handle datetime. I am also wondering if there is a better approach.
private static FormatterConvert... |
I'm new to Java and Android. While I've created a project that seems to work, I'd like some opinions on how to make it better.
The app is going to be used as an interval workout timer/music player for Android devices. I know there's a ton of these already, but I thought it'd be a good way to learn the language, and i... |
I made a Java program that asks for a word, then a screen width, then whether you want it to go fast or slow. Then it outputs that word and bounces it across the screen. Is this code efficient for what it does? Is there a better way to do it (without a pre-defined method/class)? And does it look professional and eas... |
I am not sure if I am correctly handling $_POST data in MVC pattern:
Dummy $_POST data
$_POST = array(
"menu" => array(
"key_name" => '',
"pub_name" => ''
)
);
View
$connection = null;
$entry = new menuPostController($connection);
echo $entry->renderXML();
I will get this result when there th... |
I am toying around and playing a lot with defining a function. I'm trying to get extremely comfortable with it. The code I have wrote works fairly well, but definitely is not perfect. Also, the function I made called playagain is having some errors. When I type in "Yes" for the input I'm getting a strange TypeError. If... |
I have the code below to get an infinite generator of the products of an iterable (e.g. for the iterable "ABC" it should return
A, B, C, AA, AB, AC, BA, BB, BC, CA, CB, CC, AAA, AAB, AAC etc.
for product in (itertools.product("ABC", repeat=i) for i in itertools.count(0)):
for each_tuple in product:
print(ea... |
For a code challenge, I'm trying to write a comprehensive URI parser in Python that handles both URIs with authority paths (ex: URLs such as http://user:login@site.com/page?key=value#fragment) and other URI schemes (ex: mailto:mail@domain.com?subject=Blah).
Here's my current code:
import json
import re
class Uri(object... |
Here's a trick for preallocating some memory for some type T. Do there exist similar tricks? Improvements?
#include <cassert>
#include <cstdlib>
#include <atomic>
#include <limits>
#include <new>
#include <thread>
#include <utility>
namespace
{
template <typename T, typename A = unsigned>
struct static_store... |
I wrote this block of code as part of a JS utility library I'm working on. I will be thankful if someone could scan through it for eventual bugs or improvements that might be applied to it.
The idea is to create a function that will configure an object to manage its own data collection by attaching .data() function t... |
I want you to pick my code apart and give me some feedback on how I could make it better or more simple. In my opinion this is the best code I have written, being that I'm new to programming. The program is a basic "converter" that has the user input his/her age and it tells how many days, hours, and minutes the user h... |
This code finds a common ancestor. If one of the input does not exist in the tree then throws an exception. This does not use extra storage. It does not even traverse more than what it should be. It would also account for duplicate node values in binary tree.
I want you to pick my code apart and give me some feedback o... |
I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code finds a common ancestor for binary search tree. This code accounts duplicates as well as incomplete tree, and also throws an exception if input element is not in the tree.
public class LeastCommonAncestor... |
My professor wants me to do this:
Write a number of interchangeable counters using the Counter interface below:
public interface Counter {
/** Current value of this counter. */
int value();
/** Increment this counter. */
void up();
/** Decrement this counter. */
void down();
}
I need comments on my work so far. Do ... |
I'm building a mini-app that will display when changes to the DOM have been made by JavaScript. I have all of the functions that I can think of listed in the code. Is there a way to consolidate the functions into one, and have the overrides still function correctly?
var DomChanges = (function() {
var a = Element.pro... |
I'm writing a program for my intro to comp sci course where I'm supposed to prompt the user to enter a stream of integers, and then return the largest two. We were given the hint to use a scanner and a while loop with the condition .hasnext.
Please review my code:
package Homework;
import java.util.*;
public class Qu... |
I've been practicing implementing a linked list from scratch. Can someone help review my code?
class Node {
Node next;
int num;
public Node(int val) {
num = val;
next = null;
}
}
public class LinkedList {
Node head;
public LinkedList(int val) {
head = new Node(val);
... |
I wrote a script for validate the input field for following requirements
Not null
Multiple of hundreds
Less than needed amount
Here is my script:
$('#investAmount,#invest-button').bind('keypress', function(event){
if(event.which == 13){
if(amountValidation('#investAmount','#inNeedAmt... |
This is the original version of code written by my coworker that replaces every null cells with an empty string.
for (int i = 0; i < dGV_factory.Rows.Count; i++)
{
this.dGV_factory["dGV_factory_groupID", i].Value
= this.dGV_factory["dGV_factory_groupID", i].Value ?? "";
this.dGV_factory["dG... |
I'm building a rails app that, among other things, imports text markdown files as blog posts. The idea is that the truth is in the markdown files, so any time those are edited, created, or deleted, the blog should reflect this. Of course, I had to make this more complicated and insist that I should be able to edit, add... |
I received the following question in a technical interview today (for a devops/SRE position):
Write a function which returns true if the two rectangles passed to it
as arguments would overlap if drawn on a Cartesian plane. The
rectangles are guaranteed to be aligned with the axes, not arbitrarily
rotated.
I pr... |
This method works correctly and verifies whether a user has permissions to view or edit the first parameter (value). I think it is not the best implementation, because there are too many conditions and the List object isn't necessary. How to improve it?
protected override Exception GetValidationException( object value,... |
I want to run the timer at 2:00 a.m. and shutdown the application.
This is my code:
var ShutdownTimer = new Timer();
var currentTime = DateTime.Now;
int hoursUntilShutdown;
switch (currentTime.Hour)
{
case 1:
hoursUntilShutdown = 1;
break;
case 2:
hoursUntilShutdown = 0;
bre... |
I have been working on a toggle script, but I find myself repeating my code. Is there a way of combining it all?
jQuery(document).ready(function($) {
var topContainer = $("#alles");
var topButton = $(".abutton");
topButton.click(function() {
topContainer.slideToggle(1200, 'easeInOutQuart');
... |
I need some tips on how I can improve the design of the following code. Everything works correctly in the program. It takes a string and shows each token, the only tokens being numbers and operators. The output shows all the tokens and what type of token they are.
public class Tokenizer {
int pos;
char[] expre... |
I have the following code which changes the text in a certain element on click depending on the text value present in the element at the time the event is fired.
http://jsfiddle.net/TNDhL/
$('#left').on('click', function (){
if ($("#textContainer:contains('something')").length) {
$('#textContainer').text('third tex... |
I've read the docs online explaining Log N and I do understand that the basic concept of it, but I'm still not sure I've managed to nail it.
The problem
This exercise is called "Complementary Pairs" and given an array A
and an integer K, how many pairs of A, sum to K.
For example, with this input:
k = 6 a = [1, 8, -... |
I'd like someone to suggest a better way to create this pattern in Java which I'm sure is possible:
*********
* *
* *
* *
* *
* *
* *
* *
*********
I'm working my way through a new Java book and am examining string patterns.
public static void drawRectangle() {
// y axis
... |
I have a page where a user needs to click two checkboxes before continuing (agree to two terms of service). My jQuery is fairly straightforward, you have to have both check boxes checked to continue:
$("#agree1, #agree2").click(function () {
if ($("#agree1").is(':checked') == true && $("#agree2").is(':checked') == ... |
I have the following data structure:
data XComposeString = XComposeString { keyEvents :: [Event], s :: Result }
deriving (Eq, Show)
data XComposeFile = XComposeFile { strings :: [XComposeString] }
deriving (Eq, Show)
Where Event and Result just String or some combination of several String.
I'm creating a Trie fro... |
This is a data structure I wrote:
It is an circular first-in-first-out queue (a ringbuffer);
It has batched removal/popping - it returns an array of a fixed buffer size;
It is unbounded, and grows itself as needed;
It is generics-compliant (at the cost of primitives).
It is (supposedly) thread-safe.
It is (suppo... |
This is a program I made to bounce the letter a across the screen. I made a few others, but this one I made with a recursive bounce() method. I know main() is a bit empty, but I intend to make an input menu that main refrences, so it seemed better to put the code in another method.
Is my code clean (probably far fr... |
I am trying to open two CSV files, one for reading and one for writing. The script should continue only if both files were successfully opened. My code seems to accomplish that but it seems like it could be improved further.
My questions are:
Should I consider a different approach?
My code feels a bit bloated inside t... |
I'm working on a simple CMS with the intent of making it as secure as possible (a personal challenge) and the code as clean as possible. I think I've a long way to go so I would appreciate any input, or bug spotting!
Common.php
<?php
// Errors, errors everywhere. Let us display them all!
error_reporting(E_ALL... |
What is the general design pattern for declaring variables in a class?
I have a homework assignment to create a simple Java program which asks the user for a range of two variables. The program then creates a random variable from within this range and prompts the user to guess the number.
I'm having trouble understandi... |
Just getting into functional programming and F# with the most appropriately titled Functional Programming Using F#. I wrote the following function definition for problem 2.4 but I'm thinking there's most likely a more elegant and/or idiomatic solution:
let rec occurrencesFromIth =
let bool2int x = if x then 1 else... |
This code can be found in the archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
#ifndef CMW_ErrorWords_hh
#define CMW_Erro... |
Just looking for some pointers on how I could improve the code. This is my first game ever and python is my first language so it's bit messy but I'll be happy to explain stuff if needed. I'm kinda frustrated cause some bits look really ugly and I hope you guys can help me out. Here it is:
EDIT: cleaned up the code and ... |
I have a Task model in Django which looks like the following:
class Task(TimeStampedModel):
project = models.ForeignKey(Project, related_name='tasks')
date = models.DateField(_('date'))
task = models.TextField(_('what\'s the task?'))
status = models.CharField(
_('what\'s the status'), default=co... |
I'm supplying a HashMap with data in the following way:
HashMap<String,MyClass> myHashMap = new HashMap<String,MyClass>();
myHashMap.put( "foo", new MyClass(2,4) );
myHashMap.put( "bar", new MyClass(0,10) );
myHashMap.put( "a", new MyClass(0,0) );
myHashMap.put( "b", new MyClass(0,1) );
myHashMap.put( "c", new My... |
I have an array of objects that each have a name/value property. The array can contain multiple objects with the same name property. I want to serialize this array into the form:
name:value,value|name:value|name:value,value,value
So basically each property is separated by a | and each value by a ,. The above exampl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.