instruction stringlengths 71 71.9k |
|---|
I have a server side PHP file which processes Ajax requests from the client browser. Some requests are only valid if they originate from an Administrator in the application, others are only valid if they originate from a Manager in the application, and the rest are valid if any system user makes the request.
I covered ... |
I have completed an application which gathers specific records and marks them as Collected. As of now, the application runs perfectly and does exactly what I need it to, but the problem comes in when a large data set is reviewed. If I am pulling records for one day or even maybe a week, it runs at a decent pace, but on... |
The code below takes a specified number of card decks, and shuffles them according to the Fisher-Yates method. Does this implementation have any bias?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace randomShuffle
{
class Program
{
static void Main(string[... |
I've been creating javascript things for a good few months now, as practise but whenever I use a functions I just create it and plug in the arguments. I'm never touching modules or classes or anything, and I just want to know how this code could be better, using modules and classes. Various function are sort of part o... |
I have multiple menus that will change languages in one Sub that will handle multiple events of the menus click, It is working for me right now, I'm just wondering if there is better way to do it... I'm using the menus name to call the process for each menus.
Private Shared Sub CheckMenuItem(ByVal mnu As ToolStripM... |
I am creating a user permission system. I will have my user permissions set up off of "objects" and not pages. For example, I have an EVENTS section. Within that section, there are FORMS, FEES, etc. I want to be able to handle permissions down to the child levels.
Here is my permission_objects table:
| id | object | pa... |
This code is to allow calling any stored procedure with one user defined table as the parameter.
I usually use Entity Framework, but I just don't need it for my current solution, so I am rolling my own connection here:
public class GenericDataModel
{
public GenericDataModel(string connectionString)
{
th... |
I need some help refactoring my solution to the problem below:
Problem Statement
An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit ... |
I have a map of objects and errors associated with those objects.
I have to do the following:
populate the errors in the object
populate errors for valid objects based on the following:
check the indicator property in the object ( Y | N | other )
if all have Y and if there are invalid records - need to reject all
S... |
I'm reading/writing half precision floating point numbers in C#. These are basically 16 bit floats, compared to the usual 32/64 bit floats and doubles we are used to working with.
I've taken some highly tested Java code from an obvious "expert on the subject" here and modified it to work with C#. Is this correct?
// ig... |
I recently made a 140-lined Pong game in C# using forms.
Since I'm very new to programming, I'd like if somebody would please read it and give me advice on where to improve, what you believe I did wrong and most of all, what should have been done better and how.
Plus, would it be somewhat useful to implement delegates ... |
I have a form that requires a calculation when clicked on a multiple drop down selector, and still displays the clicks of the courses in real time and lastly calculates the sum total of the courses.
<!DOCTYPE html>
<html>
<head>
<style>
div { color:blue; }
div#five { color:red; }
div#show_box {
backgro... |
I'm refactoring some code around a couple of ASP.NET Web Forms pages and decided to try out a variation of the Abstract Factory pattern of my own design. I need to create an implementer of an abstract class based on what query string value is available.
Here's (a simplified version of) what I have right now:
internal s... |
I decided to try to make a simple RPS implementation in Java 8, the following notes should be said first:
At a later point it should support RPSLS aswell, as any other Gesture-game variant.
At a later point it should support different views, for example a graphical one.
I have made a special ConsoleReader class which ... |
How can I write this OR statement better, allowing for growth in number of values?
var isNewFile = (progressID == 10 || progressID == 20 || progressID == 21);
I was thinking of this:
var isNewFile = progressID.Contains (10,20,21)
OR using Linq:
.Select or .Contains
Any thoughts?
|
It returns true for:
a*(b+c)
()()
(())
((!!(123(x))))
and returns false for:
(a((b+c))
)()(
))((
(rsd+3)*(-3-a))
As you can see, the logic is simple. Can you confirm for me that it works for all-cases? I mean the logic isn't flawed.
It must be efficient and by that I mean not go over the linked list more than o... |
I wrote a messy function and I am wondering if you see any way I could clean it up. Essentially it takes in a list e_1=2&e_2=23&e_3=1 and makes a queryset out of it, maintaining the ordering.
from operator import itemgetter
def ids_to_students(items, prefix=0):
if prefix == 0:
# Make ordered QuerySets of ... |
The lifetimes of various objects referring to each other are sometimes only known at runtime. For example, in a side scrolling shooter game, a HomingMissile instance might have a pointer to the Target instance it is following. But if the Target is killed before the missile arrives, the HomingMissile is left with a dang... |
I am experimenting with streams and lambdas in Java 8. This is my first serious foray using functional programming concepts; I'd like a critique on this code.
This code finds the Cartesian product of three sets of ints. My questions/complaints about this snippet are:
Are nested flatMaps really the best (most understan... |
I have this script that I need to run a tab (jquery). Mainly I need to hide some div and add class (you sure have understood).
How should it be written in a more elegant and readable?
function fun1(){
$('#tab1 a').addClass('selected');
$('#tab2 a').removeClass('selected');
$('#tab3 a').removeClass('selected');
documen... |
I have developed a service to automatically detect whether an app has started. If the user forbid this app to start (could be chosen from a list of apps), a dialog will be shown.
public class AppStartReceiver extends Service {
private static final int DELAY_IN_MS = 2000;
private List<String> forbiddenApps = new... |
Because we have a mix of both icons for core items and .png icons for custom items, I've developed an easy way to theme them (alter the color) all of them easily that will work across all browsers.
Prior to this, I tried CSS and SVG options and they just weren't as simple as this option (but probably less overhead of c... |
I have created a little console tool that simply does commands that you enter.
The commands are stored in a txt file. Right now I only got 2 commands: getTime and getCommands.
Pretty simple, but I'm not sure I'm doing anything the most optimal way, which is why I am asking here. I was thinking about creating a whole c... |
This is a sign up function called on form submission. It firstly inserts key user data into the users table. If successful, secondary data is then inputted into respective tables (such as user job titles and user experience). I'm not really sure whether stacking queries 2-5 is the best way to do it, so I would be inter... |
I have a manager class that will manage an unknown number of objects. I'm currently storing the objects in a NSMutableArray object, and when I need to find one, I iterate through the array comparing pointers.
For example, I have an array called managedObjects. I get a delegate method call:
- (void)someDelegateMethod:... |
I am writing a D3D9 hook plugin to give back to a community that helped me learn programming. It is a community based on programming and scripting for games.
The plugin is supposed to hook d3d9.dll and allow clients to read pixels from the backbuffer. That is the entire extent of the plugin.
Thus I have hooked only the... |
This is a chunk of code I wrote for a job interview at some point - it is a remote key-value storage REST API supporting CRUD operations.
Maybe anyone has some feedback on this? It would be very helpful for me.
I did not attach the tests, since it might be a little bit too much code. You don't have to review both files... |
I am making a website that takes a bunch of dining hall information and puts it all together in a neater (and hopefully more mobile friendly) form.
Here is the link:
https://googledrive.com/host/0By7Z_HHj2VhnWmlhbWl4aF8xdFU/nuEats.html
It's a little incomplete at the moment, but what it does is the bar up top shows yo... |
Is there a more efficient way to write this? Seems redundant to me:
var leaves = $(".leaf");
var trees = $(".tree");
$(".my-class").on("click", function (e) {
if ($(e.target).hasClass("leaf")) {
trees.each(function() {
$(this).attr("tabIndex", -1);
});
... |
I have some animations happening after some delay calls the code to animate. It works fine, but the code to call the functions is not nice.
double delayInSeconds = 0.2;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds + 0.1 * NSEC_PER_SEC);
dispatch_time_t popTime2 = dispatch_time(... |
Description
This is my code for the Weekend Challenge Reboot - Tic Tac Toe Ultimate.
The game can be played here: http://www.zomis.net/ttt (along with some other variations that are also use the same code base, but with other 'controllers').
This question contains the game model and a 'controller' for the TicTacToe Ult... |
This code is starting to be used within several of my projects, and therefore I thought it's time to get it reviewed.
Description
The most common application for this code is that there is a computer opponent in a game which needs to make a decision based on some parameters. A list of all possible decisions that can be... |
Can I get some pointers, critiques and/or comments on the following model? (p.s. performance seems great... tested all methods up to 10,000 records)
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class o7th_Model extends CI_Model {
private $msg;
private $last_id;
private $full_q... |
My design goal was to try and make a "clean" and well-designed Tic-Tac-Toe game but also to try and use concepts and programming constructs that I'm new to.
I'm planning to implement an "AI Player" class later on. I know that Tic-Tac-Toe is a solved game so there are more effective approaches for AI logic but I've ne... |
I have been working with Java for a little more than a year. I recently have built a Tic Tac Toe game as an assignment for my Java class. After my instructor graded it, he wrote a comment around my validation method logic. Even though I got 100%, he said that the logic in my validation method is too cumbersome. He stat... |
I have nginx serving files with uwsgi and I wanted to lock my server down just to allow SSH and Nginx to run.
#!/bin/bash
i=/sbin/iptables
# Flush all rules
$i -F
$i -X
# Setup default filter policy
$i -P INPUT DROP
$i -P OUTPUT DROP
$i -P FORWARD DROP
# Allow unlimited traffic on loopback
$i -A INPUT -i lo -j ACCEP... |
I'm developing a Chrome extension so I can use bleeding-edge technologies like flexbox:
jsfiddle
HTML:
<label for="example-search">Classic search example</label>
<div class="input-wrapper">
<input type="text" id="example-search" />
<button>Search</button>
</div>
CSS (cleared to highlight flexbox):
.input-wrapp... |
I am attempting problem 7 on Project Euler. I have come up with this solution which works fine for finding smaller nth prime numbers, but really lags when it comes to higher nth prime numbers. I am not quite sure where to start to make it more efficient.
public class TenThousandFirstPrime {
public static boolean... |
I just tried BDD for the first time and implemented a simple Semantic Versioning Bumper in Python.
The class takes a version string in the format of major.minor.patch (i.e. 3.2.2, where major=3, minor=2, patch=2). Then you can bump a level, say patch, and you'd get 3.2.3. If you bump minor, you'd get 3.3.0 and if you b... |
I am trying to understand the concepts of friend functions, overloaded operators, and inheritance in C++. I am very confused on the specifics used for coding, since I am fairly new in programming, and working in the Visual Studio C++ environment in writing code.
The following is the project details for writing a progr... |
This is a hard question for me to ask, because I don't really know how to explain it. So, please, bear with me.
Bootstrap menu, as I know, has 2 modes: "desktop" mode "phone/tablet" mode. The desktop mode is anything above 767px width, and the later is anything below or equal (to 767px).
Easy, we copy the navbar exampl... |
This game is similar to a Dungeons and Dragons game. How could I improve the efficiency of the program? For example, where can I add functions, records etc? This is for a school Controlled Assessment so any help would really be appreciated.
import random
play1 = True
str1 = int(input("Enter a value for strength"))
... |
Below is my solution for this 'Team Split' problem.
In summary, the problem is to find relative strength of 2 teams by finding the difference between their total strength (individual strengths can be found using a quadratic expression of form ax2+bx+c).
The solution in Java manages to solve the problem, but I am regula... |
So today after few years of not programming in PHP I decided to go back, but to do so I needed to change all MySQL connections. So I want to check if I am using it good.
Earlier I used to write something like this:
$user = clean($_COOKIE["Logged"]);
$GameReg = mysql_fetch_array(mysql_query("SELECT * FROM DB.GameReg WHE... |
A secret santa gift exchange is a game where each player is randomly assigned a person to whom they anonymously give a gift. The algorithm is referred to as Derangement.
For example, given the following players:
Mohamad, Carolina, Sami, Tania, Ikram, José
A game may be:
Mohamad gets Sami
Carolina gets José
Sami ... |
For class we were to make a MapReduce program in Python to find low value hashes of our name. I have completed the assignment but want to try and speed it up. The program currently takes about 45s to complete. I would like to see if there are any suggestions on speeding it up some.
The requirements are to find hashes o... |
I'm writing a virtual machine in Python using RPython and the PyPy toolchain. The RPython will still work in the ordinary Python 2 interpreter; it's just a bit slow unless it's compiled to C code with PyPy.
Does anyone have any positive or negative feedback about my VM?
The virtual machine has 4 instructions:
EOP - En... |
I'm using a third-party library which utilizes boost::shared_ptr for memory management.
The problem is that I need to allocate many objects and I have detected that the allocation and deallocation is rather resource-demanding. So I thought I should utilize a smart-pointer memory pool to reduce the overhead.
#include <b... |
I'm working on a little game where you press a button and a new image appears. There's a glitch every time you ask a new image to display and it occurred to me that I should preload the necessary images. However, I'm not sure how to do this efficiently as I'm not using a variable to display the images. It's also been p... |
I'm currently in the process of coding a QuadTree. The QuadTree seperates into four quadrants, with 1 being the top right and 4 being the bottom right. I have this code to determine which quadrant the AABB fits into:
int getIndex(AABB aabb) {
int index = -1;
double vertMid = bounds.getX() + (bounds.getWidth... |
I have some triggers placing and sizing elements for video controls. It works well enough but mostly through trial and error and I am not sure if there is a better pattern:
The full source can be found here and webpage here.
My biggest issue I think is when is it appropriate to have an element listen (e.g. on the speci... |
I'm currently implementing my own QuadTree in C++. It runs well with 100 items, but once you start adding more it slows down. remove, getAll, and insert have all been profiled as taking a while. Any advice is appreciated!
class QuadTree {
private:
const static int MAX_OBJECTS = 20;
AABB bounds;
std::ve... |
I am trying to implement ugly number sequence generation in Scala.
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15...
I have implemented using var keyword like java implementation and it is working fine. Here is the ideone link of complete code.
Can some... |
I am using this code in a lot of places:
if (ParameterName == null)
{
throw new ArgumentNullException("ParameterName");
}
But I think this is not DRY. The only difference here is ParameterName. Is it ok to use these lines everywhere, or is there a way to make it DRY?
|
I was wondering if any of you know any best practices or design patterns so that I can have good logging in my programs without them looking messy or bloated.
I am currently using C# and NLog, however I guess any advice here would be language and tool agnostic.
The problem we have is that we want to have good logging, ... |
I have more than 1000 items in my GridView. When scrolling though, it appears to make the app 'shutter'. Each time I load images from Picasso GC, it increases.
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import a... |
Here is my Bubblesort code:
public static List<int> BubbleSort(List<int> _digitList)
{
List<int> digitList = _digitList;
bool didSwap = true;
while (didSwap)
{
didSwap = false;
for (int i = 0; i < digitList.Count - 1; i++)
{ ... |
I have a multi-threaded app (WCF) that writes to a MySQL db. I want to use MySQL's built in connection pooling abilities.
As far as I can tell, to do that, I should set MySqlConnectionStringBuilder.MinimumPoolSize to some value approximately equal to the number of threads I connect. Then Open/Close the connection for e... |
Based on several different sources, I have compiled the following as my basic HTML email template. Please let me know if I have missed anything important. I am not sure if I am using \n and \r\n correctly.
$semi_rand = uniqid();
$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";
$mime_boundary_header = chr(34) . $mi... |
Unlike Perl, you can't to my knowledge match a regular expression inside an if statement in Python and assign the result to a variable at the same moment. This leads to typical constructs like this:
match = re.search(REGEX, STRING)
if match:
# do something
So far, so Python. But what if I want to iterate through a... |
Here is a practice question I am solving:
Write a function to find the first non-repeated character in a string.
For instance, the first non-repeated character in 'total' is 'o' and
the first non-repeated character in 'teeter' is 'r'.
How can I improve the efficiency of this algorithm?
function repeater(string){
... |
I have done some research about intentions of UnitOfWork pattern. In short, what I understood is that UoW is needed for transactions. But I saw some code examples where people use UoW as factory for Repository objects as well, one example is DbContext from EF. My first thought about it doesn't it break single responsib... |
I'm very new to learning PHP & MySQL (I've got past experience with Java) and I'm doubting whether my code is organised well. I've got an index page which has two forms; the first is a form to login and the second is a form to sign up a user. So far I've only completed the signing up of a user. Please comment on my cod... |
The code is an implementation of the Gauss–Seidel method. I would like a general review of the code.
PS: I use code::blocks IDE
//generalized code for gauss seidal iteration method
#include<stdio.h>
#include<malloc.h>
#define chk_end 0.01
int row_lim=0,col_lim=0;
float** partial_pivot(float** mat,int row,int col);/... |
I need help with a simple Google Apps Script I've written. The script finds days on which no all-day events have been scheduled, across multiple calendars.
I'm fairly certain the main issue is the fact that I'm making an API call to get all owned calendars, then I'm making 5 API calls on each of these calendars to retr... |
Ok I am making unit converter and I have attached temperature conversion code below. The problem with this code I think is that I have written function for each and every single unit to convert to another unit.
So in code below there is one function to covert Celsius into Fahrenheit, Kelvin, Renkien and Newton. Then an... |
I have a macro that makes comparisons and then this macro exports all of the changes based on if the information doesn't match. I have it so that each column gets their own worksheet in the new workbook. I am using 7 different counting integers and it takes a very long time because I am exporting over 60k rows.
Questio... |
After looking through PHP.net documentation for hours, is this the best way to offset an array from start to finish by using array_slice() with array_merge()?
For example: $array = array(1,2,3,4) to offset by 2 to get return $array = array(3,4,1,2).
Here's the code I'm using it in:
$team = 2;
$course = array(
... |
As a part of my Tabv Vim plugin (which at this stage is nothing more than a pitiful rag-tag assortment of half-baked hacks), I have a function which attempts to guess the directory paths for main source and unit tests. The first working version of this function is (full source):
let g:tabv_grunt_file_path='Gruntfile.js... |
I posted this question here.
And an answer stated that I should not do:
$table_name = 'survey_'.$_POST['surveyid'];
because
It is easy for a hacker to exploit your site if you include $_GET or $_POST data directly in any SQL string.
Here is the code. Do you see any security exploits?
if(ctype_digit($_POST['surveyid... |
I was just reading about ring buffer the other day and I was fascinated by how simple yet efficient it is.
I've implemented a ring (circular) buffer in Ruby and I'm just wondering if there's anything I can improve, and also how to properly measure its performance.
Ring buffer:
class RingBuffer
attr_accessor :ring, :... |
I have a notification system that looks like this:
function notificationMethod(message){
// do stuff
// once everything else is setup, attach a click handler to the "Okay" button
$('#notificationOkay').click(function () {
unBlockScreen();
$(this).off("click"); // once they click the "Okay" ... |
I was working on a subtype of list in python that acts as a list that should never raise an IndexError (every key you input that's greater than the length of the list gets wrapped around). I was having quite a few problems however implementing it properly for slices, who have a LOT of base cases. I wrote the following ... |
I'm running code which works fast locally, but when it's on Heroku it's slow. Heroku says this is because there is less memory and CPU power on my hosting than locally. I'm trying to rewrite my code so it's more efficient, but I'm not sure how.
This is what they said:
...[my] method (especially, a.each part) is taking... |
See the proposed changes in this Pull Request under def add_talk.
date = self.talkDetailsWidget.dateEdit.date()
time = self.talkDetailsWidget.timeEdit.time()
presentation = Presentation(
unicode(self.talkDetailsWidget.titleLineEdit.text()).strip(),
unicode(self.talkDetailsWidget.presenterLineEdit.text()).strip(... |
This is a wonky PHP function I came up with to merge some select values from child arrays into the original. It could really use some help simplifying / making it more elegant.
Is there a built-in method I'm overlooking? array_push didn't work for me because the data needed to be flat.
The problem
What I've got:
arra... |
This is one way to make a boolean in C.
typedef enum {
false = 1 == 0,
true = 0 == 0
} bool;
Recently I made some like
typedef enum {
true = ~(int)0, //true is the opposite of false
false = (int)0 //the smallest enum is equal to sizeof int
} bool;
int main(void) {
return false;
}
Can this be im... |
private string ExtractExceptionMesssage(string exceptionMessage)
{
const string startWord = "Message>";
int startWordLength = startWord.Length;
const string endWord = "/Message>";
var length = exceptionMessage.Length;
int index = 0;
var sb = new StringBuilder();
while (index < length)
... |
Problem Statement:
A palindromic number reads the same both ways. The largest palindrome
made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit
numbers.
This code is in C++ 11, please review my code.
#include <iostream>
#include <math.h>
u... |
This is a byte stream implementation in C. Its usage and purpose should be evident from main.
Implementation is not finished; this is just start. Comments are still welcome.
.h:
#include <stdint.h>
typedef struct
{
uint8_t * data;
uint32_t length;
uint32_t offset;
} ByteStream;
int32_t BSInitWithSize(By... |
While the MVC4 template provided by Microsoft is useful, I feel there are a few scenarios that should be covered to help out users trying to log in.
Allow the user to log in with their email address instead of their user name (they can still choose to use their user name). The former is generally easier to remember.
... |
Some context: I have code that looks like this (minor issue noted here):
Statement select("SELECT * FROM People WHERE ID > ? AND ID < ?");
select.execute(1462, 1477, [](int ID, std::string const& person, double item1, float item2){
std::cout << "Got Row:"
<< ID << ", "
<< perso... |
Let's assume I have an enum type
enum ComponentState {
TURNED_OFF,
TURNED_ON,
SUSPENDED,
TO_REPAIR;
}
This enum describes a state of some component. Now let's assume I want to export my component to as XML file. Then, of course, I'm going to import my component. So:
//Export:
componentElement.setAttrib... |
I have an algorithm for checking whether one line is contained within another. The lines I have are made up of an ordered array of points, which are just data structures with values for x, y and z. The lines are no necessarily straight. The subline does not need to be going in the same direction as the main line.
The a... |
I am stuck to define a generic repository with AutoFac IOC container. I am keeping thing very simple and only showing relevant information.
BaseEntity
public abstract class BaseEntity
{
public int Id { get; set; }
}
IRepository
public interface IRepository<TEntity> where TEntity : BaseEntity
{
List<TEntity> G... |
I have an axis-aligned bounding box (AABB) that I've coded, but at the moment it is very redundant. I feel like there are variables that I can get rid of. I need the AABB to be very fast, and I'd like it to be more lightweight than it is.
#pragma once
#include "Engine.h"
// Collision
#include "Vec2D.h"
// End Collisi... |
Fast Time conversion
I'm trying to write a very fast time-to-string and string-to-time function.
I noticed that on low CPU mobile devices this function has, even if minimal, impact on the performance of the overall canvas animation.
Milliseconds to Time string (HH:MM:SS.mss)
In this function: is there a shorter & faste... |
I'm currently facing a problem where I have to shift data in a multidimensional JS array in different directions, but I think the first solution I whipped up is not as efficient as it could be (some fancy math I don't know of maybe?).
Let me explain the problem a bit better with some examples of my data.
This is the ar... |
I've written a small webapp in JavaScript, and am now essentially rewriting it to use RequireJS. I'm doing this partly to get more familiar with RequireJS (which I have little experience with), as well as for ease of maintaining and upgrading the app.
I'm hoping to get feedback on whether the structure I'm looking at ... |
I got the following ugly code:
template < class _Coeff,
unsigned _nVars,
typename _Expo=int,
template <class, class> class _Map = _Map >
class Polynomial
: boost::ring_operators< Polynomial<_Coeff,_nVars,_Expo,_Map>
, boost::addable < Polynomial<_Coeff,_nVars,_Expo,_Map>, _Coeff
... |
Below is some code I have written today to test out some bits I have learnt. It isn't much nor is it spectacular. Please critique and let me know what I could/should have done differently or anything I could do to improve it so far.
package easy8;
import java.util.Scanner;
public class song99bottles {
public static ... |
I am a beginner in C++ and learning from textbook. I find it hard to jump into oops concepts as I have used C a lot. Here is an interview question I came across:
Problem Statement
Our marketing department has just negotiated a deal with several local merchants that will allow us to offer exclusive discounts on variou... |
I found out that in Visual Studio 2012, it is possible to create project of SFML easily with a template. I am not an experienced C# programmer. Hence I wanted to implement a physics component just for practice purposes.
PhysicsManager Class contains all the physical objects:
public sealed class PhysicsManager
{
// ... |
I have a bit of Python source code that I want to recreate in C#. The code is about reading and decrypting a binary file. I have tested the function on an existing file and it runs without errors; while the resulting string is not garbled or anything, it does not appear to be useful to me.
But that is outside the scope... |
I have a method I created which is a custom indexOf(). This code seems ugly to me so I was wondering if anyone could recommend a cleaner and perhaps faster implementation of my method.
public static int myIndexOf(char[] str, char[] substr, int index) {
if (str == null) {
throw new NullPointerException();
... |
For non-plugin code, I generally use the module pattern, but I'm working on a jQuery plugin and decided to try out the "lightweight start" pattern. The problem is, I find myself needing $.proxy when calling private methods to ensure the this context.
Is there a better way to structure the code in order to avoid $.prox... |
Lets say there are 10 boys and 10 girls in speed date.
10 boys select 4 girls and rank them.
10 girls select 4 boys and rank them.
In the end the winning pairs would be returned.
Finer details such as tie-breakers, rules of input params etc, are well documented.
Looking for code review, optimization and best ... |
I have the following code which I feel that I must refactor, but not sure how to do it.
List<AlgoTuningData> feedbackScoreDatas;
List<AlgoTuningData> topRatedDatas;
int score1 = 0;
int score2 = 0;
boolean matched1 = false;
boolean matched2 = false;
for (AlgoTuningData topRatedData : topRatedDatas) {
if (!matched1 &... |
I have written code in C++ 11 and check output with Project Euler site, and it is correct. I am not showing output, just to keep it secret, at least from my end.
Please review my C++ 11 code.
#include <fstream>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
using namesp... |
I'm just started learning TDD with Rails and RSpec. This is my first test for controller. Just plain RESTful UserController that responds with JSON, so it has no new and edit methods. Please review it
require 'spec_helper'
describe UsersController do
let(:users) { 4.times.map { create(:user) } }
describe '#index'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.