Skip to content

Instantly share code, notes, and snippets.

View colthreepv's full-sized avatar

valerio coltre colthreepv

View GitHub Profile
@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
@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 / .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 / 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 / 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 / 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 / sprintf.js
Created September 26, 2013 14:46
sprint-like function for javascript
/**
* Thanks Raymond Powell
* http://stackoverflow.com/a/14640439/1071793
*/
String.prototype.format = function () {
var formatted = this,
prop,
regexp = new RegExp('\\{' + prop + '\\}', 'gi');
for (prop in arguments[0]) {
formatted = formatted.replace(regexp, arguments[0][prop]);
@colthreepv
colthreepv / .gitconfig
Last active December 23, 2015 17:59
future personal ~/.gitconfig
[push]
default = matching
[color]
diff = true
ui = true
branch = true
[color "branch"]
remote = white reverse
[color "diff"]
meta = yellow bold
@colthreepv
colthreepv / test
Created August 13, 2013 16:06
nginx sample config to use with chunked.js
server {
listen 80;
server_name *.test;
gzip on;
location / {
#proxy_set_header Host api.github.com;
proxy_pass http://localhost:1337/;
proxy_buffering off;
proxy_http_version 1.1;
var http = require('http');
http.createServer(function (request, response) {
// response.setHeader('Content-Type', 'application/json; charset=UTF-8');
// response.setHeader('Transfer-Encoding', 'chunked');
var html =
'<!DOCTYPE html>' +
'<html lang="en">' +
'<head>' +