instruction stringlengths 71 71.9k |
|---|
First of all, I am not using JQuery but Cheerio. I have never actually used JQuery in "real life" -- I started with Cheerio, which is a subset and doesn't actually work in a browser environment.
(Note: I don't have enough reputation here to create tags, somebody might want to tag this question as "cheerio" and delete t... |
I'm generating domains with random names. I used the map function because it packages the results into a list which I can then join() into a string but the way I used the lambda function could be confusing to people reading this later.
def generateHost():
charSet = 'abcdefghijklmnopqrstuvwxyz1234567890'
minLength =... |
I've created a MovingAverage class, but it is not optimized for performance at all. I care about performance a little bit because I'm using this class in trading (I collocate on exchange and so on and so on; let's talk about performance of this particular class).
How would you improve it for better performance?
interfa... |
I'm learning go. I wrote a simple logparser for SLF4J in Python some time ago and tried to port it to go as an exercise. The algorithm is identical, but the go-solution isn't quite as fast (the Python solution is about 1.5 times faster for large enough logfiles). Is there any way to get more speed out of it? It do not ... |
Left view of a Binary Tree is set of nodes visible when tree is visited from left side. Left view of following tree is 12, 10, 25.
12
/ \
10 30
/ \
25 40
Looking for code review, optimizations and best practices. Also verifying space complexity is O(n) and not O(logn) wher... |
This post is a follow up question.
The purpose of this class should became clear without any further explanation. Raise your hand. If not, then I will have to improve the naming/structure.
I would like to know how to improve this code in terms of readability and complexity.
Data structure:
<?xml version="1.0" encoding... |
I'm working on a Pong game and right now I'm working on being able to register multiple KeyDown presses simulatenously. I used the Win32 native method GetKeyBoardState first to loop through all of the virtual keys and see if any of the keys matched the game input keys. Now this worked just fine but in the interest of o... |
Simple idea: just have a plugin (more a basic function). That I can use with jQuery in different ways it offers, means:
var myNewVar = $.myNewFunction( myVar );
var myNewVar = $().myNewFunction( myVar );
I want to know if what I did is the good way to doesn't repeat the code, or if their is a better way to.
Here my pl... |
For my Advanced Data Mining class (undergrad) we were to design a program that would predict the next word a user is likely to type via automatic text classification using the n-gram model.
The following is what I came up with. The reason I am posting this is because I am about to graduate and I want to be aware of any... |
I have a task to print all zero subsets of 5 numbers, input from the console.
I have succeeded in implementing a working code, but it seems it is quite complex (it is like inception) and if the count of the numbers is to be greater, it would be rather pointless to use such a method.
using System;
using System.Collectio... |
Next is an algorithm to calculate the histogram for a given YUV420sp image. The YUV data is given by the hardware camera as an unsigned char*.
The algorithms works correctly, but I'm looking to optimize it for speed.
void calculateHistogram(const unsigned char* yuv420sp, const int yuvWidth, const int yuvHeight,
... |
I've been developing sites using Dreamweaver for the last 15 years, I do a lot of code editing manually so I have quite a good knowledge of the PHP language.
I'm diving into object orientated programming and getting to grips with classes objects and the like.
I hope to eventually port the game to a framework such as sy... |
I'm working on a bookmarklet that will be cached for 24 hours only, after that time it will be reloaded from the original source.
Is there something I could improve?
javascript:(function () {var currentTime=new Date();var month=currentTime.getMonth()+1;var day=currentTime.getDate();var year=currentTime.getFullYear();do... |
I have these relevant tables in an MVC website:
Server
ServerPlayer
ServerPlayerChat
Servers have serverPlayers and ServerPlayers have ServerPlayerChats. Simple enough and expectable.
I have a feeling my code could be drastically condensed (particularly the GetServerPlayer method) and that the GetServerPlayer method ... |
I’ve got a matrix of data and I want to take the average of the positive and negative parts of the values.
Is there a more Pythonic way of doing it?
from numpy import *
…
exposures = matrix([0]*numPaths*numExposures)
exposures.shape = numPaths, numExposures
… # fill matrix
@vectorize
def plusv(x): return max(x,0)
... |
Is this repository code written according to best practices? The Last Section I included it in the repository as well.
class HR_Repository<T> : IRepository<T> where T : class
{
private readonly LoginDataContext dataContext;
public HR_Repository(LoginDataContext dataContext)
{
this.dataContext = dataCon... |
I'm working on Ocaml.org 99 problems, and I solved the run-length decode one.
Here is the solution given by the site:
let decode l =
let rec many acc n x =
if n = 0 then acc else many (x :: acc) (n-1) x in
let rec aux acc = function
| [] -> acc
| One x :: t -> aux (x :: acc... |
I recently had to work in a tricky piece of work for a project I am working on. You can find its code on GitHub and I'd like to have a feedback about some specific parts of it.
The project is a library and if you look at the README you will see how it needs to be integrated with an android application. I report it here... |
I implemented my own sorting in VBA because it doesn't provide its own, and it's healthy to test yourself. It was surprisingly difficult and I ended up make a few tweaks that I didn't expect to make in order for it to sort.
Public Sub quicksort(ByRef arr As Variant, _
ByVal left As Integer, _
... |
I've implemented a Segment Tree in Python3:
import math
INF = int(2e9)
class SegmentTreeNode:
def __init__(self, l, r, v=INF):
self.left = l
self.right = r
self.value = v
def merge(self, left, right):
if left is not None and right is not None:
self.value = min(lef... |
Have I made any obvious mistakes?
Is this code clean?
Is there a better way to do this in python?
# -*- coding: utf-8 -*-
import feedparser
from feedgen.feed import FeedGenerator
from random import shuffle
from feedformatter import Feed
import time
from datetime import datetime
tstart = datetime.now()
# Set the feed/c... |
I've been trying to optimize this piece of code:
void detect_optimized(int width, int height, int threshold)
{
int x, y, z;
int tmp;
for (y = 1; y < width-1; y++)
for (x = 1; x < height-1; x++)
for (z = 0; z < 3; z++)
{
tmp = mask_product(mask,a,x,y,z);
if (tmp>255)
tmp = 255;
... |
Warning: the code below is NOT multi read/write!
It'l work fine as long as you don't have multiple writes OR don't require resize.
But with multiple writers, the code can enter a deadlock state.
I'm revising the code and if I do manage to work around these issues, I'll post them in a linked question.
After, analysing ... |
I have this regexp working, simple, but I feel like it may not be the best way to code it. Basically, I have a playlist separated by line breaks returned as tcp data like so:
file: http://192.168.100.214/Music/justchill.mp3
Artist: Brian G
Title: Just Chill
Track: 1
Date: 2014
Genre: Instrumental
Pos: 0
Id: 0
file: htt... |
Here is my two-player Tic Tac Toe game. How can I improve it?
#include <iostream>
#include <vector>
//Simple Display
void Display(std::vector<char> const &grid){
//Creating a onscreen grid
std::cout << " " << 1 << " " << 2 << " " << 3 << "\n";
for(int a = 0; a < 9; a++){
if(a == 0)
... |
This is the function which I wrote and am currently using in my project. I want to know if there is a better way to write it:
function pageLoader(pageIndex){
$(".ServicesSectionWrapper,.ServicesSectionWrapper .Selector,.ServicesSection,.JournalSectionWrapper,.JournalSectionWrapper .Selector,.JournalSectio... |
I just finished writing a basic binary conversion class in Ruby. I'm curious to see if anyone has suggestions for improvements. In particular, I'm looking for the cleanest, shortest, most succinct code possible, while staying away from hacky shortcut stuff.
In creating this I wanted to use a minimum of functions that c... |
I want to make sure that the code is correct in terms of its design, code correctness, best practices & Junit testing.
The complete description is given below:
Functioning of the app quickly estimates the Final Cost depending on different markups. The following are the markups:
Flat Markup of 5% on all jobs
Markup o... |
I have a project (ldaplib) I am working on that needs to do ASN1-BER decoding and encoding. The function I have for the decoding portion is slightly more complex but neither are all that complicated. I would like to get some feedback on the overall approach as well as the code/exceptions/inline comments.
The decodi... |
I have this implementation of the split algorithm that different from .split() method you can use with multiple delimiters. Is this a good way of implementing it (more performance)?
def split(str, delim=" "):
index = 0
string = ""
array = []
while index < len(str):
if str[index] not in delim:
... |
TL;DR: The Bash script converts a published, somewhat-structured text file into a format usable by my testing infrastructure. It's slow, I think it's ugly -- although it is fully functional.
The NIST provides test vectors for verifying the correct operation of a Galois Counter Mode (GCM) when used with the AES block c... |
I've wanted to make a Pong game for awhile, so I eventually got around to it now, it didn't take that long except for the reflections which I unfortunately didn't end up being satisfied with. I wanted to implement a more elegant solution utilizing trigonometry to calculate ball curvature upon impact, but alas it was my... |
Is it possible to shorten this piece of PHP code?
Honestly, I think it does not look clean but like a mess.
if(Input::exists() && $token) {
if($validation->error('firstname') && $validation->error('lastname')) {
echo str_repeat(' ', 20), '<div class="addition error">↳ You did not enter your name.</div>', "\... |
I've tried this problem on Codeforces. Given a set of string patterns, all of which are the same length, and which consist of literal lowercase ASCII characters and ? wildcards, find a pattern that satisfies them all.
I want to optimize and simplify it further and make it a more elegant solution, if possible.
import s... |
My goal is to parse defines in Objective-C code:
#define wowFont [UIFont fontWithName:(DEV)?@"one":@"two" size:(DEV? 10: 12)]
#define wowColor [UIColor colorWithRed:(DEV?240/255.0f:255.0f) green:((DEV)? 230.0f / 255.0f) blue: 10.0f]
I try to write grammar for it:
grammar Defines::Grammar {
token TOP {
\s*<... |
I have some old RAR files and I know the general format of passwords I used to use, so I have generated a dictionary file combining those words in a variety of ways. The dictionary file is 500mb and I've wrote a python program to use the dictionary.
The issue is that the program has been running all night and is only ... |
I implemented Aho-Corasick string matching in Haskell. It is a purely functional implementation compared to many other implementations.
The input to build an automata is [([a],b)]. which is a list of (pattern,output) pairs.
b has to form a monoid, so we know what to do when more than one match occurs at the same place... |
I'm a beginner developer, I'm learning online (mostly from the Apple documentation guides), and couple a days ago I started a notes app project. It's the first app I'm building without a guide.
It's very simple so I'd love to post it here and get your feedback on how to improve my code to be more efficient.
The app hav... |
I implemented a throttled database service trait for wrapping my service code in a future, supplying a slick session and throttling the # of requests in accordance to the length of the thread pool queue.
My main reason for this was to transfer the responsibility for database session / transaction handling away from the... |
It seems like there are many ways implementing inheritance in JavaScript. Which version do you prefer or would you suggest another solution?
The code should run in IE8+ so my first version would not fit…
function Animal(name) {
this.name = name
}
Animal.prototype = {
eat: function() {
console.log(this.n... |
I'm trying to get a better handle of code organization and how HTML5 (really HTML) stack works in general. I've worked mostly with ASP.NET Webforms and done some MVC as well. Let me say now, "I hate magic". I hate figuring out the magic. I just want it to work in the manner that it's supposed to. So I posted this littl... |
I learned to program in Java and C# and in my free time I am using Ruby because it is fun. Unfortunately I have the feeling that I write Ruby code like I am making Java or C# code. I have learned to use regex instead of strings for comparison, using each instead of for-loops, keeping method names lowercase, and how to ... |
Here's a link to the problem. Is there any way I could optimize/speed up this code, perhaps make it more Pythonic?
"""How many distinct terms are in the sequence
generated by a^b for 2 <= a <= 100
and 2 <= b <= 100?"""
import math
from timeit import default_timer as timer
def distinctPowers(a_max, b_max):
product... |
I am using Spring Framework, Hibernate and JUnit. I am testing persisting of a UserEntity.
The UserEntity has the following associations:
ManyToMany - City
ManyToMany - ActivityCategory
ManyToOne - UserType
@Test
public void testCreateNotExistingEmail() {
UserTypeEntity userTypeEntity = userTypeDao.find(1L);... |
Write a function undef that will remove a name and a definition from the maintained by lookup and install.
Here is my solution:
void undef(char *name)
{
struct Nlist *tmp = hashtab[hash(name)];
if(!strcmp(tmp->name, name)) { // delete the head node
hashtab[hash(name)] = tmp->next;
free(tmp->... |
I am working on this project that has a reservation form which allow users specify which sort of service they require. I have a select menu with eight (8) options and I have two divs which would either show/hide depending on the value of the option been selected. Seen below is the select element:
<select name="serviceC... |
I've this function to list products from database by category. I'm using prepared statements, but wouldn't this make it pretty pointless to use them?
function getProducts($category,$search_param,$pdo){
$query = "SELECT * FROM renkaat
INNER JOIN ajoneuvotyypit ON tyyppiID = ajoneuvotyyppiID
INNER... |
I'm building a port scanner as an exercise. It contains a method to separate the ports that the user wants to have checked, which can include single ports and port ranges, ex: 22, 23, 80-120, 443-500, 1024, etc. It discards wrong ports such as negative ports, wrong range such as 120-80 instead of 80-120 which is the ri... |
This function tells that elements of content either (maybe) match regexes that you like or match regexes that you don't like.
This messy code requires Data.Text.Lazy but internally shuffles around internal and strict versions. Also list Monad code looks fishy to me.
How can it be made simpler, faster, more general (esp... |
I found myself writing code to run at a specified frequency more than once, so I decided to make this simple timer. My main concern is that this is not the most efficient way of doing this since with SDL I would just ask for the time in ms and sleep in ms.
I'm storing the current time in timer_update() to avoid the pos... |
Android documentation says:
Often you will want one Fragment to communicate with another, for example to change the content based on a user event. All Fragment-to-Fragment communication is done through the associated Activity. Two Fragments should never communicate directly.
My question is: Why should Fragments neve... |
I have this code:
public class RecurLoopTest {
public static void main(String[] args) {
printit(2);
}
private static int printit(int n){
if(n>0){
printit(--n);
}
System.out.print(n+",");
return n;
}
}
I have drawn a execution flow/memory flow diagr... |
This is how it handles input:
if negative, terminate program
if 0-2, display input without calculating
if greater than or equal to 3, calculate and display result
I have also used some macros from an included file:
nwln: outputs a newline
PutStr: displays a label
GetLInt: receives a 32-bit integer
PutLInt: displays ... |
I have a text file and I was curious about what character appears how often in the text.
Any review is appreciated.
public class CountLetters {
public static void main(String[] args) throws Exception {
TreeMap<Character, Integer> hashMap = new TreeMap<Character, Integer>();
File file = new File("C:/... |
Is this an efficient way to handle page requests in MVC?
index.php:
require 'Classes/Autoloader.php';
Autoloader::start();
Session::start();
new Bootstrap();
Bootstrap.php
class Bootstrap {
private $controller = null,
$action = null,
$args = null;
public function __construct() {
... |
I have this common design in my application:
public class MyListener1{
MyTask1 task1;
MyTask2 task2;
public class MyListener1{
public MyListener1(){
task1 = new MyTask1(this);
task2 = new MyTask2(this);
task1.execute();
task2.execute();
}
public void onResult1(String result)... |
Here's my solution for Project Euler Problem 30. Any optimizations in time, space, or style would be greatly appreciated.
from timeit import default_timer as timer
def digit_powers(exponent):
def power(k):
return int(k) ** exponent
if exponent <= 1:
return "The exponent must be at least 2."
... |
I'm making a game battle system, where there are 2 players.
Every player can have multiple units to control, but only one at a time.
Every unit has an int curSpeed variable;
I need to have in 2 variables who attacks first (Player f) and who attacks second (Player s), based on the speed of the current controlling unit... |
I am fairly new to Python and programming in general so I hope the code in this post is not too messy. I have the following code which I use for taking images from an IP security camera:
def Camera(timecount, cam_name, stream_url, username, password, work_dir, x):
x = x
work_dir = work_dir
h = httplib.HTTP(... |
Does my code look secure right now? I know that I still have the password hashing and so forth, but what about SQL injections? Do I have any? Are there any other security issues?
<?php
$con=mysqli_connect("localhost","root","xxx","s");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MyS... |
I have a function called mult2 that takes in two square NumPy matrices and returns a matrix that is the result of a special multiplication:
p=P(1,344)
PI,PIT=[],[]
for i in xrange(344):
PI.append(p**i)
PIT.append((p**i).transpose())
def mult2(a,b):
C=np.sum((a*b)**2,axis=1)
CE1=np.matrix([[0.0] for _ i... |
This is the updated code using all suggestions from the previous question that I made here.
I have revised the naming of the variables, and i have included the classes that this part of code is using, in order to have a better understanding.
I'm making a game battle system, where there are 2 players.
It is like a roun... |
Please be über brutal, and treat this as a technical interview question.
I was wondering how this function that I wrote looks like. It groups together words that have the same alphabets (i.e anagrams).
Time Complexity: \$O(n^2)\$
Space Complexity: \$O(n)\$
private static List<List<String>> groupAnagrams(ArrayList<Str... |
This is a Python solution for all general cases. Any suggestions at all would be appreciated; in my opinion it's already quite good! Here's a link to the problem.
from timeit import default_timer as timer
def count_coins(target, operands):
ways_to_make = [1] # list of ways to make x at index x
for o in range(0... |
I'm writing a program to differentiate functions (perform basic calculus) in Haskell. The program works, but there's one function that looks very ugly to me:
--some prerequisite definitions
--a mathematical value is either...
data Value =
Literal Double --a number, such as 4, -17.5, or 2.33e27... |
I made this math script, where you enter an equation and it solves it for you. I was wondering what you thought of the code, and what I could have done better or what doesn't follow Ruby best practices. The code is also on Github here if you want to see the readme and how to use define_equation()
#!/usr/bin/env ruby
r... |
Please be brutal and treat this as me coding this up for an interview.
A sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than tw... |
The following is an implementation of a tree in C++ designed for keys which do not have an order (otherwise a std::map could be used). T is a key type and H is a hash for T.
#include <iostream>
#include <memory>
#include <utility>
#include <unordered_map>
template<typename T, typename H>
class tree;
template<typenam... |
I'm making a simple Tetris clone and would like to know how's my code for the map and pieces. I'm using x, y, x_before, y_before, t0, t1 to allow smooth movement.
colors.h
#ifndef TETRIS_COLORS_H
#define TETRIS_COLORS_H
typedef enum {
DARK_CYAN, DARK_RED, DARK_BROWN, DARK_MAGENTA,
DARK_GRAY, DARK_GREEN, DARK_... |
public void fizzbuzz(int count, int max, String fizzer) {
fizzer += (count % 3 == 0) ? "fizz":"";
fizzer += (count % 5 == 0) ? "buzz":"";
fizzer += (count % 3 != 0 && count % 5 != 0) ? count:"";
if (count != max) {
fizzer += "\n";
fizzbuzz(count+1,max,fizzer);
} else {
System... |
There are n balls kept on a table and connected by same singe connected string (which can be cyclic or maynot). Write the code to select a ball such that after lifting the whole structure from that ball height will be minimum. (algo+code+ mathematical proof of correctness)
Note, I do understand merits of unit testing i... |
I'm reading this tutorial and it's the first time I try something this new.
Here is my attempt:
import sys
import math
import pygame
import random
pygame.init()
windowwidth, windowheight = 900, 500
windowsurface = pygame.display.set_mode((windowwidth, windowheight), 0, 32)
clock = pygame.time.Clock()
fps = 30
MAX_INT ... |
I am a beginner and I have made Login Form in HTML. I'm pretty sure it will look horrible to any developer, but hey, that's why I've posted it.
I'd like a general review of this. I'm especially concerned about the quality and enhancements of this form.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt... |
I have implemented Insertion sort in Java. Please review it.
public class InsertionSort {
public static void main(String[] args) {
int[] values = new int[args.length];
for (int i = 0; i < args.length; i++) {
values[i] = Integer.parseInt(args[i]);
}
for (int i = 0; i < valu... |
This is my code for reading a file with a delimiter. Any suggestions to help improve my code efficiency?
I am not satisfied with using array data structure. Can any other data structure be used instead of an array?
bool read_file(char *p_file_name,char *file_content[FILE_NO_OF_ROWS][FILE_NO_OF_COL],const char *delimi... |
I would like to submit a portion of my code for Code Review, and I have done my best to comment the code (and include essential parts that may aid understanding of the program) for your convenience! Any optimisation that would increase the speed of the running of the program would be appreciated!
The program is designe... |
Could you please review my script?
#!/bin/ksh
T=/bb/bdap/bin/cms/tools
U=$T/upgrader
mv $T/conbase_updates $U/conbase_updates.br.drqs$1
cd $U
grep "^BR" config.alpha > config.br
./ConbaseUpgrader config.br conbase_updates.br.drqs$1
|
I am wondering if my current unit tests could be written better, I am most interested in whether it is possible to make the code look more concise, as currently it a boiler-plated mess.
I have full access to Java 8, if that would help by making it more concise.
The Arguments class itself:
public final class Arguments {... |
I often find myself doing this (or similar) with Lists and other collection types:
if (someList != null && someList.Count > 0)
//take some action on the list
so I got lazy and wrote the following extension methods to do it for me:
public static bool IsNullOrEmpty(this IEnumerable self)
{
//Conve... |
Suppose I have a nested class structure like this:
namespace My.Namespace {
public class Foo {
public class Bar {
public class Baz {
public string Test { get; set; }
}
}
}
}
I need to get the nested type name of Baz without the namespace, i.e. Foo+Bar+Ba... |
How do I optimize this code further? Goal is to edit "js-tab" in one place. This is what I tried to follow.
Full code here.
var ToggleTab = {
init: function() {
this.tab = $(".js-tab");
this.bindEvents();
},
bindEvents: function() {
this.tab.on("click", this.toggleTab);
//this.tab.on("click", $.prox... |
I finally managed to get the code to work properly. It makes the player object move faster if the user double taps the arrow key with a few 'ticks' (new frames) after the 1st stroke. - User presses and has a limited time to press again to sprint the object. If the time runs out the user has to try again.
However, It'd ... |
I'm trying to code following requirements with lockfree in most-used-code-path that is to get a resource from pool.
Same resource should be used n (maxUsageCount) number of times and then
destroyed and create a new one.
If there is an error with a resource, it should be marked stale by
client. Staled resource should b... |
I have a website where people can write articles and publish/unpublish them. This is done via single button on the page:
<a id="publish-button" href="#" class="btn btn-default <%= 'btn-success' if @article.published? %>">
<span class="glyphicon glyphicon-globe"></span>
</a>
As you can see, if an article is already... |
I've got some architecture in my code similar to this. It is about the Construct method in the base class in the example below. This method contains the logic for constructing a building, which is the same in every building. Yet different buildings may want to do things differently, like a different roof. So I've used ... |
I've translated this code from c# and would like it to be more idiomatic f#:
namespace Foo.App_Start
open System
open System.Web
open Microsoft.Web.Infrastructure.DynamicModuleHelper
open Ninject
open Ninject.Web.Common
type NinjectResolver(kernel:IKernel) =
let _kernel = kernel
interface System.Web.Http.De... |
This is my first ever real 100% self made perl script, I'd like to know how I can improve it.
#!/usr/bin/env perl
#this script takes a directory and sorts the files into folders by file ending
use strict;
use warnings;
use File::Copy;
sub sort_files {
my $dir = shift || '.'; #cwd if no directory given
$di... |
I was asked to provide the solution of this rolling dice problem in an interview. When I showed him my solution, he said that there is another way to find the solution. I am looking for answer in PHP script only.
Question:
Two persons are playing a game of rolling 2 dices. Each person rolls the two dices n times and r... |
I've written a program to simulate a game of Mafia among several bots. Here's the directory structure the program lives in (to make understanding parts of the program easier):
/
start
README.md # Readme file
wtfpl.txt # License
controller/
main.py
messages.py # Contains a list of strings. I only p... |
I posted my audio recording program to Code Review before, and received a stern review along with the other reviews that caused me to rewrite the entire code base. Here is what I would like reviewed:
Reusability/Portability - is this code easy to use for multiple separate projects with minimal modification?
Optimizati... |
My requirement is to convert a sequence of numbers into a display string as below.
Example
Input
1,2,3,4,5,7,7,8,8,8,10,15,10,11,12,88,87,86
Output
1-5,7-8,10-12,15,86-88
void makeDisplayString(std::vector<int>& vector, std::wstring& string)
{
if(vector.empty()) return; // If empty do nothing
std::sort(vec... |
I've been looking for an implementation of Tarjan's algorithm in C#/C++ for a strongly-connected components in graphs, and couldn't find any implementation without use of additional Stack - most of them just follow wikipedia pseudocode. I've decided to create one in case if someone is looking for it. Please take a look... |
I have a site where user accounts can be created in two ways: by new users (sign up) and by admin users. Since the creation is handled differently in each case, I decided to split the logic into two separate functions. I have a working implementation but I'm pretty new to Rails so I don't know if it is robust and secur... |
I've been learning Java lately and had some great feedback from the previous threads (hangman and guess a number games).
I was challenged by a user to try to get this code done, so I'm posting it here for further review.
Basically my weakeast (among many) points are exception handling and proper documentation.
What do ... |
I'm trying to make a backend for QuizUp like application: user connects to a server, sends credentials and gets paired up with another user. After that server handles each pair, periodicaly sending server messages to each user in a pair and also redirecting user's mesages between them.
Server class:
private static clas... |
In case the table has class 'trans' - run dataTable() and columnFilter(); otherwise just run dataTable().
Is it possible to not repeat the dataTable() part?
$('#dt_a').each(function() {
if ($(this).hasClass('trans')) {
$(this).dataTable({
"sDom": "<'row'<'span6'<'dt_actions'>l><'spa... |
A month ago I finished and posted my first version of my Tic-Tac-Toe, I received a lot of good feedback and refactored it to more closely suit the MVP design pattern.
I've done some further clean-ups and refactoring in the code now but most importantly I have implemented a very primitive AI, that works "fairly well", ... |
I have seperated my project into two projects. One is the web forms project and the other is the Model project with contains a generic repository implementation, a service class for each of my entities and a UnitOfWork class. All the code below apart from the last section is in my Model class library project.
Generic r... |
I am trying to build an efficient function for splitting a list of any size by any given number of indices. This method works and it took me a few hours to get it right (I hate how easy it is to get things wrong when using indexes).
Am I over-thinking this? Can you help me minimize the code? I am just not seeing it. AL... |
I am a fairly new (RubyonRails) developer. I desire to improve my coding skills so I used climate to do some review on my code. It gave me a flag for this method that its complex. Is it characterised as complex because of having several "actions/tasks" in a single method?
Will it be better if I extract some code segmen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.