instruction
stringlengths
71
71.9k
I am using a std::priority_queue to implement Dijkstra's algorithm: while(!Q.empty()) { u = Q.top().first; Q.pop(); int size=G[u].size(); for(int i=0; i<size; i++)//tle { v = G[u][i].first; w = G[u][i].second; //cout<<u<<" "<<v<<" "<<w<<endl; if(d[v] > d[u] + w) ...
This is my homework. Kindly help me check it? The instructions are: Implement an infix expression to postfix expression converter. You are to implement the infix to postfix algorithm presented in the lecture. You are to use only the stack that was provided in the lab lecture. The use of the stack of JDK or any other ...
I have a WCF service that itself uses another third party WCF service. It's basically a proxy. So I'm getting a request to my own one and I have just to "forward" it to the third party one. I would like then to map from my flattened request (that's the way it's been decided to be coded) to the slightly more complex req...
Given a Binary Tree, extract all leaves of it in a Doubly Linked List (DLL). Note that the DLL need to be created in-place. Assume that the node structure of DLL and Binary Tree is same, only the meaning of left and right pointers are different. In DLL, left means previous pointer and right means next pointer. The qu...
Given a binary tree, a complete path is defined as a path from root to a leaf. The sum of all nodes on that path is defined as the sum of that path. Given a number K, you have to remove (prune the tree) all nodes which don't lie in any path with sum >= k. Note: A node can be part of multiple paths. So we have to delet...
If the linked list is 1->2->3->4 then the output should be 1->3. If the linked list is 1->2->3->4->5, then the output should be 1->3->5. The question is attributed to GeeksForGeeks. I'm looking for code-review, best practices and optimizations. public class DeleteAlternate<T> { private Node<T> first; priva...
I was inspired by Me How's question to see how far I could push an imitation of .Net's Enumerable Class. The new functions can obviously handle Collections, but can also handle any collection-type object whose items have a default value. If a collectionObject's items don't have a default value, Runtime Error 438 "Objec...
Description If you install this hook in your repository and push branch foo-automerge to this repository, this hook will merge this branch into working copy if: currently checked out branch is named foo. working directory is clean merge would be fast-forward Reasons why I need it are outlined on my question on SO ...
A while back I posted Wrapper for jquery ajax to ensure redirects occur on clientside on handling ajax and redirects when a server side error occurs. Since that post I've been using this module extensively (in MVC.net projects) and it works really well in conjuction with some serverside code to help implement the redir...
I have created a nice little image gallery for the web. I set out wanting 3 things. 1. The whole gallery had a basic level responsiveness to it. 2. The gallery would take images of any size, and display them without cropping. 3. The gallery would run automatically. If you look here(JSFiddle) I have done just that. The ...
I implemented this merge sort in JS and noticed that for random integer numbers it's a lot faster than the build in sort functions of all the browsers I tested (Chrome, FF, IE). Does anyone have an idea why that is? Also, is there a way to make my code even faster? function bubbleSort(f, a, start, end) { end--; ...
A piece of my program allows the looping and incrementing of a targeted entity to be used in a while loop somewhere else. Here is a sample of the while loop: while (state.World.Looping(reqComponents)) { TimerComponent timer = state.World.GetComponent(TimerComponent.Type); if (timer.IsActive) { time...
I'm working with a Rails app that requires a few layers of infrastructure to run: MySQL, Redis, Sidekiq, and (of course) the Rails server. I wrote some functions to help me manage the various servers (start/stop/check and one to kill the rails server when it gets hung up and decides to eat all my memory rather than shu...
I have two data frames/ lists of data, humanSplit and ratSplit, and they are of the form > ratSplit$Kidney_F_GSM1328570 ratGene ratReplicate alignment RNAtype 1 Crot Kidney_F_GSM1328570 7 REV 2 Crot Kidney_F_GSM1328570 12 REV 3 Crot Kidney_F_GSM1328570 4 REV and ...
I am looking for a review of my recursive function that generates the permutations of a string. Are there better ways to do this? var permutations = []; function doPerm(str, arr) { if (typeof (str) == 'string') str = str.split(''); if (str.length == 0) permutations.push(arr.join('')); for (var i = 0; i < s...
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. My solution: #include <stdio.h> #define TOP_LIMIT 1000 float sum_of_series(float start_from,float position,float difference) { ...
Description I think many many people have seen this youtube video "15 Sorting Algorithms in 6 Minutes" When I saw it, I decided: "I can do that better" and I tried to get things done with the tools at my disposal back then. Windows Forms and C#. I added a functionality to allow the pausing of sorting in any point of ti...
I have a plain text file with the content of a dictionary (Webster's Unabridged Dictionary) in this format: A A (named a in the English, and most commonly ä in other languages). Defn: The first letter of the English and of many other alphabets. The capital A of the alphabets of Middle and Western Europe, as also the ...
In this iOS app I'm working on, there are two landing screens shown to the user depending on a particular status. The screens are Login screen and Activate screen. Let me explain what this Activate screen is. There is something called activating users. It's done by a web backend and the app has no control over it. Eac...
How should I deal with ViewModels that are "fat"? Or should I just accept it sometimes. Example - one of my ViewModels (editing image page, almost 300 lines of code) which has a lot of UI commands like cropping, quick image filters (like contrast, brightness), undo, redo etc. public class ImageEditViewModelWinRt : Shar...
In an attempt to try something new, and possibly help out at work, I tried creating a random schedule generator that generates schedules based on 3 inputs (Rotation length, Staff list, and Shift list), then filters them based on predicates (so far, the only predicate is to make sure that no-one is working longer then X...
This algorithm is meant to read a string of numbers on an input, a naive substitution cipher code (A = 1, B = 2, ..., Z = 26) and output the number of ways the code could be interpreted (e.g. 25114 could mean 'BEAN', ‘BEAAD’, ‘YAAD’, ‘YAN’, ‘YKD’ and ‘BEKD’, hence output is 6). It is working properly, but not fast eno...
Essentially what I've done here is written an Interpreter that takes in Python math, such as this, 23 ** 374748, and prints out the result. This program relies on the fact that in Python 2.7 input() is "broken". This means it can take in Python math. # Main parser class class Parser(object): def __init__(self): ...
I am new to android testing and would like to try start off in the correct direction, so I am trying to understand if this is the correct way to test a particular method or if there is some best practice that I should be following. Here are some snippets of the class that contains the method I would like to test. publ...
I've just created a test to create my table gateway class. I've written about 8 tests and all are passing. I'm hoping anyone can offer any advice on what to do next to make these better. This is quite a small app and just one of my own, but at work I want to write tests for much bigger applications so concerned with pe...
I'm working on a set of helper classes for working with libpq in C++ and I want to be able to pass in objects to the helper classes and have them internally represented as strings when sent to the db, and convert from string to objects when fetching data. I'm not particularly after a crazy ORM allowing custom objects, ...
Problem: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued ...
I had previously asked about how to evenly distribute the items in n lists into a single list and was referred to this question. I made a practical example of my solution for this in VBA for Excel, since my application for this was resorting my Spotify lists which can be easily pasted into Excel for manipulation. Assum...
I'm working on a web-based on/off controller for multiple switches. I'm looking for a good way to manage the current state of a switch and updating the current state on change. So far I've got a lib.json file which looks like this: { "Lights":[{ "name": "light-one", "pin":"3", "command":"...
Here is my plunker example of what I am doing. jQuery is a great way to use slide transitions and seem to work well with angular as long as you are only using the methods on the element object inside a directive. Basically I am using a directive for divs I want to slide toggle which listens for a broadcast from the co...
I am sort of new to programming. I would like to understand the code areas that are garbage and could be better written keeping the exact (if possible) behavior the code has now. from random import randint import time from collections import OrderedDict cast_again = 'r' statistics = OrderedDict() casts = 0 menu_optio...
Here is a simple reusable AngularJS factory I came up with to initialize Google Maps Asynchronously, which somehow does not seem to be supported by major libraries (see below): Following Google's guidelines I am using global callback function (which seems to be unavoidable harm), that resolves a dummy promise, which is...
I'm stuck with the slow VBA routine below, which I think is the cause of lagging (taking to long). I was wondering if there is a faster way to do this: With Sheets("Groups") .Cells(1, 1).Value = "Groups" .Cells(1, 2).Value = "Aantal" .Cells(2, 1).Value = "9N4" .Cells(2, 2).Value = n9N4 .Cells(3, 1)....
Maybe someone here can help me sort out this implementation and make it better. First the following constraints: 1 Controller & Action that accepts all post requests, these post requests will always be XML data but can be different in the sense that the elements and the element count can differ. Each type of incoming ...
This all works. Just wanted to make sure I didn't miss anything. Coming from C++ and working my way through Algorithms, 4th ed. Here is my LinkedList class: /* Linked List Implementation Based on Algorithms, 4th Edition, Section 1.3 */ import java.util.Iterator; import java.util.NoSuchElementException; /** * ...
I've recently begun learning Scala, and while I've run into its concepts before (immutability, tuples, first-class functions) I'm not sure whether I'm using the language how it's supposed to be used. My learning project is going to be a simple little dungeon crawler, and while you can see the code on GitHub, I'm copyin...
This is a function for JavaScript validation: var alpha = "[ A-Za-z]"; var numeric = "[0-9]"; var alphanumeric = "[ A-Za-z0-9]"; function onKeyValidate(e,charVal){ var keynum; var keyChars = /[\x00\x08]/; var validChars = new RegExp(charVal); if(window.event) { keynum = e.keyCode; } ...
My code works in that it compiles, and when executed writes out a log file using a buffered writer. But I wonder whether: I am correct in assuming that this actually winds up deferring a .Close that is always called a package variable is the idiomatic way of doing this in Go I realise that I could just have createLog...
Inspired by the non-locking implementation proposed in this post, the following code is an attempt to (about) do the same using the azure cache. As I'm totally green on the Azure cache I'd appreciate input on best practices or pitfalls. I should add that this method is assumed to be the only interaction with the azure ...
I would like my form generator class to be reviewed. I want to know about the following topics: Is this efficient? Does this have any flaws? Is this using the concepts in the proper way? Are there any security issues? Is my coding style correct? <?php class FormBuilder { public function buildForm($method, $actio...
I'm working on a simple dictionary tool, with a base class that can be extended by plugins to represent different dictionaries. The plugins are organized in the filesystem like this: plugins/ ├── dict1 │   ├── ... │   └── dict1.py └── dict2 ├── ... └── dict2.py Each plugin defines a class named Dictionary, w...
I've been writing some code that places some data in an empty worksheet and then formats the sheet by adding borders to all of the used cells. The code functions how it should perfect, but it takes a little bit of time to execute. I was wondering if there is any way I can speed up my code that I'm missing, because I do...
I have the following contract in a WCF-based web service: public List<string> GetAllPossibleQueryEngineHostNames(Instance instance); Obviously, I can call this and pass in an Instance object. However, I need to also support older versions of the client, which pass in a string like so: string instance = "value"; svc.G...
I'm making a web application for the administration of a restaurant kind of type. The purpose of this application is to make customers, and the orders of those customers, which has products in it, etc... This application is written in PHP combined with jQuery. I have many tabs, such as: Displaying the orders A screen ...
I decided to write my own programming language, of sorts. Essentially, you write code into a text file and the program will run the code inside the text file. The file is provided through a script argument. # Basic programming language from operator import eq, ne, lt, gt, le, ge from random import random from sys impo...
I have been experimenting with integrating Lua into Objective-C. I have tried to do the bare minimum to get Lua to compute values and return them. I did not want to use any external libraries so I have avoided those. All that is required to make this work is to add the Lua files to the project directory. Then all th...
Use these links to understand the code I'm posting below since although it looks like PHP it is not: Function Reference Language Reference I have been making a programming language for some time now as a good learning experience etc and improving my programming skills. I'm making a full clone of the original Pengo. ...
I'm trying to do three different type of DAOs with 4 subtypes of each. I have RAM, SQL and Serial with each one have four subtypes. Is a singleton necessary with my implementation within the factory and more specifically with each DAO? Should I use static methods instead? Also I have two factories, is that necessary? ...
I'm writing a Java application to control a custom IR research camera that will be installed on an aircraft. The camera connects to the the computer using UDP sockets via a direct LAN cable. The camera does not initiate any communications; it just replies to commands, 5-character strings, sent to it (the camera code i...
I am using a singleton in my DAO. Would I be better off with static methods? Also, should I be worried about synchronization of the singleton and my data structures? public class RAMUserDAO implements GenericDAO<User, String, Boolean> { private static RAMUserDAO userDAO = null; private Map<String,...
I'm a freelancer and I recently wrote a python script that processes input xlsx files that contain data in a particular format and output a csv file in another format as required. The code works well and fulfills the requirements, but I am looking for a code review with suggestions on performance, improved readability,...
I have a lot of code that looks like this: value = TopicLinkClick.create_from(new_params) return value unless value.nil? # do something else I find this code is not so good because creating a temporary variable is troublesome and disruptive of my workflow, and it takes time to read and understand a large block of cod...
I am looking for clean way to accumulate amounts within a input dataset. In this example, there are 18 rows of data, and the output is a 3 rows of data, accumulated by Key, by ExpenseType. My biggest concern is whether hashMap is the correct utility for this, or if there is an easier/cleaner way. FamilyExpenseProcesso...
I'm now looking for feedback on v2.0 of this program instead. I'd like some feedback about my code. What bad habits do I have? What advice could help me write more Pythonic? I'm trying to write a console application and want a tool to display, update and save settings in a dictionary. def file_as_string(file_name): ...
I want to read multiple files simultaneously and apply the same function on data. This code works correctly, but can someone please suggest any better way of writing this? function fileread(path,stats,callback){ var buffer = new Buffer(stats.size); fs.readFile(path, buffer, function(err, data){ if(err){ ...
This is the application I created for my personal use. I need some quality testing of this application. If you see some errors or any lengthy coding (it's already lengthy), and it needs to be shortened please tell me. I would love to learn new things; as I'm a newbie, I have made lots of mistakes here. using System; ...
I am trying to remove empty a String array from ArrayList: List<String[]> someList = new ArrayList<String[]>(); which contains data like: [ { "Loic" , "Remy" , "Fail","Medical"} , { "Faser" , "Foster" , "Pass","Southampton","GK","Young"} , { "" , "" ,} , { "" , "" , "","","",""} , { "Emre" , "Can" , "Pass"...
Following on from my earlier question: Very simple PostgreSQL ORM in C++ using libpq (tldr; I'm creating a set of helper classes for working with libpq) I've decided to have another attack at the datatypes which represent postgresql data types so some sort of ORM can occur with my classes. Following on from the advice ...
I have such a method which takes a URL, such as http://twitter.com/ttt or twitter.com/dasd, and should show its domain with http: http://twitter.com and name twitter def show_domain(url): sites = { 'twitter': ['http://www.twitter.com/', 'twitter'], 'facebook': ['http://www.facebook.com/', 'facebook'...
I know this is a mess! How can I write this code better? function anim() { $( "#p1-animation-1" ).fadeIn( 1200, function() { $( "#p1-animation-1" ).fadeOut( 1200 ); $( "#p1-animation-2" ).fadeIn( 1200, function() { $( "#p1-animation-2" ).fadeOut( 1200 ); ...
I have a String like "Time left (XX)" or "You need stay here for (XX)" and int as second. I use those two variables to format label like "string (mm:ss)" example "Time left (59:23)". private String timeDescription(String pDescription,int pTime) { final String preformatedTime = secondsToString(pTime); final Str...
I changed the withColumns() method in this class: public static class Options { public String table; public String[] columns; public Options withTable(String table) { this.table = table; return this; } public Options withColumns(String[] columns) { this.columns = columns; ...
I have decided to create my own CircularListCursor, because I wanted some abstraction and a ListIterator<E> couldn't give enough in my opinion. I'm also using the javafx.beans.Property class, as I really like how it is being used in JavaFX 8 and figured it would be useful. The basic properties of a cursor are: Can go ...
I am currently building a web app where I need to randomly switch the font and color of a title (inside the #content div) and the background of the page every time a button is clicked. I wrote the following code that works perfectly, but I'm wondering if it could be optimized (or at least written in a more elegant way...
Context: A logger records events which contain an area, a level, a message and an option indicating that the source replaces another one. The logger attempts to send the message through HTTP, and on failure, saves it locally. If HTTP service times out, the logger stops attempting using HTTP and stores the message local...
Before I wrote this I searched and found a number of solutions that make use of a caching provider to handle a set of items. I felt that was too cumbersome of an approach and set out to create a class that could cache a single value, similar to the way Lazy<T> manages the initialization of a single value. I'm having tr...
I'm developing a very basic product builder. Part of the builder has a basic text editor including some text color presets. As it stands, the presets remove a class that defines the text color and add in their own color class. Looking at my code, it feels absurdly clunky and inefficient. I'm sure there has to be a bett...
There was a lot going on in this Database that I couldn't change, a lot of bad practices because the data was originally being pulled from an old mainframe database and then transformed by a horrible looking VB service and inserted into several (horrible) tables in an SQL Database so the information could be used by a ...
I have an ASP.NET MVC Controller, the relevant parts of which appear here: public class IncidentController : Controller { private IncidentDBContext db = new IncidentDBContext(); public ActionResult Edit(int id = 0) { Incident incident = db.Incidents .Include(i => i.Images) ....
One of my rails controllers is horribly overcrowded with a bunch of methods that link to static web pages. Controller def adventure end def cooking end def dancing end def programming end def reading end def running end def sports end def writing end For each of the above actions I have seperate view files and ...
I have been reading Clean Code and decided to start working problems on Codechef.com attempting to apply some of what I have learned. Do I seem to be on the right track or am I way off? The challenge is to find the number of trailing zeroes in the decimal form of N!, where 1 ≤ N ≤ 109. I am more concerned with the codi...
I'm working on a project of mine, and I've had to write out a fair bit of jQuery. This is a generator and a calculator for some League of Legends related content. I was wondering if you could see any possible compact-"ness" changes that could be made. Here is my code. Hopefully I can trust you to take a look at it wit...
I've got a method that needs to PUT data to a web API. Sometimes the connection fails, so I needed a way to do retries, but if the retries fail, I still need to capture the exception and re-throw it. I've got something that I "believe" is working, but I've got a stupid throw at the end. Is there a better, more concise ...
I'm writing a conversion mechanism in C#. I deserialize a big XML document of one type and return a big XML document of another type (via serialization of another object). While I'm doing the conversion, I find myself doing a TON of null checks (checking whether or not a certain property has a value, which then would ...
This is a continuation of my earlier question. I have a plain text file with the content of a dictionary (Webster's Unabridged Dictionary) in this format: A A (named a in the English, and most commonly ä in other languages). Defn: The first letter of the English and of many other alphabets. The capital A of the alpha...
After implementing most of the suggestions from the first question, This is the code I got: from math import log zero_to_nineteen = ("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", ...
I have a large service application I designed; it's a solution made up of about 30 projects. I was wondering if anyone could point me in the right direction regarding using the Task-based Asynchronous Pattern (TAP) and/or the Event-based Asynchronous Pattern (EAP). Background The project in question is installed as a ....
Related to, but not exactly a follow up of this question. After fixing some issues discovered in the last review, I added a little more functionality to the Enumerable class. The problem is, I've never sorted before. I tried (and failed)to implement a few of the standard algorithms before coming up with this. It's not ...
I have two URLs (urlA and urlB) and both the URL gives me a JSON response back in the same JSON format. Below is my JSON string which I am getting back by calling from urlA. I have shorten it down by having only three reportRecords for the understanding purpose. In general, it might have more than ~500 reportRecords. {...
I'm working on avoiding JavaScript that either directly modifies the DOM a ton, contains a ton of anonymous functions, or is encapsulated in giant $(document).ready... blocks. This is one of my first attempts at writing a section of my project in a better way. The code is commented and organized fairly well, so it sho...
This is my first time implementing achievements in a game so I could definitely use some feedback on what I have done here. I have heard about singleton approaches to this problem, but I did not feel it was really necessary and I would rather avoid singletons since they have a bad reputation. Instead my approach is t...
This Python 3 program outputs a list of all pathnames in the filesystem that match a list of rules taken from a file. You can add and remove sets of pathnames. The original purpose was to generate lists of pathnames to feed to cpio for backups. A simplified version of one of my backup rulefiles should clarify how it wo...
I've written some code to "binary search" a list, and return the first occurrence of the target: def bsearch(a, left, right, target, first_or_last = 'first'): """ Use binary search to find the first, last, or random index of target. >>> a = [1,1,1,1,1,1] >>> bsearch(a, 0, len(a)-1, 1, 'first') ...
JavaScript concerns Is this the best way in jQuery to handle a button being pressed without making an HTTP req? $("#input-box-form").submit( function(event) { event.preventDefault(); var data = getParityData(); showParityData(data); }); This seems like a mess/redundant/I'm not doing it right. How can I ma...
I'm developing an MP4 parser. Each class represents each box in MP4 file, and every box class derives from base box class. The problem is that below code is duplicated on every box class: private ulong MyDataSize; public override ulong BoxContentEndOffset { get { return base.BoxContentEndOffset + th...
In this code I update two tables called Payment and SalaryTrans. First I insert records (Salary payments) to Payment table and then I update SalaryTrans table. When a record is inserted to Payment table, ID is auto generated (auto increment column) and then that ID should be updated in SalaryTrans table (for all matchi...
I am new to iOS development. I wrote this code, but the company said that this is bad architecture and is not acceptable. I want to improve this code. UITabBarController * tab = (UITabBarController *) self.window.rootViewController; UINavigationController * nav = (UINavigationController *) [[tab viewControllers] obje...
I'm working on a simple dictionary tool, with a base class that can be extended by plugins to represent different dictionaries. The base class does most of the heavy lifting: it keeps the index of all entries in memory, and it handles searching the index. Plugins that extend this class implement populating the index an...
Given three linked lists, say a, b and c, find one node from each list such that the sum of the values of the nodes is equal to a given number. For example, if the three linked lists are 12->6->29, 23->5->8 and 90->20->59, and the given number is 101, the output should be tripel “6 5 90″. This question is attribut...
<?php $xml = simplexml_load_file("http://www.example.com/example.xml"); //echo "<pre>"; //print_r($xml); $cnt =0; $customereview=''; foreach($xml->comment as $comment){ if($comment->ProdNid == $productID){ if($comme...
I have a list of sets. The same items may appear in multiple sets. I want to transform this into a new list of sets where: Each item only appears once in the entire list of sets. For each set in this new list, on every set in the old list, the new set will either be a subset or will not intersect at all. I want this ...
On a responsive website where elements may shrink/expand according to the size of your viewport, the elements that was at the top of your viewport at the time may get pushed down/up as the elements above them get squished/expanded. Forcing you to scroll down/up again in order to get to the same area you were looking at...
I am using this code to fetch some details from server from my android app. How can I improve it? Here I am also transferring some data from one activity to another. This is how I have written my Fetch_Details class: public class Fetch_Details extends Activity{ //JSON Node Names private static final String TAG...
I need some improvements on my code. I did some validation by preg_match and functions. I need some special characters restrictions every field. <?php $error=''; if(isset($_POST['submit'])) { if(nameField($_POST['name'])=='') { $error="Invalid Name"; } if(numberField($_POST['phone'])=='') { $error.="<br>Inval...
For a while now I've been after a lock-free, simple and scalable implementation of a multiple producer, single consumer queue for delegates in C#. I think I finally have it. I've run basic tests on it showing it works, and the design is so simple that I've managed to convince myself it is rock-solid. This relies on a c...
Alice and Bob are playing a game called "Stone Game". Stone game is a two-player game. Let N be the total number of stones. In each turn, a player can remove either one stone or four stones. The player who picks the last stone, wins. They follow the "Ladies First" norm. Hence Alice is always the one to make the first ...
I have been making a web page in PHP and JavaScript to take employees clock times and do some things with them so I can display them. Everything is currently working quite well, but the code looks rough. <html> <meta http-equiv="refresh" content="1; URL=http://localhost/T_A/People.php"></html> include 'People...
I have a coding problem for which I have attempted to solve with the below coding. However, my program is assessed as too slow in its execution and thus needs to be optimized to reduce the execution time. Please help me in optimizing my program and reducing the execution time. Problem definition: People connect with e...
I've just been putting together an audio meter by stacking bootstrap progress bars, and thought there was probably a better way, mathematically / logically, of achieving this. levels = (vumeter) -> green = if vumeter % 50 < vumeter then 50 else vumeter yellow = if vumeter % 85 < vumeter then 35 else vumeter - 50 ...
I've just created my first tests using mock classes. So far my tests are running much faster and now I guess I'm solely focusing on a single class (in this case I'm testing UserTable and mocking the DatabaseAdapter instance I inject into it) I haven't proceeded to do the write tests for the other methods of this class ...