instruction
stringlengths
71
71.9k
Below is a function that adds a new user to the database using their email and password. I am using Flask and SQLAlchemy. @app.route('/users', methods = ['POST']) @require_appkey def registerUser(): errorsList = [] userInfo = request.get_json() # Get "email" and "password" email = userInfo.get('email')...
I am trying to understand good design patterns in Python and I cannot think of a way to break this huge function into smaller parts without making the code cluttered, overly complex or plain ugly. I didn't want to clutter my question by posting the whole file. This function itself is already very large, but the class h...
The code below takes a String and encrypts it using AES/CBC/PKCS5PADDING as transformation. I am learning as I go and I have a few questions about my code. Is SecureRandom ok for generating my KEY and my IV? What's up with all these exceptions? Is my code creating any vulnerabilities in the encryption process? (mista...
I've got a function that's executed in a game loop. There are a couple of checks that are really only necessary during the first pass of the game loop. How can I remove these? There is more code like this, but this is the shortest example. public void Update(Frame rawBodyData) { //Catch the first pass, where RawBod...
I'm going through the book Introduction to Algorithms. I made a comparison between merge-sort for an array of integers versus a vector. Could I have structured this program better? Why is the vector version so much slower? Sorting 2 million integers with a vector type took almost 2 seconds but sorting the same list ...
I'm currently learning C# as first programming language and I've made a simple program to exercise the basic concepts. It's nothing fancy especially compared to advanced stuff you normally talk about, but I would like to know if I've made some common mistakes or I missed some good practices. Basically I created a log-i...
I've got a project I've been working on that connect to a file server and writes some data to a text file. In order to do this I added a textbox for the user to type their username and a passwordbox well for the password. In my models I have an interface called IPassword that looks like the following: public interface ...
In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one HelpersContainer that contains all helpers. Any helpers must see any other helpers. //1 network peer = 1 GamePeer object class GamePeer { HelpersContainer helpersContainer = new HelpersContainer(dbWorker...
I've written my first Python program longer than 15 rows and, of course, it looks terrible. I'd be very glad to receive comments and suggestion about how to implement a similar tool correctly. #!/usr/bin/python # -*- coding: utf-8 -*- # This script imports the csv data into a mysql database import csv import MySQLdb ...
So I was doing something which creates an airplane with an actual airline code, number, airplane type and so on. The airline code and airplane type are stored in a txt file so I can add more later to my leisure... but the code I came up with to get a random line is extremely messy. Is there a better way? I searched all...
Here is my implementation of double linked list. Is it possible to reduce the code and improve it? Some methods here: head (returns head of the list) tail (returns tail of the list); append (param: new data; add new item to the end of the list); deleteAt (param: index; deletes item by index; error handling) a...
The program takes census data from a text file in the format age, gender, marital status, district. It then gives a list of residents by district (there are 22) and by 5 age groups. Any suggestions for improvement? The only topics we have covered so far in class are methods, decisions, looping, and arrays. static void...
I've written my first implementation of quicksort in Java 8. Please let me know of any improvements that I can make (e.g. whether I'm creating any Lists unnecessarily). Also, when I try to add elements directly to the leftArray, I get a ConcurrentModificationException. Doesn't subList() create a new List that's separat...
I have an implementation of a quad tree and abstract collision detection classes. The code works but looks very ugly, but I don't know what I could change to make it better. The reason I used two interfaces instead of just extending an abstract class is because the classes which will use this are render objects and hav...
A game I've created to implement everything I've learned and to further build upon. I just recently learned classes so I'm probably using them wrongly. Every bit of criticism is appreciated, I don't want to create bad habits. Edit: My game draws up a field / map of symbols and characters which represents the playing fi...
I have the following but it takes long time to run, it is a simple wherein the user select a file and data from Sheet1 is copied to another workbook. Sub ImportApp(ByVal filepath_Report As String, file_name1 As String, wsOutput As Worksheet) Application.ScreenUpdating = False Set wbReport = Workbooks.Open(file_...
I'm looking for feedback on this live-filter I wrote in JavaScript. You can test it using the included snippet. (function() { var searchField = document.getElementById('filter'); var handler = function() { var text = searchField.value, nodes = document.getElementsByClassName('phase'), regexp = ne...
I'm really a newbie with code, and I wish to prepare all my statements to avoid SQL injection. I have searched a lot on the internet, but this wrapper/API doesn't look anything like the examples given. And I'm not yet skilled enough to fully understand how I should rework it to fit mine:) This is my code <?php /** * p...
I have created JavaScript code using REST API for getting the username of a SharePoint user from an active directory if you know the ID. Please suggest any improvements. // get user name from id function getUserFromId(userid) { // var userid = _spPageContextInfo.userId; var requestUri = _spPageContextInfo.webAbsolu...
In my very specific scenario, I need to get an NSDate holding the next time the hour will be 7 (either AM or PM). On the case that this is the first time to do this, I need to jump extra 12 hours (e.g., if I got Apr 1st 7AM - to jump it to 7PM). After playing with playgrounds I was able to achieve what I believe solves...
I have made my first app in Android Studio. I made a compass using a sensor-listener. I would greatly appreciate if someone could review my code (it is very short), and suggest improvements. My XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" ...
I asked this question on StackOverflow, got some answers, most notably a link to this one, and basing on that I've implemented this: {-# LANGUAGE RankNTypes #-} {-# LANGUAGE FlexibleContexts #-} module Main where import Control.Monad.State import Control.Monad.IO.Class -- Module -------------------------------------...
I'm using MVC in order to generate a couple of views within my webpage. For a way of logging in, I've decided to use Asp.net's Identity, which I am very happy with. However, I'm trying to find an efficient/ 'normal' way of testing if the user is logged in, and are looking at info that refers to them. As a test, I found...
The code below attempts to extract incomplete weeks from a List<DateTime>. For example, a list containing all the days in Jan 2015 would result in the 5th to the 25th inclusive. I know the list going in will contain unique dates, and are in date order. It seems to be working but I can't help but think this could be don...
Here is the interface of my generic dynamic array; /* dynamic array interface */ #ifndef DA_HEADER #define DA_HEADER #include <stdlib.h> /* size_t */ /* creates a new dynamic array, with each element of "size" bytes */ void *danew(size_t unitsize); /* returns pointer to element after the last element */ void *daend...
This is designed for a high performance complex log analyzer. Very simple idea: read a file line-by-line as fast as possible. I would appreciate any hints what should/could be improved in this code. GitHub FastLineReader.h /* Copyright (c) 2015 Simon Toth kontakt@simontoth.cz * Lincensed under the MIT license: http://...
I am very new to Python, and also this is my first time trying to parse XML. I am interested in information within str elements. I can identify that information using the str@name attribute value. def get_cg_resources(pref_label, count=10): r = request_that_has_the_xml ns = {'ns':"http://www.loc.gov/zing/srw/"...
I am working on an API that is mostly intended to be used interactively/little scripts. There are some classes with methods that could act slightly differently depending on the intention of the user, I have explored several options and would like to get some feedback on caveats, and alternative options. I will use a si...
I have a class with a data member that needs to be rounded up to a 2 digit integer, irrespective of the number of the input digits. For example: roundUpto2digit(12356463) == 12 roundUpto2digit(12547984) == 13 // The 5 rounds the 12 up to 13. Currently my code looks like: int roundUpto2digit(int cents){ // convert...
We use this class quite a bit for boilerplate / glue that allows web services and applications to call databases. This code is very important, and I'd like to ensure I'm getting the best performance possible. Any and all feedback is welcome! If there is a better / more efficient way of doing something, please let me kn...
I have a binary file with alternating uint8 and uint64 data stamps. I read those in by using the following line: clicks = np.fromfile(filename, dtype=[('time','u8'),('channel','u2')]) This works well and fast enough. Now i want to go though the array and set the time values to the time difference with respect to the l...
I'm trying to output the percentage of certainty of two comparatives data. Here's the resulting code: /** * Original code from https://vwo.com/js/significanceCalculator.js */ function calculatePValue (c_t, c_c, v_t, v_c) { var d1 = 0.0498673470, d2 = 0.0211410061, d3 = 0.0032776263, d4 = 0...
If classes provide __slots__ and at the same time inherit from another class also providing __slots__, there is no straightforward way to access and list each and every slot of the class. Especially when you consider chaining of inheritance. I've written this meta-class that adds the __all_slots__ property, listing all...
This, again, is a very simple code. This is my 2nd polyglot question and this time I've tried to do something that I miss sometimes in Javascript. PHP has the array_sum() function, but Javascript has no direct equivalent. So, I decided to make one that works with both languages! Here is the code: function sum_array() {...
I've made a small project from my institute. I've got 5 classes, in 4 of the classes (Teachers, Students, Group, Subject). I've got a constructor and get&set methods. In the main class I've got an all functional realization. How can I make this code better and easier to use? package com.company; import java.util.*; p...
I have an app that uses HTML5 video and our customer still needs to support IE8 - Gross. Anyway, I came up with this directive in AngularJS for embedding a SWF object for when I need to fallback to Flash. It works fine so far, but I would like to see if there is anything I can do to improve it. Can anyone see a case wh...
I'm trying to separate logic from the controller, so I created this Upload class. It is not a big class, just a class so that the controller doesn't know about the logic and stuff like that. <?php namespace Dnianas\Uploads; class Photo { /** * The image filename. * @var string */ protecte...
I am trying to make sure my client-side code does not send another request before it receives a reply. To the best of my knowledge the code I will post is supposed to do this but I am still getting a -1 for $return. The AJAX request repeatedly gets the echoed value of a function which is using a batch file to get the s...
I took a test on Codility for coding the minimum number of frog jumps to reach from position x to position y: A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance,...
I came across this post which explains the copy and swap idiom. However I could not find this idiom applied to classes that have base classes. Following is my attempt of a copy-swap idiom applied to class constructors and assignment operators. In the following code class employee inherits from class human - The constru...
I wrote a quick and dirty auto-clicker for the StackEgg. Any comments, both on code and effectiveness? function doRound() { var stats = []; $(".egg-stat").each(function () { // Find the number of hearts for each stat. var title = $(this).attr("title"); title && stats.push(parseInt(title,...
Inspired by this question on Stack Overflow, I wrote a function that returns the length of a list made of numbers that are divisible by their own sum of digits inside a range: -- Returns the digits of a positive integer as a list, in reverse order. -- This is slightly more efficient than in forward order. digitsRev :: ...
Given an array of ints, return a string identifying the range of numbers. Example: Input arr - [0 1 2 7 21 22 1098 1099] Output - "0-2,7,21-22,1098-1099" Is there any improvement possible in this implementation? #include<iostream> #include<vector> #include<algorithm> #include<sstream> std::string range_creator...
I have been writing a Simple Port scanner in C, once I got it to work I decided I wanted to make it faster because it takes a very long time for it to get done with scanning all of the ports.Is there anything I can improve on in my code to make it faster? Here is my Code : #include <string.h> #include <stdio.h> #inclu...
I thought of a simple way to hash a string. By taking the ASCII decimal value of each character, multiplying it by 10, and adding all of the values computed together for each character in a string. Is there a name for this algorithm? I highly doubt I was the first one to think of this. Compiled with gcc -Wall -Wextra -...
I'm trying to solve this problem. Given a sequence \$B=B_0,B_1,\ldots,B_{N−1}\$ for each query \$(P,K)\$, find the minimum \$S\$ s.t. there are at least \$K\$ entries in \$B\$ that satisfies \$\left|P−i\right| \le S\$ \$B_i \le S\$ where \$B_i\$ denotes the \$i^{th}\$ entry of \$B\$. Input The first line contain...
I got bored and decided to make a merge sort from scratch. I like everything, except for my "merging" of the two arrays into a sorted array inside the for loop. I had several bugs that I had to iron out, which were along the lines of if subArray1 or subArray2 ran out of elements, checking them caused ArrayOutOfBounds...
I have a seat allocation algorithm for an airplane 30 x 6 seats. The plane is 'split' front (1 - 15) and back (16 -30), right (A,B,C) and left (D,E,F). I am placing passengers in window seats front right centre (15A) first then back left centre (16F) followed by (15F) followed by (16A). This will continue for single pa...
Basically, we came up with this task at work. I was wondering if there's a shorter and cleaner way of doing the following in some other language (or even improving what I did with Ruby). We have a folder. In this folder we have files (images only, /w .jpg extension). The names of the images are random strings such as: ...
I want to change the task edit form of the workflow when an approver wants to approve/reject a task. Please review and suggest improvements or any other possible solution with an explanation. public void createTask1_MethodInvoking(object sender, EventArgs e) { createTask1_TaskId1 = Guid.NewGuid(); ...
I'm trying to make a simple app to help me store data about food to use this database in a future diet application. What can I do to improve the code? What part of code should I make a class etc.? #include <iostream> #include <vector> #include <string> #include <map> #include <iterator> using ...
The following is a program to shred files securely: #include <iostream> #include <sstream> #include <string> #include <fstream> #include <vector> #include <cstdio> #include <cstdlib> #define BOOST_FILESYSTEM_NO_DEPRECATED #include <boost/filesystem.hpp> using namespace std; using namespace boost::filesystem; static...
I created a jQuery plugin that converts a text field to a 3 drop down, datepicker. It allows the user to select a Day, Month and Year rather than type the date in an input box. The original input element is hidden and a callback function is provided where the user can format the value for the input box. The id and name...
I'm learning Java, and would really appreciate any tips on how to improve this code. It's just a simple date validation class. import java.util.Map; import java.util.HashMap; class DateValidator { private int day; private int month; private int year; private enum Months { JANUARY(1, 31), FEBR...
I am testing what knowledge I have with the FizzBuzz tests in Java. This is the one I just completed: Given a string str, if the string starts with "f" return "Fizz". If the string ends with "b" return "Buzz". If both the "f" and "b" conditions are true, return "FizzBuzz". In all other cases, return the string unchang...
Given two strings, find the common characters. Is there better implementation for this problem? #include<iostream> #include<string> #include<algorithm> std::string find_intersection(std::string & first, std::string & second) { std::sort(std::begin(first),std::end(first)); std::sort(std::begin(second), std::e...
Although I have been coding in PHP for a while now I am trying to go back to basics with some things to make sure by understanding and methods are the most efficient. I have the following snippet... if (!empty($_GET['location'])) { $location = $_GET['location']; } else { $location = ''; ...
I'm looking to improve my code as seen in the demo link below. The code displays a list in a tooltip. The tooltip is accessed by hovering over the last element of the main list. Here's the demo. The ultimate objective is to wrap only one of the below list item in the code in a JS for loop which will dynamically create ...
I am trying to write an REST API using php from scratch which I am gonna use to play with Angular.js. It is working fine now and I need your opinions on the things I have done in this code to improve myself. NOTE: I am not going to use the below code in production and I am not recommending anyone. I am just trying to l...
I try to make a middleware stack system in the rack way (but not for HTTP request). Here is the main class: class MiddlewareStack def self.stack middleware @middlewares ||= [] @middlewares << middleware end def self.middlewares @middlewares end def self.next payload next_middleware = @midd...
I was having a chat with a friend about data structures (as you do), and that, and his love of portmanteaus meant that he came up with a Quack - A queue and a stack, stuck together in the dumbest way, as it just gives you a tuple of the front and back items. I thought that it might be at least possibly useful if it was...
I'm fairly new to object oriented programming here and am trying to get my head around the best way to go about creating Users and Validating them in the system. My first attempt is below and my main questions apart from does it all seem correct is in regards passing a validator class to the save function and pros/cons...
I would like you to review the solution I came up with to the following scenario: In attempting to model a generic Repository object (that receives a generic type parameter) to interface with my data store, I created an abstract RepositoryBase class, that receives a DbContext parameter in the constructor, and implemen...
I have a C library written by a third-party company. It calculates photo positions on a book page, position of a photo inside an area (which part of the photo to crop), it fills a book with random photos... I have created a .Net wrapper around the C library. I'm very new to C++ so I don't know the conventions (naming, ...
I have a string array: def invoices = [LEDES98BI V2, LINE|INVOICE_DATE|INVOICE_NUMBER|INVOICE_TOTAL, 1|20150301|INV-Error_Test1|22, 2|20150301|INV-Error_Test1|24, 3|20150301|INV-Error_Test2|26, 4|20150301|INV-Error_Test2|28,] I tried to convert it to HasMap<String, List<List>> with key as invoice numbers(INV-Error_Tes...
I'm trying to implement a suffix array for use in programming competitions. I'm using the CodeForces example and trying to "make it my own" so I can make sure I understand it and feel better about using it. Here's what I have so far: struct SuffixArray { vector<int> sa, pos, tmp; int n, gap; SuffixArray(st...
I have just started learning data structures and for the past two days I was going through linked lists. I have implemented the basic/common operations on the linked lists and I would love for some feedback and discuss best practices. P.S: I will also try the STL method, but for starters I did this. /* A list of th...
I'm hoping for a little bit of a code review to ensure I am doing UTF-8 right. I am developing a "csv_fixer" that allows a user to select the encoding of the file so we can correctly handle encoding errors. Also, there is a choice to skip this, in which case I am just removing the fields that have encoding errors. So ...
I have an application that runs hourly, and I want to use it to also send an email at the start of the day of the first Monday of the month. I searched and found information to help me code what I needed, and all my tests pass, but I want to make sure that I am testing for all edge cases and that I am also being a goo...
In my current project I develop a responsive site which has only on desktop a fixed width. Otherwise it's fluid. My client or rather my art director ;) want's fluid bullets with horizontal and vertical centered content on the site. To illustrate that I created a dabblet. Here is my HTML for the bullet: <div class="ib">...
Disclaimer: This question is very much like the one posted here. I gathered some opinions about my options from the answer there. Here, I just want validation about the choices I'm deciding to stick to and see what people think about the decisions specifically. Also, gather suggestions about other parts of the code I'm...
I need to convert a list of dictionaries to a dictionary of dictionaries, with a particular item as the new key. This is the way I'm currently doing it: >>> a [{'bar': 'baz', 'id': 'foo'}, {'bar': 'baz', 'id': 'qux'}] >>> { item['id']:{ sub_item:item[sub_item] for sub_item in item if sub_item != 'id' } ...
Is there a cleaner way of doing this? I'm using filter_input to first check for valid input, then using it again to assign the variable. Also, my condition in if/else seems quite long. $optionsMonth = array('options'=>array('min_range'=>1, 'max_range'=>12)); $optionsYear = array('options'=>array('min_range'=>1900, 'max...
Is the below a good solution for an observer to monitor multiple subjects. My only fear is that if an observer was monitoring a wide range of subjects then the update method could get quite large checking each instance to see what type it is but I can't think of another way to implement this: Journalist Subject cla...
My program fetches input from a RabbitMQ or Amazaon SQS-like queue. There is not always input available in the queue. If a message is available, it triggers work. If that work is successful, message needs to be deleted so that work is not repeated. If work is unsuccessful, message needs to be made visible again, ...
Here's an implementation of finding the minimum element in a rotated array using binary search (one that is sorted in ascending order, and all elements are distinct). Please let me know of any improvements that can be made to it. import java.util.List; public class RotatedArray { /** * Finds and returns the i...
I'm a C++/Python developer attempting to learn JavaScript, but I'm struggling to write clean code. I've read that async.waterfall and Promises are two ways to flatten the code a bit, but my implementation seems far more inflated than what I've grown accustomed to using Python. Is there anything that I can do to refac...
I have a CommunicationStateMachine object that's attached to my channels. It keeps track of who's turn it is to speak, how far along the conversation the server and client are, things like the client ID, all bytes read to date, the ByteBuffer etc. My previous version of this server did some checks in the Selector thr...
I want to write unit-test to my code. However, while writing it, it seems all I can verify is that one method or the other were called once. My class is a manager that execute verification flow. It calls many checkers\verifiers - so they have the real logic. How can I test such "verification flow" code? public Alternat...
I am trying to build a high performance socket server and this is what I have come up with so far. Can anyone please review my code and see if I can make any improvements on it? // State object for reading client data asynchronously public class StateObject { // Client socket. public Socket workSocket = null; ...
Problem Statement This is a challenge from HackerRank: You are given N sticks, where each stick has the length of 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 T...
<script> <?php unset($data0); unset($data1); unset($data2); $sth = $dbh->prepare(" SELECT a, b, c FROM t "); $sth->execute(); ?> Morris.Line({ element: 'morris-line-chart', data: [ <?php while ($row = $sth->fetch()) { ?> { m: '<?php echo $row['0']; ?>', a: <?php echo $row['1']; ?>, b: <?php echo $row['2...
I read through and implemented the advice I received yesterday. I would, once again, really like some input on how this can be improved. e.g. encapsulation, interfaces, abstract classes etc.. Right now, it's one class. import java.util.Map; import java.util.HashMap; class DateValidator { private static DateVali...
I'm looking for suggestions to improve my accordion code. Someone could also use it as a starter for their code. Here's the demo. var Calendar = function(o) { //Store div id this.divId = o.ParentID; // Days of week, starting on Sunday this.DaysOfWeek = o.DaysOfWeek; ...
Am trying to update the Map<String,List<Map<String,String>>> invoices with the invoiceErrors as below InvoiceError // is an entity with below attributes { String errorMessage, String invoiceNumber } ErrorMessage invoiceNumber ------------- ...
I have the below script which returns CSS files based on production or development environment. The development section is fine; but for production I have to do 2 loops to get the files. Is there a cleaner/better way? function get_css_files() { $CI =& get_instance(); $return = array(); $css_files = array( ...
Lets preface this by saying that when it comes to javascript, I am a hack. I make what I need happen by cobbling together crappy, inefficient, redundant code. I want to get better. Recently I was asked if I could make a set of elements on a page sort-able by price, A-Z and Z-A. The code on the page looks something like...
I'm tempted to write a new kind of smart pointer which, I believe, is less intrusive than boost::intrusive_ptr and has the same memory footprint. The code for the smart pointer, which I called less_intrusive_ptr, is shown below (the boost version used is 1.57.0): #include <utility> #include <boost/intrusive_ptr.hpp> #i...
I've received a request at work and the senior developer is away on vacation so I can't ask him. The request was to truncate lengthy article titles while maintaining readability. In other words, don't simply chop a word in half and add an ellipsis. I wrote an extension method that looks for punctuation and establishes ...
Recently, as part of an interview, I was given a (seemingly) simple code prompt: To simulate a Bank with 5 customers and one teller, allowing them to deposit to and withdraw from their accounts, but with each customer on its own thread while only allowing one to access the teller at any given time. I've a CompSci degr...
I was just curious to know what you think about this website I'm designing. I would just like any constructive feedback that you might have. http://jackatron.web44.net/music/ @import url(http://fonts.googleapis.com/css?family=Lato); html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote,...
I've used the typical INT array sort function found all over the internet for years, but I've also had a need to sort other items in an array, or even to just simple take an Array of multiple types of items and get it in order for later readability. Thus leading me to the smartSort method I list below. If I've anything...
I was wondering why replace is not in base. I thought, it's because it must be easy to implement with standard combinators. Although I do not like prefix syntax of Applicative I wrote it this way: replace a b = map (bool <$> id <*> (const b) <*> (== a)) And was slightly surprised after seeing replace in Data.List.Util...
I created a simple login system using just sessions but having to login every time gets annoying. That is why I'm no trying to save the sessions to my database linked to the user's account. I will first show my code and than ask a few questions. First file which is the new file I created is this one named sessiontest.p...
This is my attempt at writing a generic NSMapTable with weak keys and strong values (after your feedback I'll be trying to write Strong-Key/Weak-Value and Weak-Key/Weak-Value variants to have the complete functionality of NSMapTable with generics). To my knowledge it works correctly. public class WeakKeyDictionary<K: A...
I'm new to C and I've been working on some code for a project for school. This was the finished result and now that I'm done it, I came back and tried making it better. So I was wondering, how would I make this printAvgCalPerGroup simplified? #include "diary.h" void printTotalCal(Food * list) { int total = 0; ...
I am trying to bridge the gap between the database context and routes that are stored in the database. The factory is designed so that when used in other assemblies, you are forced to use the database context which is known to contain the DbSet which can provide the required data to populate the route. In the assembly ...
I have just started learning coding and am trying to clean up a website that I am making. Everything is functional, but I imagine there is a better way write everything that is there, because a good chunk of it is repeated each time (the part with mouseover and mouseout) Is there a way to create a command like mouseove...
Is this approach considered good practice, or should I create separate router.delete functions for all my routes? Please, explain why. router.delete('/delete-:object', function(req, res) { var query; var id = req.body.id; switch (req.params.object) { case 'news' : query = queries['news_dele...
I'm taking part in this Daily Challenge on http://www.reddit.com/r/dailyprogrammer/comments/29zut0/772014_challenge_170_easy_blackjack_checker/ Basically, you have to develop a program that runs two blackjack players and outputs the winner, the user has no input on the player's choices - basically it's all AI based. I'...