instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
We have multiple scripts which write into XLSX with the same format, into a different format or slide variation. I am trying to write an API which saves time for other programs, but I need input on restructuring the file.
import openpyxl
from xlsxwriter.workbook import Workbook
class xlsx_extend(object):
"""This c... | stackexchange/codereview |
I wrote this login system in the evening and i would like to know what should I fix / change, if should I use classes and, about readability, if this code is OK.
I'm a begginer in coding so made this small project only for exercising, but good to know wether if i'm things doing right or wrong.
import os.path
credentia... | stackexchange/codereview |
I'm currently doing a project, requiring me to implement a CircularQueue data structure in C++:
template<typename Type> class CircularQueue {
template<typename Type> struct CQNode {
Type head;
CQNode* tail;
CQNode() {
this->head = NULL;
this->tail = NULL;
}
CQNode(Type head, CQNod... | stackexchange/codereview |
This is a simple program meant to show how dynamic JavaFX is. It moves one list item to another and back without having to update the screen directly, thanks to the Observable Collection classes. It also exemplifies how links would work.
In the same vein as Hello parallel world, I practiced and illustrated some ideas w... | stackexchange/codereview |
I have this recursive function that I made which prints a table, but I really think my current solution is really ugly. Does anyone have an idea as to how I can improve my solution?
I'm trying to implement without any variables and with the use of sprintf.
let rec rec n =
if n > 0 then
rec(n-1) + sprintf "\n"+... | stackexchange/codereview |
Right now my route is doing the following:
Searching for the post by id from the request parameters
Check if the user already likes the post
If the user likes the post, then increase likeCount and push user_id to the likes array of the current post and vice versa (dec, pull)
Adding post id to myLikes array of user and... | stackexchange/codereview |
I have a database containing a high amount of data. I want my app to filter and select only some of it, and save it into a CSV file or JSON.
For the moment I have this method which takes the data from the database and puts it in a CSV:
void viewAllCounters (String tableName, long startDate, long endDate, Connection c) ... | stackexchange/codereview |
This is my first attempt at a hash map and I feel it is a great start. Although it does have a certain naive feel that I'm having trouble with.
public class HashMap<TKey, TValue>
{
const int BlockSize = 100000;
const int NumberOfBlocks = 42950;
readonly Entry[][] _blocks = new Entry[NumberOfBlocks][];
... | stackexchange/codereview |
I need to convert my model to fit data in tableview cell finding better approach
My Model
class MyResponseModel {
var question: String = ""
var id: String = ""
var answer: String = ""
//Other variables also but not required to display
init(fromDictionary dictionary: [String:Any]) {
self.qu... | stackexchange/codereview |
I have a sub which should only continue running if 4 specific worksheets are present. From online reading, such as @Tim Williams's comment in Test or check if sheet exists, I know that using an error thrown, to determine a course of action, can be frowned upon, but I found similar usage to mine in both that question an... | stackexchange/codereview |
This code interprets an abstract syntax tree generated by a recursive descent parser for a dynamic scripting language called Hassium. The syntax of this language looks like this
# Recursion functions
func fibonacci(n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
}
return fib... | stackexchange/codereview |
I recently started doing some competitive programming in C and one of my first requirements was a high-speed token reader (analogous to the java Scanner class' next() function). A few examples of input I am most likely to read are:
5
ccadd
bddcc
5 4 1
1 2 5
2 3 7
3 4 8
4 5 2
2 3
The integer/float inputs will be handl... | stackexchange/codereview |
This code animates my main game sprite by increasing the animation frame. First I check if the character is moving, then I increase the animation counter until it reaches the desired speed, and then if so, I increase the animation frame.
How can I make it more elegant and optimised in terms of speed?
if (moving)... | stackexchange/codereview |
I'm currently taking Harvard's CS50 course via EdEx.org, and we're learning about sorting algorithms. More specifically, we're studying bubble, insertion, selection, and merge sorts.
Just for kicks and giggles, I went ahead and decided to write a program that compares all three. Basically, what it does is takes arrays ... | stackexchange/codereview |
I am currently developing a game for Android. One of the things I am working on is moving the map by touch.
This is the code that handles getting speed, which is then added to the screens position and the next update draws the corresponding portion of the map.
@Override
public boolean onTouchEvent(MotionEvent event) {
... | stackexchange/codereview |
For Job shop scheduling, I built a fitness function:
def makespan_timeCalculation(lot_size, RHS, setup_time, processing_time, sequence, mc_op):
machine_assigne_time =[[0 for i in range(mc_op[k])] for k in range(len(mc_op))]
max_c = [0 for i in range(len(lot_size))] # Equal number of job
completion_time... | stackexchange/codereview |
Commenting omitted to give you the idea. I've been toying with this recently as a variant of the Builder pattern. I've recently fallen in love with immutable objects for the benefits they give in larger concurrent systems.
Questions:
Is there a way to do this without having to instantiate two Objects? (ie. Something... | stackexchange/codereview |
I'm pretty sure the script below can be refactored but I'm not sure how to go about it. Assuming I need to make use of inheritances but that's a skill I'm still working on. Any thoughts on how this script can be improved would be greatly appreciated. This is just a snippet of my project - the end goal is to retrieve da... | stackexchange/codereview |
I've got a SQL database that keeps track of which services a client has. I need to create an image using SVG that only displays the services that the client has. The database stores the services in the format 1,2,3,6,7,9. Here's what I have:
<?php
header("Content-type: image/svg+xml");
$db = new PDO(**[reda... | stackexchange/codereview |
This program is for constructing a symbol table where a key is a word and value is the frequency of the word in a text file and finding the word with maximum frequency.
I did it in two ways:
First I used Java's inbuilt TreeMap, which uses a red-black tree as internal data structure.
Then I made my own implementation o... | stackexchange/codereview |
My first Elm program.
Nineagram is a puzzle that appears in the local newspaper. Given the nine letters for the day, the task is to come up with two five-letter words that share the same middle letter.
Example: efiimlrtu has at least one solution of...
f
e
l i m i t
u
r
This program is an aid to the so... | stackexchange/codereview |
So, this is my refactored VM:
public partial class MainPageVM : INotifyPropertyChanged
{
private IThemeProvider _ThemeProvider;
private IStartupVersionProvider _StartupVersionProvider;
private IFontSizeProvider _FontSizeProvider;
public ObservableCollection<MenuItem> Back { get; set; }
public Obser... | stackexchange/codereview |
I have a Python script which parses a complicated CSV generated on election nights. Each row of the CSV represents a race. As I loop through the races, I store the candidates for each race into a list called cnds. The other variable to note is called num_win, and it holds the number of people who will be elected for th... | stackexchange/codereview |
In my OpenCL kernel, I have the following logic:
size_t id = get_global_id(0);
uchar index0 = (id / 32760) % 16;
uchar index1 = (id / 2184) % 15;
uchar index2 = (id / 156) % 14;
uchar index3 = (id / 12) % 13;
uchar index4 = (id / 1) % 12;
if (index1 >= index0)
++index1;
if(index2 >= index0 ||
index2 >= in... | stackexchange/codereview |
I'm consuming some messages from a rabbit queue. Within the consumer/processor I need to invalidate a varnish cache and requeue the message if the purge failed.
I'm using a local purge proxy.
The consumer is a Dropwizard microservice but I'm using a BasicHttpClient because JerseyClient doesn't allow me (AFAIK) to set ... | stackexchange/codereview |
I'd originally not copied the result vector to vec which I figured and corrected. Iis there a better way to implement the merge sort other than the approach I've taken?
template<typename T> void merge(std::vector<T> &vec, int left, int mid, int right )
{
int i=left;
int j=mid+1;
int k=0;
int size = (rig... | stackexchange/codereview |
I made a tic tac toe win checker that represents a 3 x 3 board as a list of list with variables X O B as 'X', 'O' and ' '. However the input can be any valid and invalid board of tic tac toe game.
e.g.
board = [[X,X,X],
[X,X,X],
[O,O,B]]
board = [[X,O,X],
[X,O,X],
[O,O,B]]
I've crea... | stackexchange/codereview |
Let's say you have a simple pure function that applies a discount of 30% if the total price of a list of Items is over 30.00 (let's not delve into the fact that I'm using a Float to indicate the price):
promoGet30PercentOff :: [Item] -> Float
promoGet30PercentOff xs
| total > 30.0 = total * 0.7
| otherwise = tot... | stackexchange/codereview |
This is my second follow-up. Major changes made:
Use a Map instead of an enum for the Morse characters
Added (space) in Morse characters
Added method play() to play the Morse code
Comments are now JavaDoc comments
Moved CHAR_SEPARATOR and WORD_SEPARATOR to the class that contains the Map of characters
MorseString.ja... | stackexchange/codereview |
This is part of a two-part post (Part 2).
Here, I have two recent projects that parse a file. The first uses a loop that's kind of hard to follow, and the second uses "modes" to decide what to do.
Project 1: A "bookmark manager" for managing URLs easier than a text editor.
The data structures:
typedef struct {
cha... | stackexchange/codereview |
Here is my solution:
I want to know if my solution fits the requirement 100%? Or if there is any better solution?
Constraint of the question:
must be singly linkedlist
must use recursion, and no helper methods allowed.
The method must return the head node of the merged list.
class Solution{
Node dummy=new Node(0... | stackexchange/codereview |
I am writing a Swift library. I'm writing unit tests for that library.
I am afraid that some of the code that I am testing will possibly throw exceptions. In Swift, we can handle errors, but we can not handle exceptions. Exceptions are considered programmer errors which should be caught and fixed before release. Th... | stackexchange/codereview |
I use this Bash script to rename specified files to all lowercase letters:
#!/bin/bash
usage() {
test $# = 0 || echo "$@"
echo "Usage: $0 [OPTION]... FILE..."
echo
echo "Rename files to all lowercase letters."
echo
echo " -n, --dry-run Dry run, show what would happen"
echo
echo... | stackexchange/codereview |
I have already asked a question about a dynamic multi threaded lock, and the reviewer found a problem.
Here is the description of the problem that I need to solve:
I need to create a structure to control dynamically created locks. For example, I have 100 threads running, and each thread will "process" a "key". Someti... | stackexchange/codereview |
I wanted to write something that would find all pyramid words within a supplied text file or list of strings. An example of a pyramid word is the word "deadheaded". It has one of the letter "h", two of "a", three of "e", and four of "d".
This would form a pyramid if you were to stack the letters:
h
a a
e e e
... | stackexchange/codereview |
Auto populate user info from database when user inputs employee number. The same applies when the user inputs name/extension/mobile/email/
Some code is duplicated. Is there any way to make it shorter?
$(document).ready(function () {
$("#empnum").change(function () {
var fourdigitpatrn = /^[0-9]{4}$/;
... | stackexchange/codereview |
I'm relatively new to C++ and am trying to learn good programming practices and habits from the beginning. The code I wrote finds the largest common subsequence between to strings (and output the resulting subsequence, not the length of the subsequence).
I was wondering if there were any improvements I could make to ma... | stackexchange/codereview |
I have a function for generating RGB colors in VB6.0, and it is working properly. Please suggest improvements for this, if any.
Public Function RandomRGBColor() As Long
RandomRGBColor = RGB( _
Int(Rnd() * 256), _
Int(Rnd() * 256), _
Int(Rnd() * 256))
End Function
| stackexchange/codereview |
Working code for my image detection script. This is functional code.
I'm loading a number of images into an array, and using two classes to generate the two main components I need for my detection; Vision and WindowCapture.
WindowCapture will grab a cropped section of your primary monitor to run detection on, while any... | stackexchange/codereview |
This is a wrap that queries the number of files and folder from a given directory, also list the folders and files into a vector. I have posted another wrap in this discussion that do the same things and following some really good suggestions I created another this time using filesystem.
The filesystem I used is this i... | stackexchange/codereview |
The task
is taken from LeetCode
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A
mapping of digit to letters (just like on the telephone buttons) is
given below. Note that 1 does not map to any letters.
Example:
Input: "23"
Output: ["a... | stackexchange/codereview |
I have this nifty merge sort implementation for sorting singly-linked lists. Its running time is \$\Theta(n \log n)\$, yet it uses only \$\Theta(\log n)\$ space (the stack). See what I have below.
ListMergesort.java:
package net.coderodde.fun;
import java.util.Random;
/**
* This class contains a method for sorting a... | stackexchange/codereview |
Programming to an interface is a design principle that enhances the flexibility of software by hiding implementation details. Consider an object tree that only exposes an interface, but you want to add additional behaviour that operates on implementation details. A compositional object structure like that exposes an in... | stackexchange/codereview |
I have some methods in my mapper:
public EventDto mapToDto(Event googleEvent, EventDto baseEventDto) {
EventDto eventDto = mapToDto(googleEvent, baseEventDto.getOriginalCalendarId());
eventDto.setCalendarId(baseEventDto.getCalendarId());
eventDto.setCollectiveId(baseEventDto.getCollectiveId());
eventDto... | stackexchange/codereview |
I am just testing out a couple of small classes for learning purposes. Here is my current working code:
class Permutation:
'''An int list a permutation if starting at any index, one can reach every other index by
repeated index accesses. The list [4, 0, 3, 1, 2] is a permutation: for example index 0
stor... | stackexchange/codereview |
About this exercise
I found out there is a form of strict types in PHP 7.4, so I freshened up my PHP coding with this simple Address class. I did not use PHP since forever. So, any and all answers and comments highly appreciated. (This question is an update on its deleted version; only users with reputation above 10k t... | stackexchange/codereview |
I am tring to count the number of exceptions happening and log those exceptions as well. So what I did is, I created one method addException in which I am counting all the exceptions.
addException method accepts two parameters, one is the String, and other is the boolean flag which means whether we want to terminate t... | stackexchange/codereview |
I have a Numpy function that takes the values of an existing array X and a size (int) k equivalent to the columns of the array. This function does some calculations in a new array, to finally output the new array after the calculations are done.
def ff(x, k):
newarr = np.zeros((x.shape[0], 1), dtype=np.uint32)
... | stackexchange/codereview |
I have recently made significant progress in overcoming beginner barriers related to using Git, CMake, libraries, and successfully implementing an API in C++. Despite my achievements, I acknowledge that there is room for improvement and would greatly appreciate someone's opinion on my code. As a beginner, I am open to ... | stackexchange/codereview |
I have created a non-owning view of some spatial data that organises the data into cells. The data is split into a grid of cell size 100, and the key to the underlying HashMap is the index (top left corner) of the grid cell. Each grid cell contains a Vec of Point2D.
The purpose of this data structure is for efficient ... | stackexchange/codereview |
I have this code that controls the user permissions provided to a user. In my case, I constructed a simple example of CRUD. When the admin checks the boxes, it will grant the user access to perform that operation. For example, if I provide the user the ability to create, they can do so.
The code works but I believe the... | stackexchange/codereview |
I have this method, which first basically shows a Welcome screen to user only once per day. The code I have so far is this
private func showGreetingScreen (tabbar: UITabBarController) {
let defaults = UserDefaults.standard
if defaults.object(forKey: "greetingDate") == nil {
defaults.set(Date(), forKey: ... | stackexchange/codereview |
Recently I was learning to code using PyQt5 and Python.
I was doing a school project on Calculator.
Here is my graphic class:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'calculator.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file wil... | stackexchange/codereview |
I want to use the output of the terminal command ldd:
root@kali-vm:~/Desktop# ldd simple
linux-gate.so.1 => (0xb7722000)
libcurl-gnutls.so.4 => /usr/lib/i386-linux-gnu/libcurl-gnutls.so.4 (0xb769c000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7539000)
libidn.so.11 => /usr/lib/i386-linux-... | stackexchange/codereview |
This is my implementation of a Tic Tac Toe game with Tkinter GUI. So far I've set up the game to play with another player. For an interview coming up, I am suppose to build additional feature such as play with AI.
I would like some general feedback on my code. Does my code smell? Can I organize the Player, Board... | stackexchange/codereview |
I just finished this Merge Sort in Clojure, structured according to ex. 22-26 of this workshop.
The main question I have can be answered without spending time understanding the code: halve is called twice in merge-sort, is this still \$\mathcal{O}(n \log n)\$? (last lines in the code sample) Since it's functional progr... | stackexchange/codereview |
I decided to make my own data structure. I did this because I wanted a data structure that is a queue but has o(1) time on lookup.
template <class Object>
class ObjectQueue;
template <class Object>
class ObjectQueueNode: private NonCopyable
{
friend class ObjectQueue<Object>;
public:
ObjectQueueNode(const... | stackexchange/codereview |
I've written some utilities to read text from streams. One of these, the ReadTo method, is to read text from a specified stream until a given text is encountered, behaving like string.IndexOf, but with streams.
Really, it's quite fast. But I'd like to know if anyone knows any way to make it even faster, as it's used in... | stackexchange/codereview |
This is not the latest question in iterative code review of this program. You can find the latest answer here.
Here's my solution to Project Euler #54. Click the link for the full project description (abbreviated here):
The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the fi... | stackexchange/codereview |
I'm new to writing bash scripts and was wondering if I could get someone's advice on a part of the script I'm working on.
Intended purpose of code
Check if a package exists using dpkg, and if it doesn't, offer to install it for the user. This snippet is part of a larger script that installs a particular Conky configura... | stackexchange/codereview |
Here the demo
The code below creates a background-image over a background-color with different opacities for each element. Is there a cleaner way of achieving this?
.component{
min-height: 100vh;
min-width:100vw;
font-size:5em;
display:flex;
justify-content: center;
align-items: center;
color:black;
}
.... | stackexchange/codereview |
I was practicing divide-two-integers question from leetcode
Question: Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.
Return the quotient after dividing dividend by divisor.
The integer division should truncate toward zero.
Question Link: https://le... | stackexchange/codereview |
This is a programming question from LeetCode:
Given a string s, return the longest palindromic substring in s.
Example 1:
Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer.
Below is my code that fails the following input because of "Time Limit Exceeded":
"glwhcebdjbdroiurzfxxrbhzibilmcfasshhtyngwrs... | stackexchange/codereview |
I am reading Cracking the Code Interview and I am getting a bit confused at the bit using 'previous'. In this problem, the method deletes duplicate nodes in a Linked List.
My assumption is that head is used to scan through the linked list while previous is used to update the linked list head because previous points to... | stackexchange/codereview |
I've written a class that allows me to easily create sprites on the screen, and then do things like: setting an image or an animation; move the sprite as a platformer or as a top down game; and test for many things like collision and orientation. So far I've found this to be very useful, and it has made it really easy ... | stackexchange/codereview |
The other day I ran into this question on stackoverflow.
Just for curiosity I wanted to implement suspending and resuming the thread, so I used signals and used pause() in the signal handler.
Is it OK to use this way? This question has many answers how to suspend/resume a thread, but I want to know what is wrong with m... | stackexchange/codereview |
I want to check a string by using multiple search patterns and split the string at every occurrence. I'm using RegEx and it works fine. But I'm worrying about efficiency and performance.
struct StringPart {
let text : String
var matched : Int // index of pattern
let pos : Int
init(searchText: ... | stackexchange/codereview |
I am using jQuery to implement a basic quiz functionality. How can I improve this code snippet even more? Is there any better way of doing it?
I am using jQuery 1.6.4.
/*jshint -W065 */
$(function () {
var jQuiz = {
answers: {
q1: 'd',
q2: 'd',
q3: 'a',
q4: 'c... | stackexchange/codereview |
For practice purpose, I wrote bubble sort in C++ two styles: C-ish and modern C++ compliant. I would like to have your comments on any point on these implementations.
Sorting.h
#ifndef SORTING_ALGORITHMS_H
#define SORTING_ALGORITHMS_H
#include <utility>
#include <vector>
//#include <iterator>
#include <algorithm>
na... | stackexchange/codereview |
I am trying to use a custom sql query to display different attributes for a product i.e. Size and Price. The query I have when running in console displays as it should
SELECT products.id, products.name, variant_properties.description, LEFT(variant_properties.description,1) as short_desc, variants.price FROM products
... | stackexchange/codereview |
I decided to create simple blog app by using Ember.js which should has the following interface
For this purpose I created blog route which contain the following code:
import Ember from 'ember';
export default Ember.Route.extend({
setupController: function (controller, model) {
controller.set('currentPost', 0);
... | stackexchange/codereview |
I'm looking for any feedback in order to improve code styling, performance etc.
Also I want to make sure that the way I've implemented AES here is actually secure
import os
import hashlib
import sys
import base64
from cryptography.fernet import Fernet
class Cryptor:
def __init__(self, password):
self.__pa... | stackexchange/codereview |
I have a vector of uint16_t and I want to check if there is a bit which is only set in one vector. I then get its position within the vector as well as from the bit.
Let's say we have:
v[0] = 0100
v[1] = 0110
v[2] = 1001
I would like to know that ind = 1 and val = 2.
In clumsy code this would be like that:
#include ... | stackexchange/codereview |
I have a vector of values vals, a same-dimension vector of frequencies freqs, and a set of frequency values pins.
I need to find the max values of vals within the corresponding interval around each pin (from pin-1 to pin+1). However, the intervals merge if they overlap (e.g., [1,2] and [0.5,1.5] become [0.5,2]).
I have... | stackexchange/codereview |
A recent question inspired me to write a script for this task:
Shorten URLs in specified text files using googleapis.com
Handle multiple URLs, whether on the same line or multiple lines
The original question tried to do this in Bash, but it gets quite tricky when it comes to handling multiple URLs, so I decided to re... | stackexchange/codereview |
I'm playing a bit with extensions for default protocols in Swift 3.0.
I would like to implement rounded(toPlaces places: Int) -> Self for Double, Float.
Both of these structs refer to FloatingType protocol.
I wrote small extension for FloatingType protocol:
extension FloatingPoint {
typealias Exponent = Int // is... | stackexchange/codereview |
I created an helper method to return a List of UIElements where the returned elements have to match with one of the Types which I pass to the method.
First I used this method to get all the children of one type:
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject dependencyObj) where T : DependencyObj... | stackexchange/codereview |
I am using jQuery data Tables server processing to show some data to user. The documentation instructs that the response that the server sends must have this data:
recordsTotal
recordsFiltered
data
when I am trying to provide this data, I have to query the database 3 times! One for total document count, once for filt... | stackexchange/codereview |
While looking at PHP.net this afternoon, I saw a comment in round() for two functions for rounding UP and DOWN (as opposed to just HALF_UP and DOWN). I liked the suggestion, but wanted a solution that was one function instead of 3, so I came up with the following:
define('PHP_ROUND_UP', 11);
define('PHP_ROUND_DOWN',... | stackexchange/codereview |
I am a beginner working on a code project. I'm simply trying to make my program multiply a user's input by a constant, however when I run the program I only get 0 as a result.
sorry this is a basic question, I just can't find a solution anywhere else.
int main() {
double quanity, result;
const double USD = 0.81;
res... | stackexchange/codereview |
In my program I read values from a configuration array.
First I just used magic constants like this:
private $config = array(
'ignoreWarnings' => true,
);
private function ignoreWarnings()
{
if (is_bool($this->config['ignoreWarnings']) === false) {
throw new Exception(sprintf('Invalid "%s" config value... | stackexchange/codereview |
I'm learning python (started about 30 hours ago) and my son asked if I could make a hangman game. Well, okay, I'll give that a try. I'm sure this code is crap, but I'll never learn if I don't ask how I could have done this better. Anything that's poor practice or doesn't scale? (I won't ask what's sloppy - it's all... | stackexchange/codereview |
Today I didn't pass the test task for the position C++ junior/middle developer. What i did wrong?
Please help improve myself.
Task:
Description.
Write a template class - an array of any type of data, and tests to
demonstrate the work with this class. Should be implemented all the
methods also acceptable to exten... | stackexchange/codereview |
I am implementing a simulation of colliding disks (ideal 2D billiard balls) in JavaScript.
I follow an event-driven algorithm that avoids discretizing time; the algorithm goes as follows at each step:
Compute the moment of the next collision (with walls or between two disks)
Translate the spheres during that time inte... | stackexchange/codereview |
I often use a similar scheme work with an API project. Can it be made easier, or is there a standard approach?
This class creates an API request:
public class ApiRequestCreator {
private static String TEST_API_REQUEST = "http://jsonplaceholder.typicode.com/posts";
public static Request createTestApiRequest(... | stackexchange/codereview |
I am using the book "Realm of Racket" which was written by the people behind the Racket and Dr. Racket projects. It is a great book based on games, similar to the famous "Land of Lisp".
The first game we are supposed to code is the classic "Guess My Number". Following the instructions on the book you end up with this c... | stackexchange/codereview |
This problem:
The Shallow Alto city council has organized a special committee to review the traffic situation in the city. Despite the fact that there is nothing whatsoever to do in the city, citizens still write complaints about the amount of time it takes them to get from one unexciting location to the next. The com... | stackexchange/codereview |
I am developing a project (which purpose is not relevant for this question) where I have a class responsible for retrieving a list of running Windows processes. The implementation will basically use the System.Diagnostics.Process.GetProcesses() call but I want to abstract that, so I don't have the call of that static m... | stackexchange/codereview |
I have to construct a URL string from smaller substrings. I'll usually have a resource url, an endpoint, a query, but you can imagine even more parts in creating a full URL.
If, for example, I have this resource URL: http://foo.com, this endpoint: bar/v1, and this query: q?var1=33,var2='abc', I expect the final URL to ... | stackexchange/codereview |
I'm learning Lua for about a week now and I've built (I hope) a function to print any type in Lua. As I'm new to Lua I don't quite understand:
if there is a more succinct way to achieve this
if there is a standard way to print nested tables
if there are any cases the function doesn't cover
function printAnyLuaType(A... | stackexchange/codereview |
I am trying to perform the basic operations + with CUDA for GPU computation. The function vectorIncreaseOne is the instance for the operation details and gpuIncreaseOne function is the structure for applying the operation to each element in the parameter data_for_calculation.
The experimental implementation
The experim... | stackexchange/codereview |
Just wanted some code review for correctness here. This is a little app for plotting newborn feeding data (important to keep track of in the first 48 hours of so) that I hope to provide to a clinic, but I wanted some extra eyes on it if possible before doing so (important to get this right!). We have the times of the ... | stackexchange/codereview |
I'm trying to increase the performance of my N Queens Puzzle solution. I'd find some threads on SO already but they don't appear to help me to increase performance.
My best solution, however, is a strategy with a constant amount of working threads. I also tried to implement a solution with RecursiveTasks. But it appear... | stackexchange/codereview |
I am learning Node.js and I would like to see if I'm using it correctly:
var mysql = require('mysql');
var fs = require('fs');
var connectionProps = JSON.parse(fs.readFileSync('connection.json', 'utf8'));
var connection = mysql.createConnection({
host: connectionProps.host,
user: connectionProps.user,
password:... | stackexchange/codereview |
I have built a small tkinter program that I want to have a few different themes it can change between. In order to dynamically change the colours/font for each widget I have subclassed tkinter, and I am just wondering if there is any smarter way of doing this? I am aware that ttk can do something similar, but then as I... | stackexchange/codereview |
To help my son with his programming skills, I am trying refresh my limited Python knowledge. I chose a simple dice game called Pig Dice.
import sys
import random
HUMAN = 0
COMPUTER = 1
HOLD = False
ROLL = True
class Die:
def __init__(self):
self.value = random.randint(1, 6)
def roll(self):
s... | stackexchange/codereview |
I have the implementation of A* search algorithm that allows to find the shortest path from start to goal.
The implementation looks like this
public class AStarShortestPathContext {
private Vertex[][] matrix;
private int rows, columns;
private int cost;
private PriorityQueue<Vertex> openList;
priva... | stackexchange/codereview |
I have a package directory pkg with several classes that I would like to build into a convenient dict property.
The structure of pkg/ looks like:
pkg/base.py:
class _MyBase(object):
pass
pkg/foo.py:
from .base import _MyBase
class Foo(_MyBase):
pass
And in pkg/__init__.py, it is a bit clunky, but once pkg i... | stackexchange/codereview |
This is part of a SDK for interacting with Communicator's SOAP api.
The aim is that the user will not have to interact with SOAP (some people complain about it).
Please note that the wired capitalisation on some properties are intentional and are required for correct conversion to a SOAP request.
I would especially lik... | stackexchange/codereview |
My code will generate a spelling mistake inside of a string 50% of the time.
It will retrieve a letter from a random index in the string like, "t" and then duplicate that letter like, "tt" and store it in the spelling mistake variable.
It will then replace, "t" with "tt" in the string to replicate a spelling mistake. (... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.