instruction
stringlengths
71
71.9k
This is a sort-of-useless "utility" I wrote to learn my way around shell programming better. My concerns are: Is the code readable? Could it be more efficient, or just simpler? The logic ends up being a little complicated and I have a lot of nested if statements. Should I use 4 tabs instead of 2? Is the interface itse...
I currently have a design that is used to store user/selected options in a database, but I am not sure what I am doing is good or not. I need some opinion, suggestion and criticise on the design. Pre-Condition: The option is not always going to change A lot of options is going to be used Database Design: Let's say I ...
I am new to C and I am trying to implement a mutex. The idea of the program is: main() will create three threads. Each thread will read one character each from individual files in serial, i.e. thread 1 will read one character store in global and then wait for thread 2 & 3 to complete the same tasks, until the end of t...
I'm new to programming and I'm trying to teach myself Python through some online books. One of the exercises has me making a Rock Paper Scissors game. The one I have written works well enough I think, but I was wondering if there were more efficient ways of writing the code, perhaps something shorter. I'm using Python ...
Using my previous function as a base I've come up the following: create function dbo.Pbkdf2 ( @password varbinary(8000) , @salt varbinary(7996) , @iterations int = 1000 , @derivedKeyLength int = 32 ) returns varbinary(max) as begin; declare @hmacLength int = 32; declare @i int = 1; declare...
I'm trying to pick up some Haskell skills so thought I'd write a random password generator to get to grips with using IO. It was far trickier than I expected and I employed rather more trial and error than I'd have liked. What I've ended up with works, and while I'm happy with it generally I'd like to know if this is r...
I have programmed this alarm application in Java using JavaFX for the GUI. I'd like these questions covered in the review: Is my code efficient? Can it be shortened? Are there any flaws in my code? Do I violate any OOP principles? If so, how, where and how do I rectify them? App UI: Alarm.java: /* * Program develop...
Is there anything I could do to improve the following .htaccess code? Options +FollowSymLinks RewriteEngine On # Redirect non-www to www. # http://{domain}/ # http://www.{domain}/ RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !=localhost [NC] RewriteCond %{HTTP_HOST} !=127.0.0.1 RewriteCond %{REMOTE_...
In this topic here I have aksed for help to sort out an error while creating a generic class whose method can return a different collection given a type. I received the answer and working solution but I have a feeling the problem is not sorted in proper way. That is why I came here for a review. The reason for having a...
I created a web crawler that uses beautiful soup to crawl images from a website and scrape them to a database. in order to use it you have to create a class that inherits from Crawler and implements 4 simple methods. get_image_page_links() returns a list of the a tags that link to each images individual page. get_image...
Given a JavaScript map object of dependencies and their dependencies, determine order to install them: Example: Input: { p1: [p2, p3], p2: [p3], p3: [] } Output: [p3, p2, p1] I really feel like there's a dynamic or recursive solution to this that I can't figure out. Is this true? Can it be done better than ...
I have created a quiz in Python that will generate a series of 10 questions to test the basic arithmetic skills of primary school children. To do this, I have used a while loop and random functions to generate random numbers and operations. name = input("What is your name? ") print("Hello, "+name+". You will be complet...
I've solved Project Euler #3, but solving the same in Hacker Rank which has time constraint of < 4 seconds doesn't work. I've tried using the square root solution for speeding up but it fails. Example: The prime factors of 10000001 are 11 and 909091, we have sqrt(10000001) = 3162, if we check all primes from 2 to 3162...
I'm trying to understand and learn about the SOLID principle and especially Dependency Injection (DI) and Factory pattern. Some background: I have a production application that uses some "helpers" classes but those are all-in-one classes that I just copy into each new project. One of the (most used) functions is serial...
I would like a review of: Correctness, especially around edge/corner cases Efficiency Readability and/or style Appropriate use of Java idioms and data structures In particular: Have I missed typical idioms/patterns useful to solving the problem? Could I have reused existing/popular framework/library code? Less inte...
I'm still pretty new to JavaScript. I'm making a game to get a better understanding. Although it's working exactly how I want it to right now, the code could definitely be less repetitive and more organized. I'm just not sure how to go about that. I'm hoping someone can take a look and simply give me some pointers abou...
I have a need to extract a part of XML tree (everything under root) and convert it to a string. (The result string will be later pasted inside XSL-FO XSLT file.) The above functionality is a part of Java 6 application. I use org.w3c.dom and javax.xml.transform. Still in the debugging process. // ... // Extract all c...
I created a HangPerson game in Haskell and I must admit it feels very imperative. How can I make it more "functional?" Are there more elegant ways of breaking up the task? The getUserLines function seems to be doing a lot of work. Any additional feedback on efficiency or anything of the sort is also appreciated. import...
I'm currently on Ch 4 Lab 4 in Programming Arcade Games with Python and Pygame. Any feedback on how I could improve the code would be awesome. I'm using Python IDLE 3.4.3. import random print("Welcome to Camel!") print("""You have stolen a camel to make your way across the great Mobi desert. The natives want their cam...
I'm trying to teach myself C. I've managed to make this program I call HappyToYou.c (inspired by this video): #include <stdio.h> //#include <stdlib.h> //malloc would need this. #include <string.h> #include <err.h> void sing(char *start, char *end){ printf("%s%s.\n", start, end); } int main(int argc, char *argv[])...
I'm writing some code to administer and grade multiple choice exams. I'd like this to be easily reusable, and I don't really want to have to do things like lay out quizzes and score them with a bunch of list and dict indexing for things like answers, prompts, etc. I've tried to implement some classes to provide a consi...
I made an Agario single player version (soon to become a multi player one using socket). What can be some improvements? Controller: package agario; import java.awt.Color; import java.awt.Frame; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapt...
I have a very simple Node application that routes requests to /users to the following file: users.js var express = require('express'); var router = express.Router(); var User = require('models/user'); var sequelizeSuccessHandler = require('lib/sequelizeSuccessHandler'); var sequelizeErrorHandler = require('lib/sequeliz...
I'm looking for a better way to manage employee photos for employee records in our database, and a way to query for the employee photos while having them on disk I have used a FileTable to store all the EmployeePhotos. Then in my Employee View I created a join using substring, which I am concerned about. I am wondering...
I'm starting to learn about data structures and coding in C. The stack is the simplest of all data structures so I'm trying to implement an ADT stack with dynamically allocated array in C. This implementation does have one obvious problem i.e. it hoards memory even after popping the data. How do I solve this problem? s...
Could you help me further improve this code, which includes some feedback from this site already (Find common "characters" in 2 given strings (rev1))? I have rewritten the code below, including feedback, as Rev3 @ Find common “characters” in 2 given strings (rev3). import java.util.ArrayList; import java.util.Arrays; i...
Could you help me further improve this code, which includes some feedback from this site already (Find common "characters" in 2 given strings (rev2))? I have rewritten the code below, including feedback, as Rev4 @ Find common “characters” in 2 given strings (rev4). import java.util.ArrayList; import java.util.Arrays; i...
I am writing an encryption class using Crypto++. The idea is that the client connects using RSA (encrypt, decrypt) with username, password, 32 byte key. The server will then return using the stream cipher (simEncrypt, simDecrypt) a session ID. Then any communication between the systems uses the stream cipher. What woul...
Could you help me further improve this code, which includes some feedback from this site already Find common “characters” in 2 given strings (rev3)? What has changed since version 3: I re-implemented the short-circuiting of scanning the longest string argument via a loop, in the absence of .takeWhile in the Java versio...
I was reading an article on Wikipedia about memoization, so I wanted to try and apply it. I am fairly new to this subject, so I thought I'd start small. Does the program use memoization correctly? Is there anything that I can improve? #include <iostream> int fibonacci(int num, int* memoize); int main() { int num;...
Could someone please review my code and let me know if there is any scope for optimization for better performance. package com.gmail.practice; import java.util.Arrays; public class Stacks { private int top; int size; int[] stack; public Stacks(int arraysize) { size = arraysize; stack = new int[size]; to...
I wrote this simple class for calculating the nth prime: package generator; import java.math.BigInteger; public class SimplePrimeNumberGenerator implements PrimeNumberGenerator { private static final BigInteger MINUS_ONE = BigInteger.valueOf(-1); private static final BigInteger ZERO = BigInteger.ZERO; pr...
Please review the code: package com.gmail.practice; import java.util.Arrays; public class Queues { int head; int tail; int size; int[] queue; public Queues(int arraysize) { if(arraysize<0) { throw new IllegalArgumentException("size cannote be less than equ...
Could you help me further improve this code, which includes some feedback from this site already Find common “characters” in 2 given strings (rev4)? What has changed since version 4: I re-implemented the short-circuiting of scanning the longest string argument via limit(), as suggested by @mjolka. I think that part is ...
This my first java program. I wrote this as a Nim Game so that I could learn java while writing it. I would love to see how could this be made better. Sample Game: Code: import java.util.Scanner; public class Nim { public static boolean isArrayZero(int[] arr){ for(int i: arr){ if(i > 0) return fals...
Originally posted this here, and it was helpfully suggested to post in this forum. In the past couple of years I've returned part time to programming after a 15 year gap. I was C/UNIX. So, I've picked up PHP, Java and C++ ok, but have struggled with JavaScript. Finally I think I've found a way to 'create' classes that ...
From "The C Programming Language" (K&R): Exercise 1-13. Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. I wrote a program to generate a vertically-oriented histogram. It doesn't accurately...
The program allows user to enter values for 3 of the following initial velocity final velocity acceleration displacement time and to specify an unknown (one of the previously mentioned variables). The program uses the Kinematic Equations to calculate the unknown. I would like a review of the entire program. I hav...
I admit I'm sort of stuck on this. I couldn't think of a better way of representing the card value that will be used in a playing card game. How well thought out is the casting an enum value to an int? I might be wrong but it does not seem very OOP. Is there a different way I should be doing it instead? void Main() { ...
I like toy AI and what can be better than starting from Tic Tac Toe. Basically, this is a command line program that asks the user to input the height of the game field, the width of the game field, the length of the winning pattern, the depth of the game search. (Some good configuration would be 5, 5, 4, 5, respectiv...
I made this code for a simple WinForm for my school project where I want to add other hash and encryption algorithms. I have made it following the algorithm of the official RFC 1321 and the Wikipedia page. I checked if the algorithm is correct by generating a hash and indeed it's working. However, are there any optimis...
This simple program uses a socket class I wrote, class socket, to retrieve a users pop3 emails and print to stdout. I would like feedback on the socket class and the code to download the pop3 emails. My main focus is on the simple state machine to go through the steps required to download the messages. It looks a bi...
This code draws a number of cubes on the screen selected from an array in one of three colours. How can I make it more efficient? void DrawMap(){ levelParent=new GameObject(); levelParent.name="Level"; for (int x=1;x<complexity-1;x++){ for (int y=1;y<complexity-1;y++){ GameObject go;...
I have a bash script I'm trying to distribute to people in my class. The script requires some dependencies to operate, namely wkhtmltopdf and pdfkit. I can install those dependencies with homebrew, but I can't assume users have that. I've written an install/uninstall script for Mac, and my partner made one for Linux, b...
I am developing a small website with PHP and am trying to receive user exam scores from the database. I rank it based on the highest score and then store the ranking to the database based on the user_id returned from the database with the score. I have finished the code but it's too long. I need optimizations and revie...
I've built a countdown directive for a website I'm working on, and it actually functions just fine. It simply parses a given date, splits the total time remaining until that date up into Day, Hour, Minute, & Second components places them into the DOM, and then increments down until 0 is reached. What I'm not sure of is...
I was recently given a Sudoku Puzzle to solve, and since I began solving many Sudoku puzzles after, I decided to attempt to create a Sudoku Puzzle viewer with JavaFX. I am not done yet, but have decided to split it into parts so that it is easier to fix future problems. Part 1 is the Sudoku class. The Sudoku class does...
This implementation is the result of solving exercise 4-6 "Monge Arrays" from the book Introduction to algorithms. Definition of a Monge Array: An m x n array A of real numbers is a Monge array if for all \$i\$, \$j\$, \$k\$, and \$l\$ such that \$1 \le i \lt k \le m\$ and \$1 \le j \lt l \le n\$, we have \$A[i, j]...
Challenge: Build an ad-hoc scanner for a calculator language. Specifications: The tokens for the language are as follows: assign → := plus → + minus → - times → * div → / lparen → ( rparen → ) id → letter (letter|digit)* number → digit digit * | digit * (.digit | digit.) digit * -------excluding read and write comm...
I am trying to move from Python to a systems programming language so this is a bit of a challenge for me. fn main() { let mut total_pow = 0; for x in 2..360000 { let values: Vec<char> = x.to_string().chars().collect(); let mut total = 0; for i in values { let value = i.to_di...
I am trying to calculate very large factorials. I am looking to speed it up as 10000! takes approximately a minute and a half. extern crate num; use num::bigint::BigInt; use num::bigint::ToBigInt; fn tree_fact(n: u64) -> BigInt { if n < 2 { return 1.to_bigint().unwrap(); } return factorial(1, n) }...
The codes below is in DLL. Here's the problems that I can identify: 1) Caller won't know what's the exception? 2) Catch exception 1 but throw exception 2. 3) num is not sum but overwrite. What else? These codes are in production, I just found it not well written. I would like to get more feedback and is there any othe...
Here's the second draft of my ADT stack code which I posted here before after carrying out most of the improvements suggested there. I decided to expose a function called resize_stack to adjust the size of the stack as desired by the user instead of doing it automatically. stacklib.h #include <stdio.h> #include <stdlib...
I have this piece of code that executes update scripts on the database. I have 20 .sql files that contains about 400 update scripts. The overall size of the files is around 60MB. When I execute all the update scripts, it eats up about 400 MB of RAM and doesn't free it. I'm looking for ways to optimize this code. privat...
I need to model simple account data structure. The user should be able: to add a transaction get information about transaction take all transaction of some type sum a transaction and all its children class AccountModel(object): def __init__(self): self.types = {} self.amounts = {} self.p...
Having a general utility function to see if the input is empty makes sense to me. Empty means different things depends on the type. I just spent ~5 minutes writing this one up, so I'm sure it's missing edge cases, and maybe I'm approaching the whole problem incorrectly. Function function isEmpty(input: any) { switc...
This was inspired by a Stack Overflow question about getting all the classes of an application and I took it a little too seriously (or perhaps not seriously enough). It's rather silly to do it this way, but I believe the code below is guaranteed to find every class exposed in the scope it is called from...eventually. ...
Please review the code package com.gmail.practice; import java.util.Arrays; public class StacksForTwo { int size; int[] stack; int top1; int top2; public StacksForTwo(int arraysize) { size = arraysize; stack = new int[size]; top1 = -1; top2 = size; ...
I'm having a WCF Rest service which does input parameter validation by using the IParameterInspector, before calling the actual service method. I have Implemented this functionality in my own way, but i have feeling that there may be some optimized way to implement this functionality. That is why I came here for a revi...
What the code does (tested basic, no errors, usecase): Reads all XML files (ending in .yin) from a directory. converts each to JSON store it in another directory, with the same basename as source file ... with .yin replaced by .json Overt issues: The code has too many nested functions walk module's next() method in ...
This is a follow-up of Wikipedia Trie pseudocode in Python Code quality improvements find has been fixed and a regression test ("bana" vs "banana") has been added so that it will never again be broken that way. Used ordinary instance methods when sensible (previous code suffered from staticmethods overuse). Significa...
In onion arch. we have multi layer structre: UI (User interface). BL (Business Logic / Services). RE (Repositories). UI uses BL to get data from RE with some conditions, my question is which is better approach (as standard) to get data from BL: In Repository (Data Access Layer): public class PersonRepository { Perso...
I always prefer to minimize the code, but sometimes I get into conflict with other people about the DRY concept. In this simple example, which one would be a good choice? function str_cleaner($str) { $str = trim($str); $str = str_replace(".", "", $str); $str = str_replace(",", "", $str); $str = str_repl...
I implemented the golden section search algorithm recursively in Lisp. My code is: (defconstant phi 0.618033988749895D0) (defun linemin (f x1 x2 &key (xi1 (- x2 (* (- x2 x1) phi))) (xi2 (+ x1 (* (- x2 x1) phi))) (tol 0.001)) (if (> tol (- xi2 xi1)) ...
I wrote this code for an assignment. It was originally meant to be written in Maple, but got very frustrated with some of Maple's idiosyncrasies that I decided to play around with Pandas instead. This is a very trivial multi-linear regression model, which calculates variable weights using least-squares optimisation, an...
Problem Statement The professor is conducting a course on Discrete Mathematics to a class of N students. He is angry at the lack of their discipline, and he decides to cancel the class if there are fewer than K students present after the class starts. Given the arrival time of each student, your task is to find out if...
I have a small (few elements) list of primary keys, sorted by hand. It come from user input. For example $ids = [15, 75, 54, 13]; The SQL command is simple. SELECT id, value, type FROM a_table WHERE id IN (15, 75, 45, 13); This is SQL, so the order of output may be random. I want to restore it in PHP. My first attem...
I am a new .NET/C# developer and one issue bugs me ever since I've wrote code the first time. How can I improve this code? Program.cs: class Program { static void Main(string[] args) { App(); } public static void App() { BankDetails bankdet = new Bank...
I have written a NodeJS module and its tests to generate a URL, shorten it with Bitly, insert the short link in a tex file, compile these tex files to PDF and then merge them into one. The code is working but it looks confusing and the tests are too hard to follow in my opinion. I'm not sure if I should mock fs to avoi...
This is a project I've been working on for a while. It's basically Cleverbot. What do you think? import java.util.Scanner; import java.util.Random; public class Cleverbot { public static void main(String[] args) { String choice; Scanner user_in = new Scanner(System.in); /* add "why" to all, with answer being,...
I have two tables Room and RoomDate. Here's the structure for Room Room roomID checkInDate checkOutDate roomType Here's the structure for RoomDate. They have a one to many relationship. RoomDateID checkInDate checkOutDate RoomID // foreign key Now I want to find how many rooms per roomType are available in a specific...
I want to build a grid and I have 2 concepts: Grid which is consist of Cell. Grid class is: var Grid = function (rows, columns, cellInit) { var canvas = create_canvas(); this.context = canvas.getContext('2d'); this.matrix = new Array(rows); for (var x = 0; x < rows; x+=1) { this.matrix[x] = new...
It's taking my machine quite a long time to execute 1 billion (1st loop x 10, 2nd loop x 1000, 3rd loop x 100,000) instructions. Suggestions for performance enhancements? Sources of potential concern: global variables slower than local variables? using for loops instead of something like map? overhead for class instan...
For a small personal project, I am looking to convert an object to an ordered by SemVer Markdown list. You can find the original code for the sort logic here and here for the writing into Markdown logic. I merged them to a full working snippet. I am using C# 5 in .NET 4.5.1. Basically, the goal is to transform this: va...
I'm brand new here, but I've read the guidelines and looked at some up-voted questions. Hopefully I understand how I'm supposed to do this... if not, please let me know and I'll fix my question. Explanation I have written a simple javascript plugin of sorts. It takes the settings object for a jQuery.ajax request and a...
type Suit = Club = 1 | Diamond = 2 | Spade = 3 | Heart = 4 type Rank = Two = 2 | Three = 3 | Four = 4 | Five = 5 | Six = 6 | Seven = 7 | Eight = 8 | Nine = 9 | Ten = 10 | Jack = 11 | Queen = 12 | King = 13 | Ace = 14 type Card = { Suit:Suit; Rank:Rank } let RandomHand (size:int) = let rndSuitIndex (rng...
I've spent some time writing a library to parse JSON into a statically typed object. Am I following most of the standard coding guidelines? Any thoughts on what I could do better, or any edge cases that are missing and aren't taken care of? private static T ParseDynamic(ExpandoObject input) { //Parse when given a...
I usually write Euler solutions in Javascript. On problems requiring very large integers I have decided to learn Scala and take advantage of BigInt. I wrote a solution to Euler025, it works fast but reads like Javascript. Will the reviewer please comment on how to write this solution more idiomatically and, if you have...
I'm currently running through some Cracking the Coding Interview questions and my solution to 4-4 is quite different from any of the given solutions. The question asks to determine if a given binary tree is balanced; more specifically, if the difference between the maximum and minimum depths within the tree is less tha...
I have a list of patients, Patient class has Prescriptions property, which is a list of Prescription objects. Prescription has 3 important attributes, Medicament,Amount and Type(which is basically a key for joining). I need to join a list of Prescription types, as a prescription type has an attribute Influence which se...
Still oiling my Forth. Below are few essential algorithms for in-place merge. Please review. Some introductory comments: >swap< is not a cute smiley. I am trying to tell that two pointers are going towards each other at each swap. rdrop drop looks hideously ugly. Any suggestions? lower-bound and upper-bound must be un...
This is my code for a very basic video game I created today. I did not create this to be a fun game to play. I created this to test my skills on conditional coding, etc. Please critique this. // Created by Andrew Tew // My Test Studio #include <iostream> #include <string> using namespace std; int main () { string yay...
I am trying to experiment with golang. This code spins off two Go routines: one to download data and another to read from the body. Both go threads are synced by the data channel. I have two questions: Should I have to dispose the body inside downloadData method? Is this type of coding acceptable in Go? package main ...
Problem Statement You are given N sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the smallest stick. Suppose we have six sticks of the following lengths: \$5, 4, 4, 2, 2, 8\$ Then, in one cut operation we make ...
ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is a special case of the Caesar cipher, developed in ancient Rome. ROT47 is a derivative of ROT13 which, in addition to scrambling the basi...
I have a class which takes the method address and arguments, and executes it later when told to do so. ' need to turn option strict off due to Execute method executing late-bound code Option Strict Off Public Class WorkItem Private Action As Object Private Args() As Object Public Overloads Sub [Set](actio...
I'm wondering if this code can be simplified. I'm less than thrilled about the fact that I repeat the Draw method in both CatModel and DogModel. For that matter, I'm not real happy that that method is even in the models at all. Trying to move it up to the AnimalModel superclass forces a cast. EDIT: The "Model" classes ...
I'm a beginner to web programming and just started a MVC project from scratch. Because this will become a large project eventually, I would like to make sure that I'm doing things kind of right from the beginning. The architecture is the following: ASP.NET 4.6, MVC 5, EF 6, Identity 2.0. I'm using EF Database First ap...
Since the repetition mode didn't make to HTML5, I was wondering how to succinctly implement it in Javascript. I've already spent a few hours on this jsbin. Be great to get a review. <button onclick="addRow();">Add row</button> <label>Pence per kiloWatt hour <input id="price" required type="number" step="0.1" v...
I have been trying to convert a string of dictionary objects as given below "{'Cmd': None, 'Hostname': None, 'Entrypoint': None, 'Env': None, 'OpenStdin': False, 'Tty': False, 'Domainname': None, 'Image': u'nginx:latest', 'HostConfig': {'Binds': None, 'RestartPolicy': {}, 'NetworkMode': u'bridge', 'Dns': None, ...
I've got a VARCHAR variable of this kind: @string = "BLABLA10;GOGOGO30;RES777;ANOTHER;" (several keyword + number separated by ;) I need to get the INT value after "RES" in a T-SQL query (using SYBASE). I thought it would be always 3 characters, so I did: SELECT @val = CONVERT(INT, LTRIM(RTRIM(SUBSTRING(@string, CHARI...
This is the Tractor problem from the Kattis problems archive. Problem Statement Bessie the Cow has stolen Farmer John’s tractor and is running wild on the coordinate plane! She, however, is a terrible driver, and can only move according to the following rules: Each of her movements is in the same direction as either t...
I tried to sample up a logging class from this question and answer(I want to use this class from C# DLL). Made slight modification mainly to file name, and also how data is written. I am interested if this can be considered thread safe logging class? I am particularly concerned by the comment under the answer. See belo...
I've written this Python script to make regular backups of a Linux server. It works pretty well except that the script sometimes backups files more than one time, which is pretty strange and I don't know why that happens. But that's not the key point of my posting here (just someone may see a little error I've made whi...
Problem description: The task is to calculate the amount of money earned from roller coaster rides on any given day. There is a queue in front of the attraction. Visitors might be alone or in groups. All members of the same group will want to ride together. The ride begins once the roller coaster runs out o...
When it comes to the Umbraco CMS, there are components called "Macro-Scripts" which are essentially a Razor View (.cshtml). They allow you to code a bunch of C# and HTML in a page and display this "Macro-Script" on any CMS page that you choose. In my tutorial (which I completed well over 2 months ago), I thought I reme...
I've been starting to learn Rust by going through some of the Rosalind String Algorithm problems. If anyone would like to point out possible improvements, or anything else, that would be great. There are a couple of things I'm especially curious about noted in the subs and lcsm solutions. main.rs: mod utils; mod string...
Please review this code, considering I put emphasis on constraining space complexity at the expense of execution speed (accepting additional branching). Can you see cases that prove the algorithm incorrect? Could you improve its execution speed without increasing space complexity? Could you make it more readable? Met...
Is there a better or shorthand way to perform a check on whether or not a variable within (possibly several levels of) an object is null or undefined? What I would currently do to check is: if (typeof json !== 'undefined' || typeof json.data !== 'undefined' || typeof json.data.formkeys !== 'undefined') {} Is there a s...
I'm trying to add a link to a page. The link should contain the current URL in a querystring (to be used as a ReturnUrl) and it can contain a hash. Middle-clicking, right-clicking and ctrl+clicking should be supported. For example, middle-clicking will open the link in a new tab with (or without) the querystring. Is t...