instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I am working in JavaFX and I created util class which is responsible for creating new window. I called this class WindowUtil. Depending on the button that was clicked I want to:
Open new window
Send some data to controller of this window (this is optional)
The problem is that code responsible for opening a new window... | stackexchange/codereview |
I'm quite new to threading primitives in C# and was hoping you might be able to suggest improvements to this. I need to ensure that the XXX call below happens within the calling thread (XXX is a foreign call into a thread-unsafe library), so I used a queue here. It seems a bit like there should be a better primitive fo... | stackexchange/codereview |
I'm working with a REST service that responds with indeterminate types. In particular, it can respond with a String, a correct payload (T: Decodable) or an error payload (PayloadError).
In order to cope with this type of requirement I've ended up with the following solution:
do {
let decoder = JSONDecoder()
let... | stackexchange/codereview |
While quarantine I decided to look into the assembly language, as it's quite interesting to see how code works on the lower levels. To challenge myself I made a binary search algorithm. The OS is Windows.
I just code casually (in Python and C++, so I know about the concept of pointers), therefore I don't have that much... | stackexchange/codereview |
The things I'm interested the most from the review are:
The performance of the code
Overall review of the code structure, styling rules and naming conventions.
What is the largest prime factor of the number 600851475143 ?
import math
#---------------------------------------------------------------------------------... | stackexchange/codereview |
There was a Tweet from @ExcelEasy earlier this week, that linked to this article, to which I replied with a little challenge:
@ExcelEasy well done! #Challenge: make a more #OOP one without using the form's default/global instance! #becausewhynot
Of course I wouldn't just leave it at that, so here's my own implementat... | stackexchange/codereview |
If have the following code that via an SQL query retrieves data from a database in the form:
Id subschemaName locusName
MLST MLST LMO0558
MLST MLST LMO0563
MLVST MLVST LMO1305
MLVST MLVST LMO1089
And I want to turn this into an XML like:
<ResponseSubschemas>
<o... | stackexchange/codereview |
I didn't want my title to be too long so to clear up any confusion I'll explain better here what my code does.
It asks for the total pages of a book(PDF file in my case), and returns the page numbers in a specific order. The groups of 32 pages will each make a booklet that when all booklets are stapled together and lai... | stackexchange/codereview |
I am trying to use Entity Framework as simple as posible. Use UnitOfWork and Repository patterns seems to be overkill because whole web application will be pretty straightforward. I came with this idea:
public class Entity
{
...
}
public class MyContext : DbContext
{
//Set database connection details here.
... | stackexchange/codereview |
Can someone please find out why this store procedure is timing out?
ALTER PROCEDURE [dbo].[Insertorupdatedevicecatalog]
(@OS NVARCHAR(50)
,@UniqueID VARCHAR(500)
,@Longitude FLOAT
,@Latitude FLOAT
... | stackexchange/codereview |
Is there any cleaner way to implement the following?
await Task.Delay(100);
ExecutionProgress = .1;
await Task.Delay(100);
ExecutionProgress = .2;
await Task.Delay(100);
ExecutionProgress = .3;
await Task.Delay(100);
ExecutionProgress = .4;
await Task.Delay(100);
ExecutionProgress = .5;
await Task.Delay(100);
Execution... | stackexchange/codereview |
Anyone please review my code and give some improvement suggestions.
I wrote code but not to the best standards. I think this site give some valuable suggestions
this code is for extracting xlsx or csv files int list of dicts and change the values of the dict objects after that concert that to json file
excelparser.py
... | stackexchange/codereview |
I'm feeling uneasy with this service method that I wrote:
@Override
public Optional<Set<TenantDTO>> getAllTenantsOfUsers(Set<Long> usersIds) {
return Optional.ofNullable(usersIds)
.map((ids) -> tenantRepository.findAll(QTenant.tenant.users.any().id.in(usersIds)))
.map((i... | stackexchange/codereview |
I want to improve this program so I want you to criticize the code, and tell me what else can I do, and where can I find information about what I have to do.
TODO:
Fix wget timeout
The code should always check the returned value from any of the malloc family of functions to assure to memory allocation was successful
t... | stackexchange/codereview |
Kindly accept my apologies as Java is something my mind cannot digest no matter what I do. At the moment I have an assignment and have written a piece of code and have used Constructor (I think so) but not sure if I have used it correctly and if Yes then will need some guidance in order to refactor the code.
Anyhow I ... | stackexchange/codereview |
I am starting to work on a basic 3D renderer for fun, so right now I have made a triangle fill function to be used when I draw faces on models:
public void fillTriangle(Triangle2d t, Color color) {
// triangle points are already sorted
Line2d ab = t.getAB(), bc = t.getBC(), ac = t.getAC();
Line2d leftEdge =... | stackexchange/codereview |
I feel like I had to invent a whole new way to do this because I couldn't find anything that did this the way I wanted to...
The basic process involves reading changes to cells and capturing information about those changes as they relate to the actual Entities in question and then persisting them to the database.
Here'... | stackexchange/codereview |
I am making a very simple stopwatch functionality as below.
New will start the timer.
Pause will suspend the watch.
Start will restart again.
Session will return the duration.
#include<chrono>
#include<vector>
class Timer {
using cppTimer = std::chrono::high_resolution_clock;
using seconds = std::chrono::s... | stackexchange/codereview |
As a first step in learning Haskell I am solving this problem, which involves finding the Rith-ranked numbers, given some input list and many Ri. In an imperative language I would make a zeroed array c of length 200, increment c[h] for each height h, compute cumulative sums of c and then binary search c to determine th... | stackexchange/codereview |
I've designed a single-file safe integer library in C++. It catches undefined behavior prior to integer overflows or underflows and throws the respective exceptions. I intend this to be portable, to not rely on undefined behavior, and to rely as little on implementation-defined behavior as possible.
safe_integer.hpp:
/... | stackexchange/codereview |
This is my code for doing a roll back with multiple MySQLI prepared statement.
I want to know if anything is wrong with the code.
$newRegistrationDataArray = array(
"date" => $date,
"name" => $name,
"address" => $address,
"country" => $country,
"occupation" => $occupation,
"emailAddress" => $em... | stackexchange/codereview |
I would like some feed back on a method which calculates the sum of Manhattan distances for each tile in a sliding puzzle to its goal position in the goal puzzle.
Here is the code:
public static int calcManhattanDistance(int[] ps, int[] goal) {
int rowSz = calculatePuzzleRowSize(ps);
int manhattanDistanceSum = ... | stackexchange/codereview |
I am storing incoming data into SQL server database
In storing process assigning group Id for 3000 records
I have written windows application that check new data is incoming into the database. first checking number of groups created while storing data and staring task same as number of groups
For that I written async ... | stackexchange/codereview |
I'm attempting to implement a calculator-like application in C#. But the way I've currently implemented it seems a little messy and inefficient. It works, but it's just I'm pretty sure it can be achieved in a more elegant solution.
I looked to see if I could factor out any repeating code, such as the switch statement -... | stackexchange/codereview |
I'm working on some Python code and have a few functions which do similar things, and the only way I've found of writing them is quite ugly and not very clear.
In the example below, the goal is to compute the Kronecker product over a tensor chain of length M, in which the mth tensor is R and every other tensor is J.
Is... | stackexchange/codereview |
The parts_sums function in the code takes a list as parameter and then returns sum of all sub-lists present in the list. e.g.
if, ls = [1, 4, 6, 4] then ls contains,
ls = [1, 4, 6, 4]
ls = [4, 6, 4]
ls = [6, 4]
ls = [4]
so the function should return a new list:
nsl = [15, 14, 10, 4]
def parts_sums(ls):
nls, c ... | stackexchange/codereview |
I'm creating an update function to show my users when the next update will be available. I'm using the jQuery countdown plugin to show the time. What is a more efficient way to write this?
today = new Date();
todayDay = today.getDate();
todayYear = today.getFullYear();
todayMonth = today.getMonth();
todayMonth ++;
v... | stackexchange/codereview |
I have a piece of code that calculates the edit distance between words and works, but it's apparently not fast enough.
ClosestWords.java:
import java.util.LinkedList;
import java.util.List;
public class ClosestWords {
LinkedList<String> closestWords = null;
int closestDistance = -1;
public int dynamicEditDista... | stackexchange/codereview |
So again, I am a bit confused about some notes that i'am getting from my reviewer. I have some kind of utils, to print/prepare log messages. Yea, maybe I am a bit fanatic java 8 lambda guy but I think it is still under control. :)
So its looks like that [I hide 'sensitive' data]
public class ExceptionUtils {
private... | stackexchange/codereview |
I have written a piece of code that calculates how to cut pipes based on an order and fixed raw pipe length (in this case 288 feet), but I am not 100% happy with my current code as it counts the pipe pieces that have been created for each length in column C (see comment in code) and clears column C at the end. Is there... | stackexchange/codereview |
This is an accounting program (and my first attempt at a web app of any kind) where users need to get and retrieve objects from different JSON URLs and at different levels. Rails is used for the back.
I'd like to know if the following process is the best to use:
User clicks button to toggle some boolean value
Local JS... | stackexchange/codereview |
I have a school assignment and would love it if you can criticize or give a couple of pointers/advice about my piece of code (don't give me the answer, breaks the point of the exercise).
Here's my work:
#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
int mai... | stackexchange/codereview |
https://leetcode.com/problems/insert-delete-getrandom-o1/
please comment on performance
Implement the RandomizedSet class:
bool insert(int val) Inserts an item val into the set if not present.
Returns true if the item was not present, false otherwise. bool
remove(int val) Removes an item val from the set if present. R... | stackexchange/codereview |
I have a plist file with many nested dictionaries inside of it, and I wanna fetch them all to my code. Isn't there any more efficient way to do that than nested for-loops?
NSArray * keys = [plistDictionary allKeys];
for (NSString * key in keys) {
// Level 1
NSLog(@"%@", key );
BOOL isDictionary = [[plistDi... | stackexchange/codereview |
I am using react-flow-chart for a job project, but it doesn't implement zoom, and I would like to take the reigns and try applying it myself. I took a linear algebra class in college, but I am not very good at transformations. I could make my job a lot easier if I directly use CSS transforms and have it do the heavy li... | stackexchange/codereview |
A friend is doing a CS course that has a command line address book as
a term assignment. Although I am a programmer in industry, I don't do
a lot of C++, so I ended up doing this as a learning exercise for C++.
The address book is supposed to read a CSV file named addressBook.csv and parse contacts in the specifie... | stackexchange/codereview |
I've written this code keeping the following cases in mind and I think I've covered them all. I'd really appreciate if someone could help me determine if I've covered all of them.
Cases I considered:
No comments at all
Text /* Text */ Text
Text /* Text */ Text /* Text */
Text /* /* Text */ */ Text
Text /* /* Text *... | stackexchange/codereview |
As of reading the following input.txt file:
1 6 14
1 2 7
1 3 9
2 3 10
2 4 15
3 6 2
3 4 11
4 5 6
5 6 9
I wanted to make a list of lists containing each line as a list of integers
[[1, 6, 14],
[1, 2, 7],
[1, 3, 9],
...
[5, 6, 9]]
I achieved that by doing the following
with open('input.txt', 'r') as f:
# gets l... | stackexchange/codereview |
I'm doing the exercices from clojureacademy.
Here are the instructions for this one.
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Returns "Whatever." if given phrase is one of the following inputs:
"Tom-ay-to, tom-aaaah-to."
"Let's go make out behind the gym!"
"It's OK if yo... | stackexchange/codereview |
This question over on SO about how to call a function "later" using Rx led me to post the following ill-advised piece of code to solve the problem:
void Main() {
getScheduleTimes()
.Where(t => t >= DateTimeOffset.Now)
.SelectMany(t => Observable.Timer(t).ToEnumerable())
.ToObservable()
.Subscribe(_ =... | stackexchange/codereview |
I wanted to know whether this approach is correct or not for a basic quiz game. I have not used object oriented programming style, Defining the quiz questions as array elements and looping through the array with a variable.
let q = ["1. What is the capital of Israel ?",
"2. Who is the Prime Minister of India?",
"3... | stackexchange/codereview |
General information
I am using an acceptance testing framework (robot framework) and it has an API which allows you to 'visit' suites and tests before execution.
Specific goal
The framework does not save the original suites name (a.k.a. tests.my_test). If you wanted to run that test twice with different names it will t... | stackexchange/codereview |
This is a basic game loop written in C++ using SDL. All feedback is appreciated especially feedback related to design and extensibility.
Main.cpp:
#include "Game.h"
int main(int argc, char* argv[])
{
Game game;
game.Start();
return 0;
}
Game.h:
#pragma once
#include <SDL.h>
class Game
{
private:
SD... | stackexchange/codereview |
I have written the below code for quick sort in Java:
void quicksort (int[] a, int lo, int hi)
{
// lo is the lower index, hi is the upper index
// of the region of array a that is to be sorted
int i=lo, j=hi, h;
// comparison element x
int x=a[(lo+hi)/2];
// partition
do
{
while (a[i]<x) i++;... | stackexchange/codereview |
This is for commercial purposes. It's not going to a database, but will just be emailed to a person via phpMailer.
I am not good at PHP (truly awful). I'd like to know whether this is good enough for going production or not.
<?php
session_start(); //allows use of session variables
if ($_SERVER["REQUEST_METHOD"] == "PO... | stackexchange/codereview |
Find 3 elements that sum to zero in an int array.. I would like to be reviewed on efficiency, style, and obviously if there is a bug I would like to know.
def sum_to_zero(a):
''' given an array of ints, find 3 elements that sum to 0 '''
for i in a:
for j in a[1:]:
for k in a[2:]:
if i + j + k ==... | stackexchange/codereview |
I am writing a program that is capable of reading a matrix supplied from a text file. One intended feature of this program is that it should be capable of detecting various delimiters in the text file.
So, for example, these inputs should be interpreted equally:
1,2,3,4
5,6,7,8
9,10,11,12
1:2:3:4
5:6:7:8
9:10:11:12
M... | stackexchange/codereview |
This code works nicely for my purposes, but I would like to improve it exponentially.
What are some steps I can take? I'm interested in optimization, refactoring, and clean-code.
def do_GET(self):
qs = {}
path = self.path
print path
if path.endswith('robots.txt'):
self.send_response(500)
... | stackexchange/codereview |
I implemented my first algorithm in golang - the caesar cipher. Is there something i could do more efficiently? I am quite new to go and any improvement suggestions are welcome.
package main
import "fmt"
// +1 encoding, -1 decoding
func main() {
var text string
var choice int
var shift int
... | stackexchange/codereview |
I've seen a few TTT related posts recently, and thought I might learn something or be reminded of certain techniques from attempting my own rendition. Here is that attempt! Hopefully any new coders can benefit from this as well. Any improvement suggestions are welcome, and numpy, scipy & bitwise operations are open to ... | stackexchange/codereview |
I'm having some trouble isolating the parts of my code enough for unit testing to make them simple and easy to maintain. The code I'm writing feels like an integration test because most of what I'm doing in the test.
I'm curious on how I can both make this code better and more unit-testy. This is just a single unit tes... | stackexchange/codereview |
The need came up the other day to be able to easily switch back and forth between making IBM DB2 queries and MS SQL queries. I didn't want to mess with NHibernate as I was on a time crunch, and I also didn't want to have a million connection strings. Lastly I learned a while ago that for classes that needed to be used ... | stackexchange/codereview |
I typed this up quickly as an intuitive solution for determining if a given number is a perfect square.
How could I improve this? I already know that it doesn't handle the case where the number is 1. I'm wondering if I could generalize the calculation so it rounds up. What can I look into to develop a mindset for tackl... | stackexchange/codereview |
I have a custom logger which logs all messages at WARNING level and above to a Slack channel. Certain error messages occur so frequently that they make it hard to see actual errors in the channel, so I would like to be able to disable Slack logging for a specific message, using something like logger.error("This is a co... | stackexchange/codereview |
I implemented a binary tree in the following code. Its node's copy constructor and assignment operator should copy itself and all its descendents. Similarity a node's destructor should delete itself and all nodes descended from it.The print function just prints each node in a new line. How can I pretty-print it? Please... | stackexchange/codereview |
I am trying to implement graphic objects that can be either Sprite, Base, Point or some others, but not very many types at all. That's why I do not make separate classes. All types exist in 1 class due to unions and few short switches. I use directly objects, not pointers, and no virtual methods.
The question is also, ... | stackexchange/codereview |
I am trying to find the users who have the highest "Following vs. Friends" ratio in my Twitter timeline.
I have a SQLite database of the users in my Twitter timeline and each column contains data found in the user section of the tweet JSON.
Is there a better way that I could write this search query?
Why does it retu... | stackexchange/codereview |
From the last few days I have been studying scraping webpages and for further development I challenge myself to transform the script I have created into a class which will receive inputs from a user.
The main reason I'm posting this is because I would like advice and insights on how should I approach and manipulate ins... | stackexchange/codereview |
I've just "finished" my second attempt a core game loop, which is a heavily refactored version of my first attempt.
My perceived benefits are:
Using functors means that the actual loops themselves are independent from the actual systems them manage. You can wrap states up elsewhere, and the only assumption they need t... | stackexchange/codereview |
The problem is basically this: Return the permutation of the set of the first n natural numbers which satisfies the following property:
|pos(i) - i| = k
∀ i ∈ (1,n)
where pos(i) is the ith number in the permutation
If no such permutation exists, return -1.
Note: the input is the integer n.
The full problem is on Hacker... | stackexchange/codereview |
Background
A recent question Print sums of all subsets made its way to the Hot Network Questions list. The problem is simple:
Print sums of all subsets of a given set
Given an array of integers, print sums of all subsets in it. Output
sums can be printed in any order.
Examples:
Input : arr[] = {2, 3}
Output: 0 2 3 ... | stackexchange/codereview |
I'm fairly new to Java and I'd like to know if there's any way to improve or refactor the prompt on validating integer values for best practices.
import java.util.Scanner;
public class Triangle {
public static void main(String[] args) {
int a, b, c;
Scanner in = new Scanner(System.in);
// Prompt for a
Syst... | stackexchange/codereview |
I'm sanitising personal data in a large database with a series of Regular Expressions. In many cases the sensitive data is in a colon-delimited field within a CSV file.
Here is a sample:
(142406, 202, '45759:2940:2016-04-12-21-24-08:300:2016-06-21:2016-04-11:1:Windows/Doors:', 2761, 4041931, 0, '1460492649'),
(142404, ... | stackexchange/codereview |
If I draw something in Illustrator and extract it with AI2Canvas I want it to be customizable so I wrote this simple program. It adds two variables: one to resize and one to shift the path coordinate.
#include <fstream>
#include <regex>
#include <string>
int main(int argc, char *argv[]) {
std::string path = argv[1];... | stackexchange/codereview |
I am writing an update statement. I think my SQL statement is opening me up for SQL injections. Is there a better to do this?
public void UpdateQuote(string quote, string quote_id)
{
using (IDbConnection dbConnection = Connection) {
string query = "Update quotes set quotes = '"+quote+"', updated_at = NOW() whe... | stackexchange/codereview |
Having contributed to this Community Wiki on StackOverflow regarding validating user input, I thought I'd finally sit down and write something more robust to do these kinds of tasks. I wanted something that would allow detailed configuration of the acceptable inputs, but without a huge list of arguments or spaghetti of... | stackexchange/codereview |
I am looking to see if someone is willing to take the challenge in optimizing this noob python script.
The purpose of the script is to:
Check if Google Drive File Stream is installed
Check if Google Drive is installed
Check if user's Google Drive folder has been renamed
Then the actions begin:
Install Google Drive F... | stackexchange/codereview |
I've made an Arduino program to run on my Teensy 3.1 board. It accepts characters and strings sent to a Bluetooth module (BC417) from any Bluetooth-enabled device and uses these to power certain pins on my 8x8 LED matrix.
I believe the code works, but I haven't been able to test it fully yet. I'm hoping (if it's the ri... | stackexchange/codereview |
I have made a method which takes two parameters: the value to convert and the base. Based upon those two parameters my method is adjusted (with several helper methods) to change the desired decimal number to a number with a different base.
Is this code practical and clean? If not, what should I change to make it better... | stackexchange/codereview |
Introduction
This is yet another data structure I'm going over again for the algorithms course. This time it is binary search tree.
Implemented operations:
Insert
Exists
Remove
Clear
Move constructor and assignment, destructor
There are some tests for remove function below the data structure itself. I tested other fu... | stackexchange/codereview |
Just beating the dead merge-sort horse, this time with generators and recursion!
What do you think?
p.s. Not entirely sure why stack overflow needs me to post more details on a code review. I'm implementing something straight from an undergrad CS class but because it does, here Is the video that inspired me https://www... | stackexchange/codereview |
I created a Greasemonkey script to allow me to quickly fill a specific form on a specific URL, for testing/dev purposes. If the current URL matches any of the urls found in the formsDefault array a button is added to the page that allows the user to auto fill with the default values.
This is my first time using arrow f... | stackexchange/codereview |
I am trying to implement DSs in C++ and this is BST insert and search functions. I tried in two different ways, please review and see if one is advantageous over other.
With pointer to pointer
#include <stdio.h>
#include <iostream>
struct BstNode{
int data;
BstNode* left;
BstNode* right;
};
BstNode* NewNode(int da... | stackexchange/codereview |
The purpose of this program is to keep track of some stocks that we bought in a game and every week we must list the closing prices of each stock in a Google Sheet. I thought since I had a lot of different investments to keep track of I would write a quick script to do it for me. And I could have my friends in class se... | stackexchange/codereview |
I have this simple function here because I am too lazy to write out a state dropdown every time I need one. I already have an array with all the states set up, abbreviations as keys and names as values. It works just fine, but I like to write concise, clean, legible code, and I am still very unseasoned, so I find I mis... | stackexchange/codereview |
I am doing an exercise on finding the nearest pair of prime numbers p₁ and p₂ such that:
p₁ ≤ p₂
p₁ + p₂ = n (for 4 ≤ n ≤ 10⁷)
p₁ and p₂ are primes
p₂ - p₁ is minimal
I think it should work perfectly except that it got a TLE. Can someone point out how can I avoid it?
import math
import random
def _try_composite(a, d... | stackexchange/codereview |
I'm currently working through an exercise of Chapter 4 from Automate the Boring Stuff, which reads as follows:
"Say you have a list value like this: spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a sp... | stackexchange/codereview |
Depending on the width of the screen the JavaScript animates a node and then loops another animation.
I'm trying to understand DRY but my JavaScript skills aren't quite up to scratch to get this code as optimised as possible. I'm also wanting to implement $(window).resize(function() { }); to detect this change without ... | stackexchange/codereview |
I managed to setup multiple spinners using one listener but there is a lot of repetition in the code.
My full onItemSelected method:
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
when (parent.id) {
R.id.spinner_ingredient_1 -> {
val selection = pa... | stackexchange/codereview |
I recently applied for a Java developer position and I was asked to completed a coding task.
After review of the coding task, the company said they do not want to take me forward to interview.
They refused to give feedback so I have no idea of what went wrong.
I'd love some insights on what I did wrong.
The task:
Yo... | stackexchange/codereview |
I have below code which works fine as its written in bash, i am just posting it here to see if this can be better optimised as per the BASH way. I am have an intermediate understanding in bash so, looking for any expert advise.
Thanks for the reveiw and comments in advanced .
BASH CODE:
#!/bin/bash
###################... | stackexchange/codereview |
I was following a tutorial for a social network. I want to know how secure this code is because I plan on launching it to the public web.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// declaring vars to prevent errors
$fname = ""; //First name
$lname = ""; //Last name
$em = ""; //Email
$em2 = ""; // ... | stackexchange/codereview |
I recently found a static C function on Stack Overflow which returns a UIViewController reference from a containing subview using the responder chain:
static UIViewController *viewControllerForView(UIView *view) {
UIResponder *responder = view;
do {
responder = [responder nextResponder];
}
whil... | stackexchange/codereview |
I have a couple of functions for doing basic arithmetic on polynomials.
let rec mulC x ys =
match (x,ys) with
| (_,[]) -> []
| (x,y::ys) when x > 0 -> x * y::mulC x ys
let rec addE xs ys =
match (xs, ys) with
| ([],[]) -> []
| ([], y::ys) -> y::ys
| (x::xs,[]) ... | stackexchange/codereview |
Since I have just started Javascript, I am trying to solve a few problems and improve myself. I encountered such a question. I tried to do everything step by step from the question, but I do not think that my code is efficient. Can someone help me develop it?
Please code for a JavaScript function that accepts two argu... | stackexchange/codereview |
So, I have coded a PHP script that will make it able for the users to edit their Post, or comments on a site that runs SociaEngine 4.
So, Is there anything that could get inproved/fixed on this?
<?php
session_start();
$Mysql_Hostname = "192.168.1.110";
$Mysql_Username = "*user";
$Mysql_Password = "*****... | stackexchange/codereview |
Learn You a Haskell explains zip4:
--ghci> zip4 [2,3,3] [2,2,2] [5,5,3] [2,2,2]
-- [(2,2,5,2),(3,2,5,2),(3,2,3,2)]
Please critique my implementation:
zip4 :: [a] -> [a] -> [a] -> [a] -> [(a,a,a,a)]
zip4 xs ys zs as = zip4' xs ys zs as
where zip4' [] _ _ _ = []
zip4' ... | stackexchange/codereview |
This is a kind of follow up to my previous sort implementation review with specific questions to quick sort, and Modern C++ idioms.
template<typename BidirIt,
typename Comparator = std::less<typename std::iterator_traits<BidirIt>::value_type>>
void partition(BidirIt first,
BidirIt last,
... | stackexchange/codereview |
I'm writing a php library for managing configurations of an application.
but the problem is anyone who uses my library will store their configuration files in ./config folder of their project root directory.
e.g. var/www/example.com/config/site.php
and my library is installed in a sub directory of the project
i.e ven... | stackexchange/codereview |
Today I've found /r/dailyprogrammer and I've solved an easy challenge. I'm new to coding and I'm not sure if this is good way to solve this kind of problems. Could you, please, give me some hints? How to make my code more clear and readable? Thanks!
Challange description:
A number is input in computer then a new no sh... | stackexchange/codereview |
I've created a program for my own purposes in three different languages, Perl, Python, and Ruby. Each program will be posted in with their own tag but I will add links to them through on each post. The program itself is very simple, all it does is ask the user about three different languages which are saved into an arr... | stackexchange/codereview |
I made a little text-based game where you move a rover and it gives you the current coordinates. You can essentially move around a 1000x1000 grid, and get output into stdout on what your coordinates are. I'm simply wondering if I could improve anything.
# Rover moving program
from random import randint
# Starting pos... | stackexchange/codereview |
(See the next follow-up here.)
This is the 4th version of the program killer tool:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <shlwapi.h>
#include <TlHelp32.h>
#pragma comment(lib, "Shlwapi.lib")
static const char* get_last_err_msg() {
DWORD errorMessageId = GetLastErr... | stackexchange/codereview |
I'm making a demo program for a job interview and I'd like to know if there is anything I can make work faster in my current solution. It's a C# console application that accepts input in form of a single string with the words delimited by , symbol. The task is to find the most commonly encountered combination of three ... | stackexchange/codereview |
I have three models which look like this:
class Post < ActiveRecord::Base
belongs_to :user, :counter_cache => :count_post
has_many :likes
end
class User < ActiveRecord::Base
has_many :posts
has_many :likes
end
class Like < ActiveRecord::Base
belongs_to :user
belongs_to :post, :counter_cache => :count_like... | stackexchange/codereview |
I want to implement the following case
Input - integer number n
Start 3 threads. The first thread prints 'a', the second prints 'b', the third prints 'c', then the first thread prints 'a' and so on
Example: Input - 6, Output - "abcabc"
I want to use condition variable to synchronise threads
My code
#include <iostream>
... | stackexchange/codereview |
Learn You a Haskell presents the Caesar Cipher:
The Caesar cipher is a primitive method of encoding messages by
shifting each character in them by a fixed number of positions in the
alphabet
EDIT
Since I'm not limiting this cipher to letters, it's not actually the Caesarian Cipher.
Thanks to Anonymous. This imple... | stackexchange/codereview |
My factory is using method injection because I thought this was the best way to make it so far. Besides, I doubt it is a good thing after having to call on its Create method from within a dependent object.
The only way I might think of whilst continuing to use the parameterized factory Create method, is to inject the d... | stackexchange/codereview |
My code should compare two vectors saved as dictionary (two pickle files) and save the result into a pickle file too. This works but very slowly. For one compare result I'm waiting about 7:20 min. Because I have a lot of videos (exactly 2033) this prog will run about 10 days. This is too long. How can I speed up my cod... | stackexchange/codereview |
This code is to have a dictionary of names and birthdays.
It will ask who's birthday it is that you're looking for. Then if it is in the dictionary, it will print back what that birthday is. If not, it will ask if you want to add it then have you insert the birthday as the value and use the name that you input before a... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.