instruction
stringlengths
71
71.9k
This is a simple repository where I want to save all the invoices of some queried users. I wanted this module to only expose a simple saveInvoices method and return a Promise. As a DB, I use Firebase whose API is async but does not return standard JS promises so I promisify the db queries. I haven't yet taken every re...
Inspired by this question in chat Is there an easy way in .NET to split a string into an array by pulling chunks of the text in. I.e. I have an 18 character string I would like in 3 6-character pieces. I thought that ain't be that hard. I would like to get any thoughts and improvements you can think of. public st...
My task: Write nested for loops to produce the following output with each line 48 characters wide: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~ +~++~++~++~++~++~++~++~++~++~++~++~++~++~++~++~+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is my idea...
I made a custom encryption library/class which allows to en-/decrypt Strings with a custom charset. I think you'll get what I mean with that when you take a look at the code. Since I haven't much cryptography knowledge, I'd like to ask if someone who knows about it could tell me if this is "safe". I know nothing is 100...
Related to the question Verb conjugator for French, I was asked an question on whether one could summarize all the $exceptionIs<NAME_OF_EXCEPTION> = $exceptionmodel-> getValue() === ExceptionModel::NAME_OF_EXCEPTION lines. In other words, can one make dynamic variables out of the comparison of a value combined with all...
As an exercise, I wanted to make an array implementation of Stack, including most of the methods from the native Java Stack. I'd like to know the following: Does the code follow good programming principles? Is the code readable/understandable? Are there any redundant fields/operations? Is there a way to further impro...
up moves N directories above the current directory (executes "cd .."" N times) When executed without input values it moves only one directory above the current directory When executed with input values, up uses the first input value (checking to see if it is a positive integer)to move above the current directory the...
I have an app that makes calls to the Podio API. The Podio Api uses OAuth2 protocol , after user's authenticate with their podio username and password an access and refresh token is provided for subsequent requests. Podio has a Javascript SDK that handles authentication and API calls. I wrote a simple Session Manager u...
It is common to shorten city names when writing, or at least in Sweden. "Göteborg" (Gothenburg) is often referred to as "Gbg" "Uddevalla" is commonly written as "Ua" "Trollhättan" is often written as "Thn" ...and a whole lot of other city names are often shortened "Uddevalla" could also be shortened as "Uva", "Uvalla...
Write a function Int -> Char -> Char -> [String] that will create the appropriate pattern. For example: mapM_ putStrLn (pattern 48 '.' '+') ................................................ .+..+..+..+..+..+..+..+..+..+..+..+..+..+..+..+. +.++.++.++.++.++.++.++.++.++.++.++.++.++.++.++.+ ..................................
A while ago, I found a somewhat interesting sorting algorithm named Exact-Sort, which is introduced with the following somewhat bold claim: No sort algorithm can sort an array with less position changing (relocating) than Exact-Sort. While the claim is perhaps not as impressive as the fact that the website is still h...
This is quite final code of a script. It looks to me a little messy ad repetitive. What can I do to improve it? jQuery(function($) { 'use strict'; /* * This Object calls a editor based * on the choice of a radio input */ var wiz_ajax = { callUrl : setup.ajax_url, ...
Based on my previous question, I have implemented all the recommendations received. Here is a summary of the improvements: Use meaningful names as much as possible. Removed multiple declarations in one line. Removed the dynamic_casts and applied a new class hierarchy design. Added a Game class to improve code modulari...
Follow-up to: Brainfuck Interpreter: Slower than a Snail? Many improvements have been added, including: Remembering where the matching [ and ] is Combining +s, -s, <s, and >s into groups Providing the option to not optimize the code I have no idea how to use JUnit to test on the output, so I stuck with Main.java: pub...
So, this is my first web scraper (or part of it at least) and looking for things that I may have done wrong, or things that could be improved so I can learn from my mistakes. I made a few short function that can take a user and search tpb to get the maximum number of pages of content that that user has by requesting th...
Inspired by this question, I wrote a program in Whitespace to output the following text: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~~+~ +~++~++~++~++~++~++~++~++~++~++~++~++~++~++~++~+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I left comments in the sour...
Here is an implementation I pieced together from various papers on the subject. It took a lot of fiddling to get it to run at all. My ideas for better performance and readability, based on looking at other GMP examples: Always pass by reference and never return any "large type" Separate matrix Gaussian elimination fr...
I have written a program to perform a task, but I'm guessing it is not optimized. I want to know if there are any ways to improve the effiency and performance of this program. This program reads a set of .gz files from a directory, parses each file, inserts the filtered content into another .xml file in the results di...
From this question, I do know that initialization list and in-class initialization are different things. The class in the following code has members with in-class initializers and those initialized in initialization list in constructors: class Bamboo { public: int a = {0}; int b; Bamboo() :a(3), b(12) { ...
I have two riscProfileTypeIds (both of type uniqueidentifier) of which I need the one with the highest sequence number (the highest of the two risc profiles, at business level). The below query does the job, but I'm not very happy with the union, I wonder if there's a way to do the same without it. SELECT [ID] FROM [Ri...
Is this good way to create a get API method with different service methods? Based on the scope parameter, it decides what service method in the API to call. Enum: enum scopeValue { None, GetAll, GetWithDetails }; API: public class WorkItemController : BaseController ...
(See the next iteration.) From time to time, while working with a command line in *nix family of operating systems, we have to write those scripts doing a rather specific task. Usually we use bash + utility programs to do the job. However, I had to ask myself: how to implement such a script in C? After an invocation of...
This function is working exactly as I want, only, it's taking too long. For speed ups, I've tried to do as much as I can before the main for loop by declaring each function as a local variable, I've also switched from using pandas dataframes to numpy arrays and decreased the outputted dpi. This function is being fed l...
Inspired by this question: Split a string into chunks of the same length The code is designed to work on text elements rather than chars to avoid unicode problems. public static class StringExtensions { public static IEnumerable<string> Partition(this string value, int chunkSize) { if (value == null) ...
If you are wondering why I ask, it is because I have numerous different methods all with very similar code (the only difference in the code in each method is what is between the generate resultset comments). I have tried any amount of times to try and shorten this but I am out of ideas. What I have been trying to get i...
The point of this code is to build an ip from a list of type ushort. var ip = new StringBuilder(); List<ushort> ipList = new List<ushort>(4) {192, 168, 1, 1}; ipList.ToList().ForEach(x => ip.Append(x + ".")); return ip.Remove(ip.Length - 1, 1).ToString(); The code works and outputs an ip as expected, but the formatt...
I am using reflection to check if a private variable is set to null after the logout function. This is needed because the getUser function will always attempt to set and return an user if no user is set. Am I doing something wrong or can I do something better? This is the bean that has the logout and getUser function: ...
I wrote a python script that converts English to Entean language from an anime called "The Devil is a part timer". This is the second version of the script which was first posted here Translating from English to Entean. This version is compatible with both Python 2 and 3.This version uses the str.maketrans method which...
Motivation I have found on occasion that I have needed to safely increment/decrement iterators by ensuring they are within some bounded range. After reading through some implementations (SO, Boost Summer code) and a proposal, I found that most of these "safe" functions did not handle the case where a negative differen...
i made a simple js snake game with canvas, the code is all mine so it can have some drawbacks or not so good parts. I will be glad to hear some opinions. https://github.com/vitaliyterziev/snake var Poly = { //polyfill Set() set: function (array) { 'use strict'; var cleanList = []; var ...
Could you please review the below AngularJS service. What it does is centralize all (relevant) HTTP action calls. Do you see any chances for improvement?: "use strict"; angular.module("services.api") .factory("apiService", [ "$http", "$q", "coreUtilityService", "constantsServiceName...
So I recently had a practical exam in which I was told to execute a function of a menu oriented matrix operation program using classes. The code I made was supposedly wrong as I hadn't used classes the way they have to be used. Can anybody help me rectify the error here. I'm a noob (less than 2 months into C++) so plea...
I have code that is used to add all cells of a tab to a var: #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <malloc.h> #define NB 10000 // Instruction RDTSC du Pentium static __inline__ unsigned long long RDTSC(void) { unsigned hi, lo; __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d...
I needed a script to wrap phrases with tag, they all are separated by commas, for i.e "Alan, Bob, John". I came to this result: $actors = explode(',', $item->casting); $item->casting = array_map(function($a) { $a = trim($a); return '<a href="'.$a.'">'.$a.'</a>'; }, $act...
WE_ALL_LOVE_SHOUTY_SNAKE_CASE_SO_I_WROTE_A_PROGRAM_FOR_IT!!1! Alright, enough of this. This is a rags-to-riches from this question. The pattern is pretty simple, it takes a String input, verifies if it is numerical, and if so, converts it to SHOUTY_SNAKE_CASE. Example : "1231" -> "ONE_TWO_THREE_ONE" It is fairly simp...
I'm currently building some HTML with JS (specifically using the jQuery library). My code is as follows: goToError: function (error, returnView, returnController, callback) { console.log(error); this._transitionOutPanel(function () { loadError(); }); var loadError = function () { $("#p...
I have a factory method that should accept a list of coordinate lists, which are pairs of numbers, for example [[(2,4),(3,3),(2,4)],[(6,6),(7,6),(7,7),(6,7),(6,6)]]. I'd like to make sure the input is indeed in this format, but without specifying the types of sequences (might be lists, tuples, numpy arrays, and mixture...
I'm doing a comparison of Erlang, Haskell, Elixir and ES6, and I'm less farmiliar with Erlang and Elixir, but I want to represent all of these languages fairly, so is this good Erlang code? -module(mapreduce). -export([map_reduce/1]). add_to_key(KV, Sum) -> {Key, Value} = KV, Tmp = proplists:get...
The main body of code is located here. In the code linted_error is a platform specific type for error codes. As well, as an optimization the code can use Linux futexes. linted/mem.h is just a tiny wrapper around malloc. linted/sched.h does a bunch of stuff but is only used in this code to wrap platform specific pause ...
This is one of the (many) utilitarian classes I have that I use with my ASP.NET sites. The basis of this one is to make gathering certain tokens that I use periodically, to make URL's more friendly. It's pretty simple, and should be quite obvious. I use it to make URL's a little more friendly. (/Id/SomeKey/SomeValue/Ot...
I am an experienced Java developer (12+ years) and have recently switched to Scala and I love it. However I feel not comfy yet and I have a feeling that I might use to many paradigms from the good old Java days. That's why I would like to start with some simple code I wrote while viewing a Stanford Seminar on Youtube w...
I have a units of measure library that I added string formatting to. Here is sample code: [Test] public void FormatSpeed() { var speed = Speed.FromMetresPerSecond(1.2); using (Thread.CurrentThread.UsingTempCulture(CultureInfo.InvariantCulture)) { Assert.AreEqual("1.20\u00A0m/s", speed.ToString("F2")...
I write a simple php login class that only operate on php sessions to login user in the system. My Question is that this class is secure enough to be used on production environment ? NOTE : Die Statements are used only for testing of scripts class.login.inc.php class Login { //setSessionFunction sets a login session ...
today I tried to code all the dictionary operations such as Search, Successor, Predecessor, Minimum, Maximum, Insert, Delete etc. for a Binary Search Tree data structure using the Java programming language. I would be grateful to you guys if you can review my code and suggest me some cool tricks as to how to optimize m...
I was inspired by Processing a list to build an IP in String Format to reinvent the wheel a little bit and play around with explicit struct layouts. You see, an IP address is really made up of four, 1-byte numbers. Each Octet of an IP address is one byte. So, this means that an IP address can be represented by either...
I've written a program that takes a mathematical formula as an user input and converts it from infix to postfix. It doesn't support negative numbers. The program doesn't depend on the user having to pay attention on how to use spaces, so '1+2*3' and '1 + 2 * 3' are the same. (formulas like 'x^2^3' however must be writt...
My code finds the best match between a private company and a listed company based on 3 ratios in order to report the ratio4 from the listed to the private company. In order to do that first, I do the percentile of the ratio1 of listed company (as it is the most important). Secondly, I check in which percentile the val...
I've created a Combobox GUI that allows the user to search through the Combobox by entering a letter on the keyboard. If user enter letter 'L' it will search through the Combobox drop-down list for the first occurrence of a word that starts with letter 'L'. Please let me know if I could have made my findInBox method be...
I am trying to implement the Multiple Producer-Consumer problem. I have made the buffer as the lock to maintain consistency of the system. Does this system actually implement multithreading? How can I improve the system using wait and notify? Producer.java import java.util.*; import java.io.*; class Producer extends T...
This function receives an HTMLElement as an argument and returns true if the tag is on the screen and false otherwise. function isTagVisible(tag) { var box; box = tag.getBoundingClientRect(); if (box.left > 0) { if (box.left >= window.innerWidth) { return false; } } if...
I have written a wrapper for Java's Iterator class using Java 7, which is designed to only iterate items that match a certain filter. When the filter is null, all items should be iterated. Filter.java public interface Filter<T> { boolean apply(T type); } FilteredIterator.java import java.util.Iterator; public cla...
I have written a program to evaluate a postfix expression using a stack. I had my stack implementation using a linked list reviewed here, so I am only including the header file here. I have taken the postfix expression in form of a string where the operators and operands are delimited by spaces and have used a sentine...
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; using System.Data.SqlClient; using System.Data; namespace ExamManagement.DLL { public class SQLDataAccessHelper { string connectionString=string.Empty; public SQLDataAccessHelper()...
Update I've posted a follow up question to this code. Find it here: Not a very interesting implementation of a Simple Substitution Cipher in Python. I implemented a second encryption algorithm: the well known caesar-cipher. This turned out to be longer than I expected. The "main" code is very concise, but the interfac...
See the initial/previous iteration. I have rewritten the script following the answer of @200_success. Now it looks like this: #! /bin/bash # Create a temporary file name for the executable file: TMP_PROGRAM_FILE="$(mktemp programXXXXXX)" # Compile the embedded C program: gcc -o "$TMP_PROGRAM_FILE" -x c - <<- END_OF_...
I have a "Like" button in my iOS app that updates the votes every time it's tapped. Just like Facebook, Instagram, ProductHunt, etc. I have a custom cell where that IBAction and IBOutlet is declared and that's where I'm making the query to the Parse db to update the UI (initially I'm querying the vote values from the ...
I'm trying out different sorting algorithms for learning purposes, here I'm doing a "type-agnostic" bubbleaort. I modeled the function signature after the standard library's qsort. I know the bubblesort algorithm in general is not that fast, but I'm looking for a review in particular about the memory management. In my ...
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...
I am learning Ruby programming from "Learn Ruby the Hard way" and I am doing the "Ruby koans". I have heard a little bit about "Idiomatic" Ruby but I don't know much about it. How can I make it more idiomatic? # Program to solve polynomials def solve(coeff) coefficients = [] coeff.each{ |a| coefficient...
I have to create a batch process which reads data from DB , process it and saves it in db . The batch data is fetched organization wise ( each organization has set of data to be processed) at once.We need to process only specific set of data i.e organization related and save it into db. Hence i have designed below clas...
I have developed a simple and easy to use JavaScript library called, Omega for practice. I would highly appreciate if you can point out all sorts of flaws in the code such as violations of best practices, conventions and even would highly prefer optimization tips or other better ways of achieving what I did. Here's the...
I wanted to write a function that when applied to another would rate limit it, but permit all calls to eventually make it through. Comments and criticism welcome. var MAX_RUNS_PER_WINDOW = 10; var RUN_WINDOW = 1000; function limit(fn) { var callQueue = [], invokeTimes = Object.create(circularQueue), ...
I have a class that is used to basically store samples from data being read from a system. Within that class is a property that I use to store the date and time of that sample: public class ReadingValue { public DateTime DateTimeOfReading { get; set; } public float Reading { get; set; } } I need to sort a list...
I created a simple 2D game that I made for myself in C++ with SDL2.0 + OpenGL + Box2D, but I'm insecure about the code and structure because I developed the game using everything I've learned on the Internet and not following some pattern. I posted the code on GitHub and I'm spreading it on some forums to get feedback ...
So again I modified my last posted code as other fellow friends said me. So please review and let me know what more modifications and optimisation I can do in This code now. Previous Post Spreadsheet Manipulations in Single Procedure I have written VBA code to copy and do some formatting and create sheets based on uni...
Summary Original Question here. Updated GitHub link here I've taken an interest in lower level data structures and I implemented an 'Ip4Address` to get familiar with Explicit structure layout. It turned out to be an exercise in properly implementing a struct in general, but I digress. The idea here is that each Octet o...
This is my implantation of counting sort, but I see myself using way too many for loops. Is this necessary? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { public static int[] a = { 0,0,0,5,4,8,9,9,7,3, 3, 2, 1 };...
I got tired of running the same command in multiple directories, so I thought "there has to be a way to make this easier". The commands I was running was mostly git status, git stash list, hg summary, mvn clean test, and so on and so on... So what I did was to create a bash script that you can pass a parameter to. It w...
I wrote a little C++ sorting routine for my Algorithm studies, but I feel that a lot can be skipped out. I am aware that modern sort takes Iterators and comparator functions, let's disregard that for now. I just want to clean up this code. Specifically, I don't like the if and value variables. I have looked into other ...
The complete problem definition can be summarized as "find the largest sum of for paths from the top to the bottom of a triangle of integers". I decided to read the triangle in from a file which can be found here. My solution #!/usr/bin/python """chicks' answer to Euler Project problem #18""" import sys import string...
Write a function that given a max argument will print a nicely aligned multiplication tables, for example, if max = 8 1 2 3 4 5 6 7 8 2 4 6 8 10 12 14 16 3 6 9 12 15 18 21 24 4 8 12 16 20 24 28 32 5 10 15 20 25 30 35 40 6 12 18 24 30 36 42 48 7 14 ...
I am setting the sum total of all the items in an array to a text view in android.The values contained in the array are all currency values. @Override public void afterTextChanged(Editable s) { int id = 0; id = (int) itemtotal.getTag(); String itemTot = itemtotal.getText()....
I have a very simple app which removes buttons and re-adds buttons to certain layouts when a button is clicked. The problem is this process is taking a very long time. How do I speed this process up? red.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { ...
I just coded method for loading data from SqLite 3 database, it is working and in test run it was successfully checked for no memory leaks: template<typename T> inline std::vector<T> Database::fill_from_table(const std::string& table_name, const std::vector<std::pair<std::string, void(*)(T &, char *)>>& setters, int64_...
The problem is to divide a list into n parts according to a predicate. I found recursive solution but I am sure that a more elegant solution also exists. def repeatedSpan[T](col: Iterable[T], pred: T => Boolean): List[Iterable[T]] = { if (col.isEmpty) Nil else { val (a, b) = col.span(pred) if (a.isEmpty) b....
Based on my previous question, I have implemented all the recommendations received. In addition, i have implemented new features and completed road geometries. Here is a summary of the improvements: Rewritten the Colors class again instead of old class which is used hierarchy design. Added curve for the road Added hil...
I'm initializing a class in JavaScript with a bunch of complex property checks. Codacy is showing that this is bad design and recommends reducing cyclomatic complexity. I'm at a loss for how to improve/streamline this, though. var ok = require('objectkit') var UsergridClient = function(opts) { var self = this ...
This is the first webpage I've ever made, besides simplified tests. My goal was to have a navigation menu on the left, an image in the top left corner with a header to its right, and a block of text in the main body. It's mostly what I had in my head, but there are a few things about it that I don't like: The centerin...
Now, a while ago, I said in chat: I'm done with BF programming. Except I guess I was lying. Here's a Brainfuck program I wrote, that prints out the multiplication tables up to 12. Fairly simple; what it does: Loops through 1-12; let's say the current value we are at is x Loop 12 times, adding x each time, and print...
I am making an ArrayList that contains Map values. itemData is my ArrayList that contains itemselected, which is a map. Then, because I want to send this array to my PHP code, I am converting itemData into a JSONArray. Then parsing the array in my PHP script and inserting those individual values into a MySQL database. ...
I've been trying to learn Java and one way I've been teaching myself is by tackling "programming challenge questions". One such question is "reverse the character order of words in a string". For example, " I have a hat " => " I evah a tah " (note the spaces). In my implementation, I don't deal with punctuation...
I have written a program to find prime numbers up to a given limit using wheel factorization of 2, 3 and 5. I would like it to work above \$10^{10}\$, but its still pretty slow. What else can I optimize here. Any way I can parallelize it? I am pretty sure markNonPrimes's algorithm is less efficient than it should be....
How should I go about creating a registration page in Windows forms? I can easily create a registration page, but I'm not sure if it's the best way. I'd have a service account that is hard coded, and it creates entries in a user table. I don't like to hard code passwords, but I don't know of another way. I guess in eve...
I've written a small Service class that contains a thread pool so that it can process multiple tasks in parallel. The kicker is that is also allows clients to bind to the service and automatically exits when there are no more tasks to run and there are no more bound clients. Some questions I have are: Am I abusing the...
I have programmed a simple command line password-manager in Node.js during my learning process, and since I am done with it, I would highly appreciate a review. Comments could be based on any topic. I am looking for a review which covers: Security flaws. Performance and Efficiency. Better ways to achieve this. Violat...
Comb sort may be thought of as a generalization of bubble sort. The following is my implementation: package net.coderodde.util.sorting; import java.util.Arrays; import java.util.Comparator; import java.util.Random; /** * This class implements * <a href="https://en.wikipedia.org/wiki/Comb_sort">Comb sort</a>. * ...
I want to show you how to implement variant like boost::variant, but almost for constexpr, not runtime: #include <type_traits> #include <utility> template< std::size_t i > using I = std::integral_constant< std::size_t, i >; template< std::size_t i > struct index : I< i > {}; template< bool ...b > struct get_i; templ...
I am running a simple Python webserver to toggle a GPIO pin on a Raspberry Pi. All seems to work well, but I have a few questions about my code (see below). I am using the urlparse module to obtain the URL arguments. The HTML file just sends out Ajax requests using buttons when clicked. I've commented out the send_res...
I needed a timer that fires in intervals for a given duration when e.g. a button is pressed. The button can be pressed several times thus I thought it would be easiest to create a new timer for each button press and the timer destroys itself when its duration passed. I wrote this... Interface: // timerhandler.h class T...
I am solving this prime generator problem from SPOJ: Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are tw...
Taking into account everything you guys told me last time I posted, I came up with this implementation of a singly-linked list, in which the first and last elements are known. I tried to make the implementation as STL-friendly as possible, so I also implemented iterators. It's my first time with those, so there might ...
The main objective of this code is that you must accept an input from the user and loop and remove the consonants and vice versa and display the new word. I know there is a easier way of doing it, but I have no idea how. String test = "john doe", check; for(int ktr = 0; ktr < test.length(); ktr++){ // System...
This web algorithm is causing even newer computers to freeze with CPU spikes from 20% to 90%! How can I make it more efficient? EDIT: An idea is to somehow get rid of the filter:blur(); property and use box-shadow instead but I don't know how to do that. Using something other than filter:blur(); would be awesome b...
I've made a Tic Tac Toe game with minimax in Javascript. It works but I have to use location.reload(true); to automatically reload the page every time user starts a new game (by pressing 'Play again!' in the modal), otherwise the game becomes slower with every round until it stops responding. I guess the problem is in ...
My idea is I can define a block of code (inline) that corresponds to an input string then can call that block of code when given that input. I'm used to this sort of structure in JavaScript like so: var lookup = { "foo": function() { ... }, "bar": function() { ... }, }; lookup["foo"]; And I'm looking for a C# equ...
I have developed a jQuery Responsive Carousel. When opened, the carousel in the browser and the Chrome task manager, I see that the memory usage of my page is higher than the rest of the opened tabs (also comparing to the Gmail tab). But there is one more tab on the task manager, 'javascript memory', which shows that t...
I have written a simple program to do trajectory simulation in the Earth-Moon system, it still has a long way to go I am working on making it more class oriented and am looking into implementing a better system than just the straight time step integration method. I want to focus on having it more class-oriented. I am u...
Just for the sake of understanding. I know JSON.parse could do this pretty easily, but without using that, how could this be made cleaner or more efficient? string = "ounces: 10; contains_toy: false" result = string.split("; ") result = result.map{|x| x = x.split(": "); Hash[x.first.to_sym, x.last] } result = result.re...
For a leetcode problem to find the minimum depth of the binary tree, I have written the below solutions. The solution is accepted, but can I do any other changes to make the code elegent? public class Solution { public int minDepth(TreeNode root) { if(root == null) { ...
I've been working on a large Ruby on Rails application for several years. We inherited it and refactored and upgraded it, but there are some sections that have not been touched in at least 5 years (parts created by the original developer(s)). One such section is payment processing code. The code works for the most part...