Skip to content

Instantly share code, notes, and snippets.

@nojaf
nojaf / string vs binary
Created December 24, 2013 12:35
Comparing the number of bytes and the time to create them when using a string or a Binary Formatter
class Program
{
static void Main(string[] args)
{
Random _rand = new Random();
List<Player> players = new List<Player>();
for (int i = 0; i < 20000; i++)
{
players.Add(new Player()
{
@nojaf
nojaf / AliasController
Last active November 13, 2015 19:03
Umbraco extension generator ApiController
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;
using Umbraco.Core.Models;
@nojaf
nojaf / ngModelTyping.js
Last active August 29, 2015 14:04
ngModel.$typing
//solution to http://stackoverflow.com/questions/25098525/angularjs-ngmodel-typing-state-directive/25099654#25099654
//so I'm naming this property $typing (and not just 'typing') because it's that awesome and genious.
//imho this should be in the core of Angularjs
angular.module("myModule").directive('ngModel', ["$timeout", ngModelTyping]);
function ngModelTyping($timeout) {
return {
require: 'ngModel',
link: function (scope, elem, attr, ngModel) {
@nojaf
nojaf / gist.ps1
Created January 12, 2015 20:20
Powershell Gist example
# Stop script on errors
$ErrorActionPreference = "Stop"
$user = Read-Host "Enter a github user"
$url = [string]::Format("https://api.github.com/users/{0}/gists", $user);
$gistsResponse = Invoke-WebRequest $url
$gists = $gistsResponse.Content | ConvertFrom-Json
$file = New-Item "gist.html" -ItemType "file" -Force
$outputStream = New-Object -TypeName "System.IO.StreamWriter" -ArgumentList @($file, $true)
@nojaf
nojaf / child.js
Created February 26, 2015 09:07
Node (v0.12) run child processes and receive output
var child_process = require("child_process");
command("dir");
commandSync("ping 127.0.0.1");
function command(cmd){
var child = child_process.exec(cmd);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
return child;
@nojaf
nojaf / commandline
Last active August 29, 2015 14:17
Basic gulp watch file
$ npm install -g gulp
$ npm install browser-sync gulp --save-dev
@nojaf
nojaf / Program.cs
Last active August 29, 2015 14:20
SledgehammerSheep - Project Setup
using System;
using System.Diagnostics;
using Microsoft.Owin.Hosting;
namespace SledgehammerSheep
{
public class Program
{
static void Main(string[] args)
{
@nojaf
nojaf / keybindings.json
Created September 24, 2015 14:57
Visual Studio Code TypeScript on Save settings
{
"key":"ctrl+s",
"when":"editorFocus",
"command": "workbench.action.tasks.build"
}
@nojaf
nojaf / gulpfile.js
Last active October 15, 2015 18:41
React ES6 gulpfile
var gulp = require("gulp"); // Good old gulp
var transform = require("vinyl-transform"); // Transform browserify stream
var source = require("vinyl-source-stream"); // Output for bundles
var browserify = require("browserify"); // Bundling tool
var babelify = require("babelify"); // Compile JSX and ES2015
var _ = require("lodash"); // Used to package.json keys
var connect = require("gulp-connect"); // Runs a local dev server
var open = require("gulp-open"); // Open a URL in a web browser
gulp.task("connect", function() {
@nojaf
nojaf / package.json
Created November 21, 2015 10:19
From TypeScript to Babel to ES5 with webpack
{
"name": "webpack-ts-babel",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",