instruction
stringlengths
71
71.9k
It looks like it should be shortened but I can't see how. I have my methods <= 5 lines but that's as far as I got: def check_lines if horizontal?(@player) || vertical?(@player) || diagonal?(@player) @win=@player end end def horizontal?(player) ((@squares[0] == player) && (@squares[1] == player) && (@squares[...
I'm working through learning Go, so as an exercise, I'm writing a simple raytracer. I'd like general feedback on the code style & architecture. Specific areas of concern: Is the project layout reasonable? Are my types and interfaces clear, and the right types/interfaces to be using? should the receiver of a function ...
This little program was written for an assignment in a data structures and algorithms class. I'll just note the basic requirements: Given an inputted string, the program should check to see if it exists in a dictionary of correctly spelled words. If not, it should return a list of words that are obtainable by: ad...
Up for review today is some C++11 code to recursively search a maze for a path to a specified goal. This one shows dead-ends it explored on the way to finding the solution. #include <iostream> #include <vector> #include <string> enum { GOAL = '*', SPACE = ' ', WALL = '#', TRIED = '!', USED = '+' }; class maze { s...
So I'm doing a basic MVC layout for a pretty basic game that I am making. The game requires the user to move up/down/left/right via buttons on the GUI. Since I'm using an MVC layout and my buttons are in a different class than the ActionListeners, I was wondering what the best way to add the action listeners are? Metho...
I've borrowed the idea from the internet and I would like to know if my implementation is all right and what could be improved. It uses the free memory to store links to each node, so there's no extra memory being used. memory_pool.h #ifndef MEMORY_POOL_H #define MEMORY_POOL_H #include <stdlib.h> #define MEMORY_POOL_...
I am trying to make a basic auth password protected folder for Joomla. This script will simply ask for username and password to secure administrator folder in Joomla and creates .htaccess and .pass_file. I want you to review it and offer suggestions so that I can do it more efficiently and learn to manage code. #!/usr/...
Like others (FileSystemWatcher Changed event is raised twice) I am facing the problem that events of filesystemwatcher are raised twice. I require to catch all non-duplicate events of watcher in real time. I came up with this. So, I want to know if it will be efficient/over-kill/buggy to use this class. class ModifiedF...
I'm working on a library which will provide easier writing and calculations in Java using a fluent API. This is the library I have implemented with basic functionalities and am now working to improve the API. I followed instructions given by this but I still have some doubts in naming some classes and methods. I have s...
I have never use css animations before, so I just want to know, is this the 'best' way to animate a Ticker? I 'best' in this case encompasses efficient and semantic use of html and css. It's worth noting that I intend to add extra functionality to this, such as manual scrolling back and forth. Is this set up ok for ext...
I have successfully coded a network request to fetch JSON data from our server. The remote function is written in ColdFusion. However, the code is quite lengthy and involved. I also noticed in the API there are other seemingly very similar ways one can go about making network requests, such as NSURLSession. (I know NSU...
I'm an experienced programmer that also has a little experience with functional programming, although mostly theoretical (as in hobby-level reading and very minor projects). I recently decided to work through the new book "Beginning Haskell" to get up to speed with Haskell and try to crank out something worthy of a git...
Note: This is the first time I've written anything whatsoever in straight C. In other words: I have no idea what I'm doing. I recently had a task that involved temporarily relaying responses from one server, through a web-facing server, and then on to the client. Along the way, the relay server had to dynamically add a...
I am posting this code up for review and debugging. This source code is for Java, and is meant to give you the exact day of the week from an entered date. Review This program seems to have 2 case statements. Would it have made sense to use an enum variable to eliminate the second case statement? How about restruct...
Can someone review this code for me? I'm not completely sure I did this correctly. I also would like help creating the code for the "walk" "don't walk" lights. I needed to create a traffic intersection. Each traffic light has a cycle of 31 seconds red, followed by 26 seconds green, followed by 3 seconds yellow. The re...
Please review my implementation of mergesort: mergesort' :: (Ord a) => [a] -> [a] mergesort' [] = [] mergesort' xs = merge' (sort' fst', sort' snd') where fst' = take half xs snd' = drop half xs half = len `div` 2 len = length xs merge' :: (Ord a) => ([a], [a]) -> [a] merge' ([], [])...
Over the past week, we tried to make our AngularJS model layer more powerful and reduce complexity in our controllers and template by using the object-oriented programming pattern and the CoffeeScript class keyword. You can see the result here: http://plnkr.co/edit/c1uxN6ZorQzOVizlzU5Y?p=preview This is our Base class ...
I'm writing a program which determines how many bits are in a floating point value (this will be run on Unix). #include <stdio.h> #include <stdlib.h> void countbits(int k); int main(){ int input; // int a = (int) malloc(sizeof(int)); printf("Please enter a number: "); scanf("%d",&input); // a = in...
This is my first attempt at a login system! I've only had roughly 2 days of experience with MySQL and PHP so far and this is what I came up with: <?php session_start(); //Start Database $IP = ""; $user = ""; $pass = ""; $db = ""; $con = mysqli_connect($IP, $user, $pass, ...
Below is the code that I've written for matrix multiplication: import java.text.DecimalFormat; import java.util.InputMismatchException; import java.util.Scanner; public class MatrixMultiplication { private static final String TERMINATED_MESSAGE = "Terminated" + "," + " "; private static final String INVALID_M...
This question is a followup from my previous question My EventBus system, and incorporates most points from @rolfl's answer. It includes, but is not limited to: Usage of Collections.synchronizedSet over manual synchronized { } on trivial methods. Minimal locking High performance code, but not going into micro-optimiza...
I have requirement to apply multiple filters on database. I will have multiple conditions in the front end where the user can select the conditions he wants to filter with and then see the output. This is similar to the filter that Freshdesk has or for instance similar to many ecommerece sites. This is my CoffeeScript ...
I wrote a short program for my exercise routine. It takes a JSON array of exercise names and duration (seconds) and puts it on the screen. The JSON looks like this: var exerciseArray = [ { "desc": "Pushup/Pullup", "countdown": 30 }, { "desc": "Squat punch", "countdow...
I was tasked with making a program that uploads a .csv to a NoSQL cluster. The files are larger (typically 2-17GB). My program works in batch mode and can process a 17GB file in 6 hours. I decided to make a consumer-producer multithreading structure. This caused it to be significantly slower. I want to know why the pro...
As an exercise, I decided to create a simple Tic-Tac-Toe game. It is Ruby on Rails based, but as for now I'm not using the server side for anything (I intend to build up on it in the future, though). As I'm rather new with JavaScript, HTML5 and CSS, I'd like some feedback regarding what did I do wrong or what could be ...
I have this basic Java code to find average of eight immediate neighbors of a matrix. Is there any way to simplify or merge any part of it, or can I refactor it? I'm a beginner in Java programming and am trying to improve myself. // CODE STSRT import java.util.Scanner; import java.lang.*; class Matrixer { double...
This is a simple GTK+ program that takes a spun article as input and shows a random output every time the user clicks the "Spin" button. It supports many levels of nested spinning like: The {car|automobile} is {{very |}fine|{really {pretty |}|}cool|all right} I tested it and it seems to be correct, but I would like ...
In this answer I suggested using a fluent interface "builder" to replace all the hard-coded, repetitive and quite error-prone inline XML string concatenations. This code might need a bit of tweaking to work perfectly with the OP's code in the question this code is following-up on, but it seems to work as expected. Thou...
I haven't done much .NET development in several years. Now I'm enjoying some of the new stuff with modern .NET. I just want to make sure I'm using things correctly. I'm a solo developer with no one else to bounce ideas off of. I have a new MVC web application. I'm using the Massive micro-ORM. I'm a big believer in...
I would like to know what you think: <?php $nav_normal = array("1. Home","2. Read Me","3. License Agreement","4. General Information","5. Database Installer","6. Create an Account","7. Create Config","8. Successfully installed" ); $last_normal = array_pop(array_keys($nav_normal)); foreach($nav_normal as $name){ ...
Is there a more efficient approach to this code? // save associated tag let saveTag question = if question.Tag = null then () else let tagCount = query{ for row in db.Tags_Tags_Tags do where (row.Tag = question.Tag) ...
I recently posted some sample code that I was providing students with and got great feedback so figured I post another one of the examples I will be providing students with. (See Simple Example of an Iterable and an Iterator in Java) This one is a simple postfix calculator. The main learning objectives are basic inher...
Fellow students are supposed to review and tell what my code is doing for a grade, this is why I'm asking on here first. I want to see if its clear enough. public class SpellParser { private static final String SPELL_PACKAGE_LOCATION = "edu.swosu.wordcraft.spells."; private Document dom; pu...
I implemented the group function: group' :: (Ord a) => [a] -> [[a]] group' [] = [] group' xs = takeWhile (== head' xs) (sorted xs) : (group' $ dropWhile (== head' xs) (sorted xs)) where sorted ys = mergesort' (ys) head' (x:_) = x Note - please...
In the below example I have tried to show how we can break a long running background task running in a service into different states of a state machine and notify the front end UI about each and every stage as they occur in the service. Here I have used a service called LongRunningService which actually (theoretically)...
I got three classes for MySQL Database access/manipulation: Conector. It has got methods for connecting, disconnecting, querying and updating db. ConectorCliente. It simply extends first and got its constructor receiving user, password, host, port and db. I have written has several different methods per each DB, depen...
Is this a good approach or is there some other solution that I am not aware of? //C++ program to count number of words in text file #include<fstream> #include<iostream> #include<string> using namespace std; int main() { ifstream inFile; //Declares a file stream object string fileName; string word; int...
I am using PDO for the first time in my project. In my previous project someone suggested me to use PDO as my queries were wide open to inject. I am pasting a sample code of my project. Can you please let me know how safe my code and query is? <?php require('config.php'); try { $pid = $_GET['pid']; $conn = ...
I have a script that creates an active CSS on link, but I think there are a lot of if statements. Can someone help me refactor this? var link = window.location.pathname; var currentPageName = window.location.href.match(/[^\/]+$/)[0]; var hl = $('#ih').val(); if (hl == 'True') { var currentPageName = 'WVD'; } ...
I'm developing a win forms application in MVP pattern. In the application, there is a small module to show the branch offices (called points) where the attendance entering process has been completed. Those details should be shown in a data grid view. So I have a form (View), a presenter and a data service classes. For...
Problem Statement A group of farmers has some elevation data, and we’re going to help them understand how rainfall flows over their farmland. We’ll represent the land as a two-dimensional array of altitudes and use the following model, based on the idea that water flows downhill: If a cell’s eight neighboring ce...
In this function I'm parsing the page of the item in the online shop. Some items lack the picture, some lack price etc, so there are few if-else checks. My questions are: How to get rid of these ugly if-else checks? How I can "pythonize" my code further? Is it correct? I.e when I manipulate the variable value using pr...
As part of a simple (naive) internationalization attempt in Go, I am trying to come up with a number formatting routine with customizable decimal and thousands separator. Is this approach alright? var decLen = 1 var decSep = "." var thouLen = 1 var thouSep = "," func numberFormat(floatVal float64, precision int) stri...
I'm looking to change a single jQuery plugin option when the window hits certain breakpoints. The code below works, however I'm conscious of repeating code and feel there is a more elegant way writing code for examples like this. My initial thoughts would be to store the first call in a variable. $(window).smartresize(...
Now FizzBuzz itself isn't a big challenge but I agree that it can be a good tool to see if someone can code or not. I wanted to practice my LINQ a little bit so here's my single line FizzBuzz solution. Enumerable.Range(1,100).Select( n => (n % 15 == 0) ? "FizzBuzz" : ...
Can you give me some performance advice on how to optimize the time of execution of the following calculation of E? package calculatee; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; public class CalculateE { static long start1 = System.nanoTime(); public static BigDecima...
Inspired by some older questions, I decided to create my own postfix calculator using Java 8. I'd like to have all aspects reviewed. public enum Operator implements DoubleBinaryOperator { PLUS ("+", (l, r) -> l + r), MINUS ("-", (l, r) -> l - r), MULTIPLY("*", (l, r) -> l * r), DIVIDE ("/", (l, r)...
I'm working on some teaching examples showing the perils of accessing the Dictionary class concurrently. In the code below each function is designed to do a word count across a number of files. (This isn't the best way of doing the count but it's there to make a point about Dictionary.) The first example, using a Dic...
I am writing some code in Ruby on Rails to Create an object. I am using Ruby 2.0 and Rails 4.0.3 in my Application. I have a Model called: class GroupUsers < ActiveRecord::Base belongs_to :users belongs_to :group This is basically a ManyToMany mapping between Users and Groups. So, today I was creating an object fo...
I'm creating a 2D tile based platformer with AABB (Axis aligned bounding boxes), and it works, I just want to organize and optimize my setup. Here are methods in my player class and entity class that are relevant to the collision. How could I make this better? I'm harshly looking at that public boolean[] method, but I ...
It's a dynamic array, the elements can be accessed normally and it supports any type. I believe I'm relying on undefined behavior when I treat every pointer to pointer as void ** and I would like to know if it will work on the main platforms. Every call to da_reserve() and da_push_back() might cause the array address t...
I'm creating an extension method that can be used on any type. The idea is that if this method is called, it checks if value is null. If null, it needs to return a default instance of the specified type. public static dynamic CreateDefaultIfNull<T>(this object item) { if(item == null) { ...
I wrote this memory pool as a code sample for a job interview. It provides a per-class memory pool that can offer faster runtime performance for classes that need to be traversable and (de)allocatable during runtime. Specifically, it provides in-order traversal of the allocated data blocks, to improve cache effectivene...
Student http://semisalsaja.com/sekolah/student.asmx?WSDL - studentList Mentor http://semisalsaja.com/sekolah/mentor.asmx?WSDL - mentorList study http://semisalsaja.com/sekolah/study.asmx?WSDL - studyList I'm trying to get data from some SOAP resources (mentioned above): class SchoolSoap { protected $_config = ar...
Implemented observers in C++11 in a generic and statically accessible way. Though an instance is created, it's used only for cleanup and lifetime management. template<typename... Args> class Observers { private: unordered_map<int, vector<function<void(Args...)>>> observers; static Observers<Args...> *instance; ...
I'm just starting out in Haskell and have been set an assignment for uni where I have to create a reverse index of words in a text file and find what line numbers they appear on. I also have to remove any stop words like "the" or "and" that aren't needed. So far I have this, but I feel that there should be a better way...
This is an example of my filesystem: /code/ internal/ dev/ main/ public/ dev/ main/ release/ tools/ /code/internal/dev/, /code/public/dev/ and /code/tools/ contain subdirectories for multiple projects. I work almost exclusively in the dev branches of /code/internal/ and /code/public/, and often I want to search...
I use Gem in a Box, a Ruby project that allows to create personal self-hosted gem repositories. Gem in a Box uses httpclient to connect to the gem repository. After reviewing my server's TLS setup in the aftermath of the OpenSSL heartbleed bug, I decided only to allow protocol versions of TLSv1 and higher on my server....
I have a list of 6 items, and each one on click reveals a div that runs 100% wide under the row of list items. The code works, but the div opens very slowly and kind of choppy. Is there anything I can do to help it run more smoothly? My HTML is set up as such: <ul> <li><a class="artist-logo" href="#arti...
I am wondering if I have overdone it with repositories in the following code, which is to save a sales order. I understand that the purpose of a repository is to decouple the domain layer from the persistence layer, but this code seems to be replicating what EF does anyway. public SalesOrder FindSalesOrder(int id) { ...
I'm currently getting into MVC, and I'm working on a simple CRUD application but to make best use of relational database layout I need to use ViewModels so things look prettier on the UI. I have a ViewModel: public class CreateAPIViewModel { [Display(Name = "Name")] public string Name { get; set; } [Displa...
Follow up for my initial question. Modified my earlier code and adding new changes. Initial Question in Code Review import random class Booking: def __init__(self): pass def checkAvailability(self,**kwargs): booking_type = kwargs['booking_type'] booking_class = kwargs['booking_class']...
Background This is a problem from a programming contest. The Sharonians of planet Sharon, at the far end of our galaxy, have discovered various samples of English text from our electronic transmissions, but they did not find the order of our alphabet. Being a very organized and orderly species, they want to hav...
This post is a follow-up to this. I wanted further reviews since the code I provided became too old when I got replies, which is why I'm providing it again here. I'm hoping I could get reviews for the new code. #!/bin/bash # # Need to sort music, try tinkering with sort -u at the end of the load_sites function .. # ...
I'm using this function to replace UTF-8 characters representing numbers in text with 'normal' digits. I'm wondering if this is optimized code since this is using two str_replace()s. public static function convertArabicNumbers($string) { //$engish = array(0,1,2,3,4,5,6,7,8,9); $persian = array('۰', '۱', '۲', '۳...
I have a 'speed problem' with a program I'm currently developing. I already have encountered the methods which costs some time. public void ConvertDataFrameToValueFields() { List<byte[]> items = new List<byte[]>() { new byte[2], new byte[2], new byte[2], new byte[2] }; items[0][0] = this.DataBytes[...
I'm pretty new to multithreading. The code below is a simple implementation of a single consumer/single producer circular buffer that does not use any locking, that I wrote for fun. The question is, will this kind of container work in actual real world situation or would it crash miserably because of some data race t...
I've created a generic data structure intended for game development entity management. It has some interesting properties: Entities are stored contiguously in an std::vector. Stored entities can be in one of three states: alive, dead, unused. Upon entity creation, a lightweight Handle object is returned: The user ca...
As advised by many, I am using a client pool - specifically the Apache PoolingHttpClientConnectionManager. For simplicity I wrap it in my own simple singleton class. Sorry about the rather OTT Stop mechanism: public final class HttpClientPool { private static final Logger log = LoggerFactory.getLogger(HttpClientPool...
I've been writing far too many routines in JavaScript that get a record from a an object or array based off a matching property, much like jQuery does with DOM elements. Since all the good names are taken, I called it Hmm. I went with the philosophy that if I don't need it yet, I wont provide for it. var Hmm = (functi...
I am trying to build something similar to planning poker and am very new to Knockout and was wondering if anyone could help me improve on my very crude start? This is what I have so far: HTML Selected Card CSS .profile { width: 50px; height: 80px; color: #FFF; background: black; border: 1px solid #FFF; float: left;...
I need roomId (an auto_increment primary key) to locate a specific room to update chat info. My way of doing it right now is dumb. In createRoom.js, I use roomName from a form that a user has entered to create a room model and find its roomId, then make roomId a param of a URL: var Room = require('../models/database')....
I'm writing Stringbuilder to file asynchronously. This code takes control of a file, writes a stream to it and releases it. It deals with requests from asynchronous operations, which may come in at any time. The FilePath is set per class instances (so the lock Object is per instance), but there is potential for conflic...
Code Objective I need to create a System.Data.DataSet object from an Excel workbook. Each DataTable within the DataSet must correspond to a nonempty worksheet in the workbook. The top row of each sheet will be used as column names for each DataTable and the columns will be populated as the string representation of the ...
My PHP contact form was recently being used to send spam. Some security measures have since been put in place (please refer to the comments below) and I'm seeking the collective wisdom of others to review the code and to check to make sure it is secure from injection attacks. <?php /* method for validate each input v...
#include<iostream> using namespace std; int partition(int arr[],int first,int last,int pivot) { int tmparr[100]; int left=first,right=last; for(int i=first;i<=last;i++) { if(arr[i]<pivot) tmparr[left++]=arr[i]; else if(arr[i]>pivot) tmparr[right--]=arr[i]; } ...
I have a complex directory structure on my web server that includes .tar files for download; I'm trying to create a report on the size distribution of these files (e.g. 10 are less than 1MB, two are 1-2MB, three are 2-3MB...) Is there a better way to organize this code? I started it as a console application, writing d...
I have read several articles using Google, but I somehow do not really get what they do, and when it is needed. Below I'll give 2 pieces of code, in one using get/set and in the other without, and they both work (at least in this example). Example 1 public class Example { public int number; } class Program { s...
Working my way through Algorithms, Fourth edition by Robert Sedgewick & Kevin Wayne. I implemented a generic version of the Quick-Union algorithm and added Path Compression (not described in the book) to it. Mainly I'm looking for feedback on these two aspects and whether I might have overlooked a side effect. public c...
After changing all variables in this code from public to private and adding get/set according to the need to get modified and/or read in another class, I'd like to know if this was done correctly. // Main public class Asteroid { Random random = new Random(); private Rectangle boundingBox; public Rectangle ...
This is the controller I created for my MVC framework, and I think I finally got it right. Anything I can do to make the code more efficient? Is this how a MVC controller is supposed to look like? abstract class Controller { protected $requestHandler; public function __construct(RequestHandler $rh, $action) ...
I just finished Project Euler 37 after a bit of debugging and can't figure out how to make it faster. Whenever I add extra tests that I want to speed the program up, it ends up just slowing it down. My primes test is from here. Please help me optimize! from primes import test as is_prime from itertools import product f...
I have two IEnumerable objects called items and newItems. I need to update the Did and KeyDid property of each element in items with the matching Did and KeyDid from newItems. I can't just call items = newItems; since other things have a reference to items. Here's my code: T[] arrItems = items as T[] ?? items.ToArra...
I'm trying to get my progress bar animated. I'd like it to smoothly transition in between the starting and destination values, but only be initiated by clicking the continue button. The code I currently have works great, but when clicking forward or backward, it brings you directly to the values: //PROGRESS BAR $("#pro...
Following code is supposed to identify a shift and then it should identify whether the shift is a night or a day shift. The method will take 'in time' and 'out time' as two parameters. These are the rules: Day shift - From 7AM to 7PM Night shift - From 7PM to 7AM (on the next day) The employee should report before 8AM...
Below are two functions. The first is to set a cookie. This function is called on any product page on my website. function setcookie() { $entry_id = $this->EE->TMPL->fetch_param('entry_id'); if (isset($_COOKIE['recently_viewed'])) { $currentSession = unserialize($_COOKIE['recently_viewed']); ...
I've just finished creating this form validation but I want to make it public for beginner 'contact us forms'. I was wondering if I can have some peoples' input on if they can understand/read my JavaScript. Although I know my JS works, it's better to be safe than to have 20 people asking what this does. It's just inpu...
I wrote the following groovy function for taking a string of multiple lines (or any other character for splitting the code into parts), and bringing each line/part to a specified number of characters, cutting too long lines and filling up too short lines with a fill character: static final String adjustLineLength(Integ...
I am trying to learn Clojure for some time. In my experience, it has been rather too easy to produce write-only code. Here is a solution to a simple problem with very little essential complexity. Input and output formats are extremely simple, too. Which means all complexity in it must be accidental. How to improve its ...
I have to generate a lot of tables from different JSON files (up to 20 tables per page). Because it's a lot of data, I really want to keep loading speed in mind. I know it's better to use a non jQuery solution, but native is not in my skillset right now. $(document).ready(function(){ (function getPersonData(){ $....
Assume I have the following list (List<string>) G G M T I'd like this to be in an order where the same letter will not occur twice, such as G M G T (I appreciate other variations would also suffice) Please note, if I had the following G G G G G M T Then of course some values will have to occur concurrently. The posit...
I'm currently working on a Scala HTTP library, fetch, mostly because I have yet to find one that suits all my needs. As part of this library, I need a generic key / value store, which I intend to use both for request / response headers and URL query parameters. This store uses type classes for value parsing and formatt...
I'm not very good at JavaScript, so it would be great if somebody could review my jQuery Upvote plugin, and point out mistakes, bad practices, or anything suspicious. The repository is on GitHub. Here's a live demo, and qunit tests, if you're interested, but I'm not asking for a review of those. Here's the code, with t...
I would like to find out if my current solution to the problem described below is "good enough" or if there is an alternative way of achieving it. All I care about is the length (no. of lines) of the code and its efficiency. I am trying to follow the "DRY" principle and come up with something that when seen by another ...
I am working with currencies, and so have been using the decimal module to rule out any floating point weirdness in the following maths. I have to add together a number of decimal amounts, find an average of them, add ten percent, and then round it to the nearest round £. I then need to do more decimal maths with the o...
The following piece of code will act as a single access to all social networks. It aims to connect different social networks to get a broader picture of the social life of a user. I have just committed the code for Twitter access, but similar access will be provided to Facebook and Github. The code is available here. I...
This works, but it's huge. We need to repeat each table column on each UNION SELECT, as well as the WHERE clause for DATE comparison. ( SELECT GROUP_CONCAT(APA_T.district), t.name FROM tbl_activity AS t INNER JOIN tbl_activity_package AS ap ON t.id = ap.activity_id INNER JOIN ( SELECT DISTINCT apa.district AS dist...
I have developed a few web applications according to my own coding style similar to MVC architecture. I'm a self learner. But there is no controller class or model class. In my way, I don't split the URL. I have mentioned below an example URL. Now I'm familiar with this process, but I know this is not a professional le...
Morris Inorder traversal - an algorithm for in-order traversal, of a tree, without recursion of extra memory. Looking for code review, optimizations and best practices. public class MorrisInOrder<T> { TreeNode<T> root; /** * Takes in a BFS representation of a tree, and converts it into a tree. * her...
In a large project of mine, I've run into a situation where a client might need to run evaluated JavaScript code. I know, it makes me cringe too. One option is to manually parse it, but for future flexibility, I would like to evaluate the code safely. Everything I've seen and researched says, NO. Ah, the nay-sayers. Th...