Skip to content

Instantly share code, notes, and snippets.

@colthreepv
colthreepv / mock-delay.js
Last active December 25, 2015 23:19
AngularJS mocked backend demonstration, step-2
angular.module('appMock', ['ngMockE2E'])
.factory('delayHTTP', function ($q, $timeout) {
return {
request: function (request) {
var delayedResponse = $q.defer();
$timeout(function () {
delayedResponse.resolve(request);
}, 500);
return delayedResponse.promise;
},
@colthreepv
colthreepv / app.js
Created October 19, 2013 13:57
AngularJS mocked backend demonstration, step-1
angular.module('app', ['appMock'])
.controller('BodyController', function ($scope, $http) {
$scope.games = [];
// function bound to the refrsh button
$scope.refresh = function () {
$http.get('/games').success(function (data, status, headers, config) {
$scope.games = data;
});
};
@colthreepv
colthreepv / chunked.js
Last active December 26, 2015 12:59
tail -f webserver version, using chunked responses (HTTP 1.1) http://goo.gl/4VuKS6
/**
* tail -f webserver version, using chunked responses (HTTP 1.1)
* slides: http://goo.gl/4VuKS6
*/
var fs = require('fs'),
util = require('util'),
http = require('http');
http.createServer(function (req, res) {
fs.stat(req.url, function (err, stats) {
@colthreepv
colthreepv / .editorconfig
Last active December 26, 2015 23:19
personal .editorconfig for js projects! AWESOME!
# EditorConfig is awesome: http://editorconfig.org/
# Please, read it!
# top-most EditorConfig file
root = true
[*]
charset = utf8
end_of_line = lf
indent_style = space
@colthreepv
colthreepv / menu.lst
Created November 18, 2013 17:43
ubuntu 12.04.3 LTS booting from Grub4DOS
title Ubuntu 12.04.3
find --set-root /ubuntu-12.04.3-desktop-amd64.iso
map /ubuntu-12.04.3-desktop-amd64.iso (hd32) || map --mem /ubuntu-12.04.3-desktop-amd64.iso (hd32)
map --hook
root (hd32)
kernel /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=/ubuntu-12.04.3-desktop-amd64.iso
initrd /casper/initrd.lz
savedefault --wait=2
@colthreepv
colthreepv / app.js
Created November 25, 2013 13:01
Example of /user route of angular-login-example made in ExpressJS
/**
* Example true backend for angular-login-example
*/
var express = require('express');
var http = require('http');
var path = require('path');
var app = express();
// from https://github.com/mrgamer/angular-login-example/blob/master/src/mockhttp.js#L51-L58
#!/bin/bash
echo time sh -c "dd if=/dev/zero of=ddfile bs=8k count=1000000 && sync"
echo dd if=/dec/zero of=ddfile2 bs=8K count=500000
echo time dd if=ddfile of=/dev/null bs=8k
@colthreepv
colthreepv / tools.js
Last active August 29, 2015 14:14
NodeList to Array
// credits to: http://stackoverflow.com/questions/3199588/fastest-way-to-convert-javascript-nodelist-to-array
function toArray (nl) {
var l=nl.length, arr = new Array(l);
while(l--){arr[l]=nl[l];}
return arr;
}
@colthreepv
colthreepv / prerender-upstart.conf
Created March 13, 2015 13:59
Example upstart script to use with prerender-server https://prerender.io/
description "<description here>"
author "<[email protected]>"
start on filesystem or runlevel [2345]
stop on shutdown
# Automatically Respawn:
respawn
respawn limit 3 5
@colthreepv
colthreepv / another.yml
Last active August 29, 2015 14:18
Bug with sudo in ansible-pull 1.9.0.1
---
- name: trying to create a directory that requires sudo
file:
state=directory
path=/helloworld
# sudo should not be required there!
- name: removing it
file:
state=absent