instruction
stringlengths
71
71.9k
This is basically a program that takes the first line of a file and makes a map using ggGgg h gGgGg s makes ggGgg equals h and gGgGg equals s. Now the rest of the file makes sentences with these. Idea is from here. #include <string> #include <sstream> #include <fstream> #include <iostream> #include <map> #include <stde...
This question has already got some reviews, so I could partially improve my code: please look at my self-answer below, which also contains comments about the review. I'm frequently interested to answer SO questions regarding (JS) objects and/or arrays manipulation. When providing a snippet, and if the actual result lo...
I have created an application that I will be using for pentesting. It creates a list of random IP addresses, pings them, and adds ports to them (but it's not complete). It works exactly how it should, and I just want to know if there's a better way to write this specific aspect of the program. require 'colored' require...
Since I have my own virtual machine and an assembler for it, I decided to test it with a FizzBuzz implementation. I have this: fizzbuzz.toy const reg4 100 const reg2 1 loop_begin: // The main loop counting from 1 to 100 add reg2 reg1 cmp reg1 reg4 ja end pusha push reg1 call print_func...
Executive summary The twist is that the consumers do not consume, they just read. The producer makes items continuously in one of two alternating slots. Readers read from the other slot. When producer comes up with a new item it waits until readers are done with their read slot (that would become the new write slot). T...
I've written an event dispatcher for a private project which task is to collect events from different threads and dispatch them in a single thread: namespace events { namespace { // unfortunately make_unique is not part of c++11 so we use our own template <typename T, typename... Args> std::unique_ptr<T> make_unique(Ar...
I've made a simple netcat in Python and would appreciate any advice/opinions of how I've implemented it. test.py: #!/usr/bin/env python # -*- coding: utf-8 -*- import sys import netcat def main(*args): netcat.connect('localhost', 4444) netcat.listen('', 4444) if __name__ == '__main__': sys.exit(main(*...
This bit of code initializes an array of any given size where each index corresponds to a thread and a value. That is, index 0 has 0, index 1 has 1, and so on. Then, the values, 0 to n, in the indexes are summed. This code as part of an assignment though I'm wondering if there are any ways it could be improved? Namely...
I have created a Bukkit/Spigot plugin for Minecraft servers because I wanted to change the dynamic of mining to prevent people with really bright monitors or the Fullbright mod from being able to skip using torches when mining. I created this plugin a while back when I used to run a Minecraft server, but since then hav...
To learn about concurrency in Clojure, I wrote a function that accomplishes the following: Takes a (possibly lazy or infinite) sequence of functions representing tasks to be run asynchronously Runs the tasks asynchronously and in parallel Immediately returns a lazy sequence of promises that can be deref'd to get the r...
I have a piece of Clojure code that reverses a string recursively. It is working but too slow (because I got the problem from Codewars and I cannot validate it before it timeouts). The algorithm is : take a string ex. "abc" and reverse it (r "abc") -> "cba" take the first position and reverse from there "c" + (r "ba")...
I use console a lot, so I thought this may help me. It's supposed to be simple, safe, and fast. Any ideas? http://ideone.com/INXub0 #include <iostream> using namespace std; class Console { public: template<typename ...Args> static bool WriteLine(const std::string& format, Args&&... args) { bool suc...
You are given a list of \$N\$ people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of topics a 2-person team can know. And also find out how many teams can know that maximum number of topics. Note Suppose \$a\$, \$b\$, and \$c\$ are ...
Previously asked here. I would like to get my code for implementation of simple sorting algorithms in idiomatic python code reviewed. I am looking for feedback on python idioms used, better ways of doing the same thing. I am familiar with FP, and I am willing to put in effort to get myself familiar with pythonic idioms...
This question is everywhere, and I looked at many answers. A lot suggest using mysql_real_escape_string but that isn't an option, since it's depreciated now. Being a rookie at PHP/SQL and especially when it comes to security, I can only hope some of you may be able to help out here. I know for a fact that some of thes...
This parses two digits and returns the rest of the string. Input: "20asg" Output: { number: 20, left: "asg" } Input: "9asg" Output: { number: 9, left: "asg" } function readDigit(str) { var digitMap = { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9 }; var ...
Does the following code is written correct witout redundant code ? or maybe using Jquery it can be written better? I need to find matching between properties insdie oData & oPushObj and fill aSelData with this content. This code is working as expected jQuery.each(aDataCollection, function(iIndex, oData) { ...
I have a system that only outputs reports in Excel 97-2003, and a second system (for the user to look at) that only accepts these reports in CSV format. The reports manager was previously opening each of the fifteen XLS reports, find/replacing all the commas with semicolons, saving as CSV, and renaming each file to th...
I built this auto registering registry to look into a package and import all modules and register any classes that are a subclass of a base class. I use it as a registry for a model's choices in Django and to be able to do a getattr on the class to get properties in a service that processes some data based on choices s...
At first, I created an unbeatable Tic-Tac-Toe game in Python. However, I wanted a better interface, so I used a PHP backend that runs the script and simple JavaScript that sends user commands to the script. index.html: (excuse stupid class names) <html> <head> <script src='jquery.js'></script> <link rel="shortcut i...
Problem from hackerrank: You’re given the pointer to the head nodes of two sorted linked lists. The data in both lists will be sorted in ascending order. Change the next pointers to obtain a single, merged linked list which also has data in ascending order. Either head pointer given may be null meaning that the corres...
I'm looking for some feedback on my lock-free queue, based on Disruptor, mainly for any potential concurrency issues, such as where I need additional fences. It looks correct to me, and I can't seem to able to break it, but I'm only testing it on my x86 machine. #pragma once #include <atomic> #include <cstdint> templ...
To test the queue I perfected from one of my CR questions, I've developed a maze program that receives an input maze, starting and end positions, and solves it. I have separate software that handles the maze execution and file parsing. I'm curious as to whether my implementation is optimal (fully expecting it to not be...
I've been learning F# for a month or so and I'm wondering how good my "functional" aspect of coding is. When I first started, I did this using an iterative approach with a lot of <- and mutables etc. I tried to rewrite it as functional as possible. Any critique is appreciated. This code prints out all anagrams in the e...
I made a calendar that displays text documents according to month. Thankfully it works, although I could really use some help how to make it more better looking and efficient. I'm new to programming but I have horrible organization skills, and can't really understand the concept of classes, and __init__. from Tkinter i...
My code communicates with a Raspberry Pi (with a static IP address) running on a network. The client sends a signal to the Pi, and the Pi sends back a double (encoded as a string) with the angle correction needed for another routine of the code (the Pi does some image processing, but that doesn't matter). The main exec...
I'm trying to solve PRIME1 in SPOJ with the following Scala snippet: 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 \le 0\$). In each...
I wrote this together for a test I'm doing that parses the Heroku access log. What I'm mainly interested is if this code follow common best practices and if there are any improvements I can make in terms of memory efficiency. Here is a line from the Heroku from their docs: 2010-09-16T15:13:46.723498+00:00 heroku[route...
I've just completed the Gilded Rose Refactoring Kata in Java. I took the approach that I would fully characterise the existing behaviour with 100% unit test coverage before refactoring. Although this got me there, it took me about 2 hours and got me thinking - is there another approach to testing that would facilitate ...
Given a string representing of an IP address, such as "127.43.23.59", return a 32 bit integer representation of this string. The 32 bit integer is separated into four bytes, where each byte is one of the numbers in the string, separated by dots. If you & 0xFF with the returned integer, it should return 59. If you & 0x...
(See the next iteration.) I have this command line program for computing GPA (grade point average). Given credit sequence \$\langle c_1, c_2, \dots, c_n \rangle\$ and grade sequence \$\langle g_1, g_2, \dots, g_n \rangle\$ (I assume European grades, i.e., \$g_i \in \{ 1, 2, 3, 4, 5 \}\$ for all \$i \in \{1, 2, \dots, n...
I have got it working in a way so that there is one superclass, MathObject. In this implementation there is only a Constant subclass. I was forced to implement an abstract MathObject add(MathObject that) and an abstract MathObject add(Constant that) for reasons. I would like to get that abstract MathObject add(Constant...
I'm playing with Haskell's list comprehensions, tuples, and foldr. The exercise I've given myself is to find all triangles with a perimeter of length 26 in the set of triangles whose edges range from 1 to 10 in length. main = do print triangles triangles = [(a,b,c) | a <- [1..10], b <- [1..10], c <- [1..10], hasPeri...
I made a small demo in JavaScript using HTML5 canvas, which renders a rotating sphere. The sphere is generated by first creating a set amount of points (currently 50, represented by vectors) randomly, then choosing the one with the highest distance from the already generated points, so I get an even distribution, then ...
When iterating over the members of an object for logging the keys / values one gets a "stair case" effect. Therefore I wrote myself this function which takes care for a left-alignment of the values. Any hints concerning flaws and improvement-recommendations welcome. // #### START TEST ####################### var pers...
I have written a function that is designed to convert an object into an array of key/pair values ("flattening it") like so: Input { "a": true, "b": { "c": 500 } } Output [ ["a", true], ["b", [ ["c", 500] ] ] Here is the code I have written to do it: function isCyclicObject(object, seenObjects) { ...
I'm currently working on building a simple REST API using Ruby on Rails. I noticed that a lot of the things I did were a bit redundant, especially the models. Just to clarify: I want this to be a REST API which returns JSON, without any views (I want to be able to access it from different applications, mainly Apache Co...
I tried to prove to myself that MJPEG stream decoding can be accomplished using bare-bones .NET. So I wrote a class that decode MJPEG streams, trying to keep tips in mind: No allocation, except the two arrays during startup Using a delegate called in a separate Task, so the image processing/display by the caller does ...
I'm developing a console app which is supposed to teach how the bitwise operators in C# work. It will include tutorials, training fields and all that good stuff. I have a problem with the naming of my variables. I have a few classes, however, their names are quite long and the variables that I'm passing to the construc...
Rubberduck has been using an extension method to export code files, notably for source control purposes. While testing source control, I ran into a weird bug in the VBIDE API, which caused UserForm modules to perpetually be treated as "modified", because every time we exported them, the VBIDE API would add an empty lin...
I am trying to increase my understanding of classes, so I tried to implement a simple address book program that holds ten names with that names corresponding address. The program works correctly and I am proud of what I have done so far, but I am looking to see if there is any aspect that can be made better, and or nee...
Following on from my two previous posts. An alternative vector An Alternative Vector (Copy Assignment Operator) I have written a detailed blog about how to write a minimal vector like class. This set of articles has been inspired by multiple posts here on http://codereview.stackexchange.com (See Sources). Index Res...
The problem is to find the number of increasing sub-sequence of a string with only digit characters. Answer may be very large, so output it modulo 10^9+7. I have been able to get a O(n) solution using segment trees. However , the the code is quite inefficient owing to loops with constant but large runtime. How can I m...
I'm making a game and I want to establish a network connection between 2 players through a server. So far all I have is: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; public class Server ext...
This code is part of a quite huge repository using NHibernate in a wrong way: no units of work, but microsessions for every object loading and saving (ignorant of Persistence Ignorance, coded like naive SQL or file access). The TransactionalSessionContainer has been existing for a while now, but, if used, only in a few...
I don't yet see a code review for a number-guessing game in Rust. Since I am just learning the language, and since the number-guessing game is part of the official Rust tutorial, I thought it would be beneficial both for me and for this site to open a code review request. I've started with the official tutorial and the...
Problem: Remove duplicates from a given array of integers. I want this method to work without using data sets except an array. My code is currently \$O(n^2 + n) = O(n^2)\$. How do I shorten this? My main goal in writing this code was in the mindset that I am in an interview and that I am given only 20 minutes to solve ...
I had to write the method that extract all pairs of numbers from collection of numbers, which sum matches the particular number. static void Main(string[] args) { var inputCollection = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var targetNumber = 12; var pairs = ExtractPairs.Extract(inputCollection, ...
I recently working in .Net field and under circumstances had to write a program to execute sql from external source file.I have written the code and works fine but when it goes to Production server,It crashes becasuse of too amny files to handle. Can someone just look and guide the improvement areas. Input Params- Mode...
I'm trying to write a short random walk simulator in which an agent has a 50% chance on each "round" to either move toward x or back to its initial position. If the agent is already at its initial position and has to move back, it stays there instead. I'm getting a lot of variance in the results and running the functio...
I have written the following method twice but I don't know which is better from performance perspective, code design and best practice. First: public int Insert() { int affectedRow = -1; using (IfxConnection con = new IfxConnection(ConfigurationManager.ConnectionStrings["sh"].ToString(...
I'm currently in the process of writing my own programming language and the Virtual Machine for the language is responsible for handing all of the local variable scopes. I need to support the following operations as fast as possible: putLocal - puts an object into the stack getLocal - retrieves an object from the stac...
I've had to write two different functions (shown below), but I want to combine the two functions into one. Is there a way to do this? softmax_a_set() takes a list of numpy arrays, applies softmax() to each individual numpy array, and then returns a list of processed numpy arrays. def softmax(a_vector): """Compute ...
My aim is to print bytes string lines in Python 3, but truncate each line to a maximum width so that it fits the current terminal window. My first attempt was only print(output[:max_width]), but this did not work because Python counts e.g. tabs \t as one character, but the terminal displays them as multiple characters....
There is a task: Given a binary search tree of \$n\$ nodes, find all the pair of nodes whose sum is equal to a given number \$k\$ in \$O(n)\$ time and constant space. Please let me know if you find bugs on any data set. import java.util.*; import java.lang.*; import java.io.*; class Main { static class Node ...
I am writing a function which on update of any attribute of model sets the status of variable is_kyc_verified to false. Here is the code of the User model and the method which changes the status: class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :time...
The goal: A set of configurable options, combined with a standardised data source, to produce a standardised Report. This question: One module of said document, with accompanying code. Input: (Dropdown selection): An Attitude To Risk (ATR) Value. 1 to 5. Business Logic: Select from pre-configured descriptions and hard...
From SICP: Exercise 1.12: The following pattern of numbers is called Pascal’s triangle. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 . . . The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it. Write a proced...
I'm in the process of writing a Generic Container Library in C called CGCL. One of the generic containers I'm implementing is the vector container. I'm writing this library to improve my knowledge of different data structures, improve my C coding skills, improve my skills with generic programming in C (as opposed to t...
I am preparing for ACM-TCPC (Tunisia). So I started solving problems from past ACM-ACPC versions. But I got stuck in the Problem I from 2014. The problem consists of finding the number of non-equivalent passwords in list of passwords. Two passwords, A and B, are equivalent if len(A) == len(B) and |A[i] -B[i]| is the s...
Obviously, everyone should use a password manager to generate and store long unique random strings of characters for the vast majority of their passwords. However, one still needs to memorize a master password for their password vault! I figured that I would write my own little script to generate such a password, XKCD ...
I had an online coding test yesterday. The question is not hard to solve, but I could not achieve the required running time. The question is as follow: Given \$1 <= M\$, \$N <= 10^5\$ find the count of pairs A, B: 1 <= A <= M and 1 <= B <= N \$(A^{1/3} + B^{1/3})^3\$ is an integer Here was my solution: I notice that ...
I have a huge method in my controller that is not DRY and just could use some general TLC. I'm new to ruby and I have not refactored my own code before, only contrived code you find on tutorials. Below I will show my controller, just to be clear I'm not looking for a full answer just maybe where I should start and some...
I'm writing this method that elaborates an image name.. I think my logic is not being the best one here but I'm not very savvy in programming yet. Right now it looks like this: if($this->isCustom($product)){ $image_path = PRODUCT_IMAGE_PATH . $this->order['order_number'] . $index . '.jpg'; $inde...
This is working but right now it is not giving me the throughput that I want. The main function has the load generation loop (where it is putting work in Queue). I am trying to model a Poisson arrival process for the memcached requests (keys are randomly generated and this is handled in sendRequest). Right now it takes...
I'm learning Java at the moment and I'm currently trying to make a GUI using Swing. I've done some reading and people usually prefer and advice to use composition instead of inheritance of e.g. JFrames. I'm trying to code the GUI by hand instead of using the GUI builders, since they all generate a lot of code and I wan...
I have file which contains a lot of boards from TicTacToe 5x5. First line says how many boards this file contains (n*5x5). We check the winner in Horizontals, Verticals and Diagonals lines. Player A or B win, when has streak of minimum 3 letters (can be 4, 5) on the board. for example: ABABA AABAA AABAA ABABA AABAA D...
The following is my code for my "drawer" to be display or hidden on the basis whether it has been clicked or not. I want to make this better as personally its messy. Any tips? //Checks if the page loaded is of specific type if(window.location.href.indexOf("home.php") > -1) { //Handles the displaying of the si...
This was written as an experiment in performance, based on another question here on CodeReview. Input into the algorithm is the number of squares on one edge of the chess board, the point of origin, the destinat ion and the type of slicing (imposing restrictions on the search to allow it to complete in a reasonable fin...
I made this game for my computer science class. Here is my professor's requirements: Write a Processing program that draws a triangle in the middle of the window. Rotate the triangle when the left and right arrow keys are pressed using the translate and rotate methods. When the spacebar is hit, create a torpedo that...
I have a site where a friendly hacker says they have accessed my admin area. I am not able to see how this is possible so any help would be greatly appreciated. I am using PDO prepared statements to connect to my MySQL database. Login Page (this is where the user logs in): <?php require_once('inc/constants.inc.php');...
I'm learning OOP and totally new to this way of coding. I've always scripted PHP the procedurial way. Now I've written a working class, which creates a database connection and has the method to create a query which is impossible to SQL-inject by hexing the non-integer data. (I know how to use prepared statements, but i...
I have created a program that turns a decimal into a fraction: package main import ( "fmt" "github.com/retep-mathwizard/utils/convert" "github.com/retep-mathwizard/utils/input" "math" "strings" ) func main() { fmt.Println("Input your decimal") num := input.Strin...
Short and Spicy question is that If input is how are you and output should beyou are how. public class ReverseWord { public static void main(String[] args) throws IOException{ String input; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter th...
I've asked question on SO how to rewrite jQuery code to Angular. Because I got no answers I've tried to create something by my own. This is my version of code: (function() { 'use strict'; angular .module('misiu.directives', []) .directive('console', ['$rootScope', function($rootScope) { return { ...
I have been writing a small particle plugin since I want to learn how physics works for games. Now I have tried to get this as clean as I possible could but It feels something is missing. Am I repeating too much code? Could this be improved in any way such as in performance? https://jsfiddle.net/zdufwLv6/ new explod...
I have written the following code, and it works great, but I'm not satisfied. I really love the book "Clean Code" by Uncle Bob and I try to apply all his principles when coding, but I'm having a tough time cleaning this abomination. I call it an abomination because I'm sure everyone new to this method will spend more t...
I am willing to get a linear output of a product in a ring Z/nZ For that I have successfully implemented a code that does a Product in a modulo However, it is not optimized to output the steps smoothly: /* Product of n1 x n2 x n3 modulo M */ var numbers=[n1,n2,n3]; var modulo= M; var AProd=1; var BProd=numbers[0]; ...
public async void Execute() { var mongoClient = new MongoClient(connectionStringBuilder.ToMongoUrl()); var db = mongoClient.GetDatabase(connectionStringBuilder.DatabaseName); var jobInfoDocuments = db.GetCollection<JobInfoRecord>("JobInfoRecords"); var encryptedKeys = new[] { "AccountKey", "PrivateKey"...
I have three primary tables: Customer Product Order Relations: Many to many between product and order. CREATE TABLE Customer ( CustomerId int NOT NULL AUTO_INCREMENT, CustomerName varchar(50) NOT NULL, CustomerMail varchar(50) NOT NULL, CONSTRAINT Customer_pk PRIMARY KEY (CustomerId) ); -- Table `...
The following code performs breadth first search on a mockup tree # some tree # A - LAYER 0 # B C - LAYER 1 # D E - LAYER 2 # F - LAYER 3 def get_something(x): if x == 'a': return ['b', 'c'] if x == 'b': re...
I have a rails4 app. When a user comments on a post it should send a notification to all the guys who commented on the post and to the post creator. I have a working method in the controller, but it's kinda ugly and I'd like to refactor it. Could somebody tell me what the rails convention for refactoring this? Comment ...
In a recent project I started passing dependencies to classes as constructor arguments, instead of using local instances. This makes unit testing straightforward (with mock objects), but manual instance creation can be quite tedious if you have more than a handful of objects. I created a small class that's capable of a...
In an effort to teach myself Node.JS and truly delve into its communication capabilities, I elected to recreate a previous chatting project. It took a bit of forethought to acclimate code to the asynchronous nature of node, consider the implications of sending files for access and get in the habit of using callbacks. I...
This question was moved from StackOverflow as suggested by some users. I developed a function that aims to (should) provide a simple and effective method to transform a polygon <path> from relative to absolute. The purpose of this function is to replace similar SnapSVG function from my code, since I'm not processing an...
I recently created my first directive based on jQuery plugin and I asked for review here: Angular console like window - first directive I've edited my directive so now instead of $rootScope it uses provider. Below is my code: (function() { 'use strict'; angular .module('misiu.providers', []) .provider('sim...
I'm starting to learn Lua and in one part of the book I need to convert a "Maze Game" that uses goto to another one that doesn't use goto. The maze is the simplest ever made, starting from room #1: --------- | 1 | 2 | --------- | 3 | 4 | --------- This is the original version using goto from the book: goto room1 -- in...
I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and will not intrude or collide with other files, then concat/minify them for production as one file; basing some concepts off ...
I am trying to learn AngularJS as a start to my revival of learning, I think that I am getting the hang of it so far, but would like to see what I can do differently with some super simple applications, hopefully I can see what I need to work on this way. First thing is first, a basic calculator. This is a super basi...
Javascript newbie here. I built a total cost of ownership calculator to calculate the cost of a business over 5 years. It has a lot of repeating script and prob way more congested than it needs to be so I was wondering if y'all could give me an idea of how I could go about writing this in a more DRY way. Below is a liv...
This code calls the iControl REST API provided by BIG-IP LTM. Trying to get the list of the pools, it's current status and the pool members associated with the pool. My code works like this, based on three calls: Get the pool names (/mgmt/tm/ltm/pool) Based on the pool names (path), get its status (mgmt/tm/ltm/pool/~p...
I have just finished a simple python script which uses this module to call Zenoss API for getting live events. What the script does: connects to zenoss reads a file which has one phone number on each line sends a message to each number by POSTing some data(first of all it authenticates) to a specific URL with the foll...
I have written this "Polyfill" for Chrome's Promise object and I have some concerns about the implementation; Does it actually work as designed? It seems to work but I'm not sure if there are any "edge cases" I am not accounting for. Is there a better way to do it? The inner function way seems a bit odd, as I don't li...
I am busy creating a file processor that needs to get some files from an Ftp client download the file and save the data into the database. I have a two part question. How can i refactor the code to look a bit cleaner? Feels like the method ProcessFiles is doing a bit much. I can extract some of the methods but...
I've refined a lot of the code from my previous question, and have also decided to include the logic that interprets a given text file. Any advice on how to improve the actual algorithm that solves the maze would be appreciated! I'd also like to figure out how to store the full path to the exit in a queue. Here's the f...
I've written an ES6 function using the new fetch() API and returning a new resolved promise with a data object or a rejected promise with an error subclass. I'm pretty new to both ES6 and Promises, and it looks a little unwieldy, so I'm wondering if there's a better way. I'm also wondering about how this relates to the...
I am getting a compiler warning when running my code analysis. It is CA2202. It is saying that I have not properly disposed my dataset through all exception paths. Here is the code: private System.Data.DataSet MyDataSet() { DataSet dat_set = new DataSet(); using (SqlConnection conn = new Sq...
I started learning Go a few months ago and am trying to shake the rust off after a project took me out of the Go world for several weeks. I'd appreciate a code review on this flood fill algorithm I wrote for practice. Specifically I'm looking for points on any code I've written that is unidiomatic in Go, and of course ...
I have been using a particular pattern over and over again when I want to keep my jQuery apps more safe from XSS. I do something like this. (It uses ES6 template strings) function doSomething ($el, user) { var $html = $(` <div> <img src="${user.img}"> <div class="username-text"></div> <div class="descri...
I wrote a function to find a specific file, or all the executable files with a given name and accessing flag, and I want to make sure it is as cross-platform as possible. Currently, I'm using the PATHEXT environment variable to get the extensions for files that the operating system considers executable. import os clas...