This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express') | |
| , cookieSessions = require('./cookie-sessions'); | |
| var app = express(); | |
| app.use(express.cookieParser('manny is cool')); | |
| app.use(cookieSessions('sid')); | |
| app.get('/', function(req, res){ | |
| req.session.count = req.session.count || 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Greg's Stop Loss Kata | |
| Testing is very hard when time is involved ... | |
| A trailing stop loss is a term used in financial trading. For a very in depth explanation you can read here http://www.investopedia.com/articles/trading/03/080603.asp and http://en.wikipedia.org/wiki/Order_(exchange)#Stop_orders | |
| However we do not need a huge amount of background in order to do the kata as we are going to limit the problem a bit. | |
| The general idea is that when you buy into a stock at a price say $10. You want it to automatically get sold if the stock goes below $9 (-$1). If we use the term "trailing" that means that id the price goes up to $11 then the sell point becomes $10. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function nestCollection(model, attributeName, nestedCollection) { | |
| //setup nested references | |
| for (var i = 0; i < nestedCollection.length; i++) { | |
| model.attributes[attributeName][i] = nestedCollection.at(i).attributes; | |
| } | |
| //create empty arrays if none | |
| nestedCollection.bind('add', function (initiative) { | |
| if (!model.get(attributeName)) { | |
| model.attributes[attributeName] = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // middleware | |
| app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/public/uploads" })) | |
| // later | |
| app.get('/photos', uploadFile, addPhoto) | |
| // file is automatically saved to /public/uploads, let's just set | |
| function uploadFile(req, res, next) { | |
| if (req.files) { | |
| req.body.url = "http://myawesomesite.com/" + req.files.file.path.split("/").slice(-2).join("/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ECHO OFF | |
| :: Installs all Nuget packages for all Projects, Recursively. | |
| :: Ignores Resharper folders | |
| :: DOS Help - http://www.dostips.com/forum/viewtopic.php?f=3&t=431 | |
| SET NUGET="Nuget.exe" | |
| SET SOLUTIONDIR=..\src | |
| ECHO. | |
| ECHO Finding Projects in Solution... (saving to ProjectsUsingNuget.log.txt) | |
| ECHO ------------------------------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Restify server config here | |
| var server = restify.createServer({ | |
| name: 'restify-test', | |
| version: '1.0.0', | |
| }); | |
| // ... | |
| // Connect config here | |
| var connectApp = connect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // http://haacked.com/archive/2009/01/14/named-formats-redux.aspx#70485 | |
| using System; | |
| using System.Text; | |
| using System.Web; | |
| using System.Web.UI; | |
| namespace StringLib | |
| { | |
| public static class HenriFormatter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class ObservableExtensions | |
| { | |
| /// <summary> | |
| /// Group observable sequence into buffers separated by periods of calm | |
| /// </summary> | |
| /// <param name="source">Observable to buffer</param> | |
| /// <param name="calmDuration">Duration of calm after which to close buffer</param> | |
| /// <param name="maxCount">Max size to buffer before returning</param> | |
| /// <param name="maxDuration">Max duration to buffer before returning</param> | |
| public static IObservable<IList<T>> BufferUntilCalm<T>(this IObservable<T> source, TimeSpan calmDuration, Int32? maxCount=null, TimeSpan? maxDuration = null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model EditUserModel | |
| @using (Html.BeginForm()) | |
| { | |
| <div> | |
| @Html.HiddenFor(m => m.Id) | |
| @Html.TextBoxFor(m => m.FirstName) | |
| @Html.TextBoxFor(m => m.LastName) | |
| @Html.DropDownListFor(m => m.CountryId, Model.Countries) | |