Skip to content

Instantly share code, notes, and snippets.

View colthreepv's full-sized avatar

valerio coltre colthreepv

View GitHub Profile
@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 / 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
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>' +
@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;
@colthreepv
colthreepv / nginx.github
Created August 6, 2013 09:08
nginx site for forwarding github
server {
listen 80;
server_name *.github;
location / {
proxy_set_header Host api.github.com;
proxy_pass https://api.github.com/;
}
access_log /var/log/nginx/github_access.log combined;
@colthreepv
colthreepv / Preferences.sublime-settings
Last active December 20, 2015 10:09
personal sublime preferences
{
"color_scheme": "Packages/User/Monokai (SL).tmTheme",
"ignored_packages":
[
"Vintage"
],
"font_size": 10,
"margin": 2,
"tab_size": 2,
"translate_tabs_to_spaces": true,
@colthreepv
colthreepv / .tmux.conf
Last active December 19, 2015 18:29
personal .tmux.conf, based off It has mouse highlight, mouse scroll.. very good configuration to use with Putty, or with a (better) non-tabbed ssh client https://github.com/tony/tmux-config
# status bar
set-option -g status-utf8 on
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244 #base0
@colthreepv
colthreepv / .jshintrc
Last active December 19, 2015 14:19
My personal jshint settings on Sublime Text (usable on any plugin)
{
"passfail": false,
"maxerr": 10,
"browser": true,
"node": true,
"debug": false,
"devel": false,
"strict": false,