instruction stringlengths 71 71.9k |
|---|
I've got the following PHP code, which is taking a search term, and checking if any of the search terms could be or could have a nickname.
$search = $_GET['search-term'];
$indiviudal_terms = explode(" ",$search);
foreach($indiviudal_terms as $term) {
foreach ($nicknames as $nameset) {//$nicknames is a multidimensio... |
I'd like to share my implementation to you to confirm if it's a correct way to solve my problem. I have a list of products which have an attributes table and a description table (both in html_encoded strings). Every product starts at a new print-page using page break. When the attributes and description tables don't fi... |
Challenge: 2520 is the smallest number divisible by 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by 1-20?
Solution:
public class Euler5 {
public static void main(String[] args) {
long startTime = System.nanoTime();
int result = 0;
for (int i =... |
I wanted to test the performance of concurrent http request in Go against node.js:
package main
import (
"fmt"
"time"
"strconv"
"net/http"
)
var responseCounter = 0
var requestCounter = 0
var count=0
var ch = make(chan int)
func sendRequest(){
go func() {
requestCounter++
url := "https://... |
I've written a solution for http://tour.golang.org/concurrency/8, which asks for a Walk() function to traverse a randomly generated binary tree, and a Same() function to check if two trees have the same values.
Is this solution is the most efficient? (I think that the Same function is not the most efficient solution, b... |
I tried to swap 2 integer numbers without using an additional variable as a traditional swap.
Is it legal in C++? My VC compiler doesn't complain nor gives any warning about it. If so, how can I improve this script?
#include <iostream>
int main()
{
int a = 20;
int b = 66;
// before swapping
std::cout ... |
I'm interested in whether there is a way to further improve a "fast" version of a function used in a homework assignment I received recently (I've already submitted the completed work).
from math import log
def func_fast(mass, density):
return sum(map((log(mass * density)).__truediv__, range(1,10001)))
def func_s... |
For the last few days I have been working on wave generation script. As there are a lot of calculations involved I was looking for possible optimizations to improve the performance of the code.
This specifically applies to the update function, as most of the calculations are done in here. As the full code is quite lar... |
Is it possible to shorten the Isnull checking?
It would be great to shorten this code and only have to put the datarow once.
This code imports data details (usually there would be more .x = IIF.... statements)
Public Class apPropertyFunctions
Public Function GetProperty(ByVal sUPRN As String) As apProperty
... |
I have a function fib2 which returning two values as Tuple but I want to print the product of tuples returned by function fib2. I am new to Haskell so please explain it to me in a simple way.
This problem is from SPOJ which I have already solved using C and again I am trying it in Haskell:
For each \$n\$, find \$G(n) ... |
Here is a zero pad function I have:
''' <summary>
''' Take a number string and zero pad it to the specified length.
''' </summary>
''' <param name="Number">The string representation of the value that will be zero-padded.</param>
''' <param name="ToLength">The length of the string that will result after the zero-padding... |
I'm a total newbie at parsing, so I figured I'd start by writing instances of Read for HList, which does not currently have them. I'd appreciate some feedback on the following:
{-# LANGUAGE
DataKinds
,KindSignatures
,FlexibleContexts
,FlexibleInstances
,TypeOperators
,GADTs
,ScopedTypeVariables
#-}
module MyH... |
I'm actually spending time on it, unlike the first time and going through, understanding and implementing the several suggestions I've landed on two different approaches.
Approach 1: Employing Java 8 Lambdas and stream functions made to be the equivalent of David Zheng's answer in Python.
import java.util.ArrayList;
p... |
Here is the link to the problem: Aladin on Kattis.com
Problem
Aladin was walking down the path one day when he found the strangest
thing: N empty boxes right next to a weird alien machine. After a bit
of fumbling around he got the machine to do something. The machine now
accepts 4 integers \$L\$, \$R\$, \$A\$ an... |
Let me know if it seems right to you and if anything can be optimized. My concern is that I'm unsure if circular linked lists are supposed to have a tail. I've implemented it just using a head. Is that wrong? If so, how would you change it to make it proper?
/*
* Circular Linked List
*
*/
#include <stdio.h>
#inclu... |
I am trying to write a script that will traverse through my directory and sub directory and list the number of files in a specific size.
For example, 0kb-1kb: 3, 1kb-4kb:4, 4-16KB: 4, 16kb-64-kb:11. This goes on in multiples of 4.
I am able to get the list of file numbers, the size in human readable format and find the... |
I'm new to JavaScript, and decided to learn the language by running through as many of the Project Euler problems as I have time to do. I just finished the first one, and am looking for some feedback, specifically on language specific features I could use to do this faster, and faster performance overall (it seems to r... |
This is the follow-up question from here.
This is an Observable class similar to java.util.Observable. The difference is that it uses generics to avoid casts.
There are two questions:
Is it really worth the effort? or it's just making things more complex than needed?
Should this class be declared final, or is it ok to... |
I wrote the script below to load data obtained from the twitter JSON archive on archive.org into a PostgreSQL database.
I'm looking for optimizations in the code. It currently runs at ~1.7 seconds per file (of 50,000 files), or loads 3 million rows in an hour.
Would I be looking at multithreading? The first run took ap... |
Is this the best way to remove URL parameters from a string containing an URL?
$url = "http://www.test.com/test.html?parameter=hey¶meter2=ho";
if (strstr($url, "?")) {
$url = strstr($url, "?", true);
}
Is there a better one-line solution? It seems so bad to run the same function twice.
|
The below script is one I made to check the disk space on mounted partitions under Debian Wheezy. I tried adding a -d switch to force printing out the used data, but its main purpose is to run as a cron job, and email the administrator if any disks are below a certain threshold.
What I'm looking for is to make sure it'... |
I've spent a few days working on the animations for my Bejeweled clone and I am pretty happy with the results so I am posting the code for review. This is the most advanced animation code that I have written so far, so there are probably problems with it. Here is a gif of the animation running :
I encountered two maj... |
I am a beginner in C# coding, and I was trying to compare two int variables:
void CompareNumber() {
int oneNumber;
int secondNumber;
if (oneNumber > secondNumber)
{
DoSomething();
}
else if (oneNumber < secondnumber)
{
DoSomethingElse();
}
else if ... |
I think the snippet is too nested having too many blocks. It needs to be refactored to make the logic more readable.
The try exception is the first level block
Timeout::timeout is the next level block
Some loop-like blocks inside it
How can I make it more readable?
def https_request(server_url, header, content)
... |
An interview question I received:
You are given two unsorted lists of positive doubles
x contains the results from experiment 1
y which contains the results from experiment 2.
All results from the second experiment y are improvements over x
by i percent, where i is an integer. That is to say that given a
result... |
I am playing around with CSS/HTML/PHP and created a password generator:
<?php
$lowercase_characters = "abcdefghijklmnopqrstuvwxyz";
$uppercase_characters = strtoupper($lowercase_characters);
$numbers = "0123456789";
$symbols = ".-+=_,!@$#*%<>[]{}";
$chars = "";
$password ="";
function generatePassword($length, $chars... |
I have two loops on my page - each with their own category. It works, but I don't know if this is the best practice as I'm pretty new to this stuff.
<?php $my_query = new WP_Query( 'category_name=news&posts_per_page=3' );
while ( $my_query->have_posts() ) : $my_query->the_post();
$do_not_duplica... |
In an effort to strengthen my functional programming, I'm reading Functional Programming in Scala. One of the assignments is to implement a function that does the same operation as containsSlice in the List API.
@tailrec
def hasSublist[T](list: List[T], currSub: List[T], origList: List[T], origSub: List[T]): Boolean ... |
I am building out a MUD game engine and want my objects to communicate with each other. There is a wide range of message types that will be sent around, all of which implement IMessage.
I adopted the Mediator pattern to facilitate passing the messages around to objects that have subscribed for publications. Is the pat... |
GetBootstrap v2.7.0 Update from GetBootstrap v2.5
I add a progress bar feature in my console application customizer and update the #region grouping and convert the switch statement to Dictionary that suggested in the last version.
For now I need help in reviewing my codes in ProgressBar.cs. You can also review my sou... |
I'm rewriting GNU's coreutils in Go in order to learn Go better. I've implemented ttyname(3), and I'm looking for a general critique. I can't think of anything in particular I think I did poorly on. (Meaning nothing stands out to me -- I'm sure I messed something up.)
I do return a pointer to a string instead of a stri... |
Here is my dictionary:
c_result1 = {"1": {"time": "89.46%"}, "2": {"date": "10.54%"}}
c_result2 = {"1": {"money": "89.46%"}, "2": {"finance": "10.54%"}}
I want extract, first key value of 1 i.e. time, length of the dictionary may vary.
My code:
c_result1 = {"1": {"time": "89.46%"}, "2": {"date": "10.54%"}}
c_result2 ... |
I have the below regex to match email address with atleast one @ and one .
[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}
Am wondering can it be simplified further to match email address with atleast one @ and one .?
|
I've decided to use some of my free time to create a simple game in Python. I chose Tic-Tac-Toe, but I decided not to make it too trivial. I made my game support any board size. I would greatly appreciate a code review.
## Tic-tac-toe game by Mateon1
try:
raw_input
except NameError:
import sys
print >> sys... |
I'm using this code to find out the recurring dates, within a given range. Is this the correct way to find out the recurring dates within a range of dates?
between[] contains all the dates calculated within the range provided by the user. I only pasted the code that is relevant to the recurrence part only.
switch (true... |
I'm creating the admin portion of a project. Specifically, I am wanting to allow the users to update the look-up tables for their areas of interest.
All of my look-up tables have the same structure:
TypeX
Id int
Description string
Active DateTime
Inactive Nullable<DateTime>
CreatedBy string
CreatedDate DateTime
Modif... |
In code I'm currently maintaining, there is a need to do very many repeated XOR operations of blocks of memory. The block size in my case is always 16 bytes. Because the code is executed very frequently, and because it's speed critical, I would like it to be as fast as possible. Ordinarily I'd write this in assembly... |
A collection of sorting types as following insertion, radix, selection and heap sorts.
How can i improve it?
#include <algorithm>
#include <functional>
#include <type_traits>
#include <iostream>
template <typename Iterator>
void radixSort(Iterator begin, Iterator end)
{
using value_type = typename std::iterator_t... |
I wanted to write a program that performed a query to a database, then formatted the data before writing it to a file.
I thus created 4 classes, which are:
a main class
a class dealing with the queries
a class dealing with the database connection
a class dealing with the formatting and writing of the data to a file
D... |
I have two goroutines that each need to return their results to the main function. These results are of different types.
I have implemented a solution that uses a structure that holds these results. The structure is passed to the routines and each routine knows which field in the structure to use to save the results.
I... |
This is a function I just wrote with the goal to only load the desired information once, and if an error occurs, save it for later so that it can always be reported to a calling function.
It does what I want but seems quite clumsy.
std::wstring const& GetMuiFilePath()
{
static DWORD error = NO_ERROR;
static std... |
I'm running a simple Bash script that uses rsync to do an incremental backup of my web server every hour. What I'm looking for is an efficient algorithm to delete the proper backups so that in the end I keep:
Hourly backups for 24 hours.
Daily backups for 1 week.
Weekly backups for 1 month.
Monthly backups from that p... |
I have made slight edits to a simple PHP contact form that I have found online. Can you see anything else that I could do to ensure that I am protected from email injections and spam? I have used trim, stripslashes and htmlspecialchars and made a simple question to act as spam prevention.
<?php
$myemail = "YOUR EMAIL ... |
I recently wanted to determine the probability of generating a colliding string, given a character pool size, string length and number of strings to generate. I was led to the Birthday Problem, and came up with this code in PHP:
function collision_probability($length, $count = 1) {
$chars = '1234567890qwertyuiopa... |
I wrote code for the following problem:
Given a string, print out the number of deletions required so that the adjacent alphabets are distinct.
Please suggest different methods by which I can increase the speed of execution.
tst = int(input())
for i in range(0,tst):
str = input()
length = len(str)
str = l... |
Challenge: The Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8,
13, 21, 34, 55, 89.
Consider a Fibonacci sequence whose values do not exceed four million,
find the sum of the even-valued terms.
My solution:
import java.util.Arr... |
I am currently writing a well.. manual testing site for a chat-based bot. The full code can be found on github.
For that purpose I had to keep track of the messages currently in the "system". The stored message format is that of a simple and immutable class with non-complex fields. The code for this format is coming f... |
I am working on a project that involves quite a lot of instantiated objects, with tons of properties, most of which have only a few possible values, so the prospect of saving on memory is quite significant.
I wanted "portable" bitfields in order to be able to use raw binary serialization and deserialization, so memory ... |
I feel like this bit of code could have been written more elegantly, especially with the huge if/else statements. Can somebody help me break this down? It would really help me out in the future.
// Contact
var c = 0;
var contactHeight = $('#contact-keebs').outerHeight();
$('#mail-wrap').click(function (e) {
e.prev... |
I have to write an API for checked subtraction where the input minuend can be < 0 but subtrahend can't be < 0. I think I've covered all the cases of underflow and overflow. With given conditions the range of subtrahend is [Long.MIN_VALUE, Long.MAX_VALUE] and of minuend is [0, Long.MAX_VALUE]; with these limits overflow... |
I am a self confessed jQuery novice but I am conscious of learning the correct techniques. When I can see repetition like this I just know that there must be a better way.
jsFiddle
$(document).ready(function() {
var project1 = $('section').eq(0).offset();
var project2 = $('section').eq(1).offset();
var proj... |
I've been programming Clojure for a little while and recently started learning Common Lisp. One of my favorite things about Clojure is the threading operator ->, which greatly simplifies long chains of nested function calls. Naturally I wanted to have this in Common Lisp.
I found an implementation here:
(defmacro -> (... |
An interview question I got -
Each element of an int array points to the another element,
eventually creating a cycle. Starting at array[0], find the length
of the cycle.
Examples:
Input:
array = [1, 0]
Output:
2
Input:
array = [1, 2, 1]
Output:
2
Note how element 3 is not part of the cycle
Input:
array = [1,... |
Summary
I'm getting ready to dive back into a "more proper" project, so I wanted to take a moment to get my TDD hat on before doing so. I decided to tackle this Roman Numeral Kata for practice. The purpose of the function is simply to take in a Long and output a string containing the equivalent Roman Numeral.
I'm conf... |
I am looking for improvements for this basic makefile and directory structure. I know this is overkill and could be compiled with one line in a flat directory structure, but I want to use this as a learning exercise.
CC=g++
CFLAGS=-Wl,--no-as-needed -std=c++11
LIBS=-lpthread
SRC=$(PWD)/src
BUILDDIR=$(PWD)/build
OUTDIR... |
I currently have the following class that takes a custom file object as an argument and makes a copy of the file locally.
class FileCopier
def initialize(file_info_object)
@file_info_object = file_info_object
end
def copy
File.open(local_file_path, 'wb') do |f|
read_file_in_chunks do |chunk|
f.write ch... |
As a beginner in coding, I have just written this code.
The code should Add a form with a button to each user profile, it named Follow or Unfollow. It updates the user meta named "following" for the user who clicked the button. So we have to use the user IDs as a serialized array. Then we should use a query for the use... |
I'm making a Java program that will analyze the given String by counting the lowercase, uppercase, numbers and special characters. Is there a way by making it functional?
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class PassTest {
public static String pass... |
I've been working on a registration form page in jQuery Mobile and I think I'm starting to get it fully complete.
What I need feedback on is if I've forgotten anything in terms of accessibility, security (am I open to any SQL injections or other risks?) and just anything in general. It's my first time creating a prope... |
My goal with the following code is to provide an extensible class that can be extended in order to read log files and transforms them into meaningful output.
I'd like to have comments about the code itself, the test code, the javadoc and the overall structure.
/**
* Exception to indicate that there is no more input.
... |
After much searching around the web, I couldn't find a single module which did a decent prettyXML or prettyHTML. Because:
<node>
<child>
Text
</child>
</node>
Is flat out ridiculous, and not a good use of space.
<node>
<child>Text</child>
</node>
Is much cleaner.
That's what spurred this project. ... |
I have this vbs file to check if a remote server is accessible. Can I simplify or refactor to make it more robust/efficient?
const forReading = 1, forWriting = 2, forAppending = 8
public maxWaitTime
maxWaitTime = 60 '1800 '30mins
public connLogFileName
connLogFileName = "connectionLog.txt"
public pathToRemoteServer
p... |
I've been doing some programming challenges and problems lately and it seems like many involve primes. I concluded that I would benefit from optimizing how I'm checking for them. Currently I'm using the following method:
private static boolean isPrime(int num) {
if (num < 1) {
throw new IllegalArgumentExcep... |
This is a Rspec test for pagination in Rails project. I'm not sure if I should write the test in spec/requests or spec/controllers.
And there must be a lot of thing that I had better to do. Which part of code should I refactor?
spec/requests/companies_spec.r
describe "Companies" do
describe "GET /companies" do
be... |
This is my implementation of Project Euler #2 in C#. It takes 0 milliseconds to run, and I believe it is correct - I have seen nothing to indicate otherwise!
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
static void GetFibos(ref Lis... |
I have just finished working on a Node.JS module that provides "multiple inheritance that works". I had some really specific requirements:
Works in safe mode
Auto-calling of parent constructors
Makes sure that a constructor is only ever in the inheritance chain once
Support for multiple inheritance
Copying of class-wi... |
A little context:
Book has 411 Pages
Read a random number of pages on the first day which is unknown
Number of pages to read next day is the square of the sum of the digits of the page currently on
I.e. on Page 36: read 81 pages next day
On day 6 The square answer directly adds to current page number to make 411
Fini... |
This code gets a state from a query string hash part, converts the hash part to a JavaScript object and then tries to get a view, dashboard or a mode value. If those keys are not present in object, it returns $.pulse.qs.views.home.
Does this JavaScript code with ternary operator follow common best practices? It looks l... |
For learning purposes, I am implementing certain code from Sedgewick & Wayne's Algorithms, Fourth Edition.
Because of language features, a direct translation doesn't seem possible.
For example, I believe the get method in their implementation of SequentialSearchST can return null for both value and reference types beca... |
This is my implementation of Project Euler #7. Have I overdone it again? Is there anything else I should or should not do? It runs in 9 milliseconds on my computer.
What is the 10001st prime number?
static int NPrimeGenerator(int nPrime)
{
List<int> primes = new List<int>();
primes.Add(2);
int nPrimeV... |
I decided to solve a problem from Code Golf called the four fours.
Problem description:
The Four fours puzzle is a popular recreational mathematical puzzle
that involves using exactly four 4s (and no other number) and a
defined set of operations to reach every number from 0 to a given
maximum.
In this version, the onl... |
This is my first submission and have completed one quarter of Java programming.
I have an assignment to create a Palindrome Checker. Fairly straight forward, I had that portion of the code figured out in the first hour. However, in typical fashion (for me) I want my code to do a bit more. This is where I run into issue... |
I have this implementation of a binomial heap providing insert, decrease-key and extract in logarithmic time.
MinPriorityQueue.java:
package com.stackexchange.codereview.ds;
/**
* This abstract class defines the API for the various minimum-priority queue
* data structures.
*
* @author Rodion Efremov
* @param <E>... |
Given a sequence of heads and tails I want to find how many significant subsequences are in this sequence where the number of heads is not less than the number of tails. I want to achieve this in \$O(N \log N)\$ time.
Example input:
[ 'H', 'T', 'H', 'T', 'T', 'H' ]
Example output:
11
Explanation:
{H} {H} {H}
{H, T} {... |
This is my implementation of Dijkstra's algorithm in C++.
Please clarify
Whether the class design is proper or if it needs to be improved.
I am just hard coding the vertex based on the priority of the vertex. Is there is any other way to implement it?
Please provide some suggestions to optimize the code.
class Verte... |
Here's the problem for Java vs C++ (JAVAC):
Java and C++ use different naming conventions:
In Java a multiword identifier is constructed in the following manner:
The first word is written starting from the small letter, and the following ones are written starting from the capital letter, no separators are used. All ... |
I am creating a trivia game (purely for learning purposes) using AngularJS, NodeJS and MongoDB. My concern is related to the way I am organising the code in AngularJS. So far the game is functional, everything is working fine, but I know I am not doing it right. Directives should handle the DOM manipulation, but am doi... |
I have this small generic path search library. It's not perfect at all, so I need some comments as to have a chance to improve it.
com.stackexchange.codereview.graph.model:
AbstractHeuristicFunction.java:
package com.stackexchange.codereview.graph.model;
public interface AbstractHeuristicFunction<T extends AbstractNod... |
I have just started programming and we are being taught C++. After our 2nd lecture we were given an assignment to make a program that would take two values of time from the user (0 <= hr <= 12 and 0 <= min <= 60) and return the value of elapsed time.
Since conditionals statements are not introduced yet, I am trying to... |
I have 2 matrices. I have to calculate the euclidean distance between every row of matrix A and every row of matrix B.
In the first solution I loop over the rows of the two matrices and for each row in matrix A, I take a row from B, take the square of the element wise subtraction, then sum it and take the square root.... |
I wrote a program, that gets a certain array and replaces each value in the array with the distance from it to the closest zero value.
Time complexity is \$4n\$ => \$O(n)\$. (please correct me if I'm wrong, though).
But I can't figure out what's my space complexity. The task was to make it as efficient (by time and spa... |
Challenge:
Count how much rain will be collected in the valleys between the peaks
of a mountain range in a 2D world.
The mountain range is defined by a single array of positive ints,
where each element defines the height a peak. IE the array [1,2,1,2]
would create the 2D slice:
. m . m
m m m m
m = mountain
. ... |
The program reads a .txt file that contains lines of numbers. The first one has one number N and the second one has \$N\$ numbers as the first line says.
The \$N\$ numbers is \$1 \le N \le 1.000.000\$.
The program read the \$N\$ numbers in an array and performs the following procedure:
Read the number one by one back... |
Playing with a simple Java Point class where I would like to constrain the X and Y values to be doubles that must be in the range -10 to 10, inclusive. I've written some code, but it's been years since I've written java and I would like to know if this is how it would be written in modern Java:
public class Point {
... |
I started out practicing on implementing the builder pattern and somehow ended it up with this 2 hours later. It isn't really much, but it works and I'm hoping review should bring about a lot of insight.
I'm curious in pinpointing:
Which part(s) are well executed? I've never done anything 'game' like so I have no idea... |
I received a task, of taking a known text file (Linux dictionary), use threads to count the different letters in it, and present the results in an array.
The code doesn't have to be pretty, elegant, clean or short. The only demand is to count the letters correctly and do it as fast as possible. The file will be timed u... |
This is an implementation of the Haversine formula in Microsoft Transact SQL.
How can I simplify the function?
CREATE FUNCTION dbo.Haversine(@point_a geography, @point_b geography)
RETURNS FLOAT
AS BEGIN
DECLARE @result FLOAT
DECLARE @lat1 FLOAT = @point_a.Lat
DECLARE @lon1 FLOAT = @point_a.Long
DECLARE... |
This works for the most part. I am very new to programming so be aware.
import java.util.*;
public class HangManP5
{
private static Scanner k;
public static void main(String[] args)
{
int attempts = 10;
int wordLength;
boolean solved;
k = new Scanner(System.in);
System.out.println("Hey, what's your name?");
String n... |
This function is meant to take an object, loop through the key-values and generate/build a HTML table at a particular ID:
function insertBasicTable(basic_data, insert_id) {
/* Insert the key/value pairs into a table element on the DOM.
basic_data = object containing key/value pairs
insert_id = the id on the DOM... |
I recently tried to implement a simple hash table using Javascript. Could anyone help me review my implementation?
//Hash Table Implementation
var HashEntry = function(key, value) {
this.key = key;
this.value = value;
this.nextEntry = undefined;
};
HashEntry.prototype = {
getKey : function() {
return... |
So, I began this challenge on CodeEval, which asks to print out the number of prime numbers less than any given integer N, where 0 < N < 4,294,967,295, ideally in O(N log N) time. I came up with this solution:
import java.io.*;
public class Main {
public static void main (String[] args) throws IOException {
... |
I am building this program in Python to generate 10 random arithmetic questions of either multiplication, addition or subtraction and then saves users scores to a .txt file. I just wanted some help condensing the code as I'm really stuck as of what to do with it.
How can I combine the function (e.g. multiplication, add... |
I'm making a data parser for road tax data (costs) which parses a JSON file with all weird variable names, which the customer gave me.
The costs are different on each vehicle type. The costs at some vehicles are also splitted over the provinces.
class RoadTaxDataParser
{
/**
* @var array $data The data for ev... |
I want to convert string arrays with following structure:
static String[] lines = {
"@1 var_decl name: testStr parent: @7",
" srcp: Auto.cpp:6 "
};
into Java objects with following stru... |
Please review my code for preorder, inorder and postorder of a tree. I am using C++11 (or wanted to use), so let me know if anything is deviating from the C++11 standard.
#include <iostream>
#include <memory>
using std::cout;
using std::endl;
using std::shared_ptr;
struct node
{
int data;
shared_ptr<node> lef... |
Below is the code for stack along with one or two extra options. Kindly let me know if there are any concerns/critical issues. Below are the links for previous versions.
Version 1.0
Version 1.1
Version 1.2
//*************Version 1.3: Begineer's Implementation of Stack ***************//
#include <iostream>
#include <f... |
I'm looking for a review of the following code.
Is there a better way to remove all properties that evaluate to truthy for a given function?
Is there a better way to prevent a stack overflow in the recursive function?
This is the entire Node.js module:
// The removePropertiesWhereTruthy function accepts the following... |
I want to create an extended disable/enable function in jQuery. This is working, but is this the best solution? Is each loop necessary?
$.fn.ariaDisabled = function (isDisabled) {
/// <summary>
/// Sets the disabled state.
/// </summary>
return this.each(function () {
v... |
I setup my code at jsfiddle. Along the review I want to know the solution of a problem I'm facing in this code.
On click the Edit button I want to enable the calendar which is disabled by default. And when it will be enabled user can select dates manually. Once user is done with selecting dates and will click the sav... |
I'm trying to build my first object oriented system. I'm not sure that my register function below is the best way of approaching this within OOP.
class User {
public $username;
private $email;
private $password;
public function register() {
//Check if the username input is set.
if(isset( $_POST['username... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.