Skip to content

Instantly share code, notes, and snippets.

View gregberge's full-sized avatar
😉
Building a better web

Greg Bergé gregberge

😉
Building a better web
View GitHub Profile
@gregberge
gregberge / addLoadEventListener
Created January 22, 2013 15:41
JavaScript cross browser addLoadEventListener() #onload #load
function addLoadEventListener (listener) {
var done, oldonload;
if(typeof addEventListener !== "undefined") {
return addEventListener("load", listener, false);
}
if(typeof attachEvent !== "undefined") {
return attachEvent("onload", listener);
}
--- /var/lib/pgsql/9.1/data/pg_hba.conf.bak 2013-06-24 16:22:00.544751787 +0200
+++ /var/lib/pgsql/9.1/data/pg_hba.conf 2013-06-24 14:10:34.017828693 +0200
@@ -79,7 +79,7 @@
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
-host all all 127.0.0.1/32 ident
+host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 ident
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@gregberge
gregberge / conf.js
Created July 10, 2013 22:53
Simple configuration module using nconf.
var nconf = require('nconf');
module.exports = nconf
.env()
.file(__dirname + '/config.json')
.file('env', __dirname + '/config.' + nconf.get('NODE_ENV') + '.json')
.file('user', __dirname + '/config.' + nconf.get('NODE_ENV') + '.' + nconf.get('USER') + '.json');
@gregberge
gregberge / gist:7194047
Last active December 26, 2015 18:19
API testing
var request = require('supertest');
describe('API testing', function () {
it('should return 200', function (done) {
request('http://mywebsite.com')
.get('/users')
.expect(200)
.end(done);
});
});
@gregberge
gregberge / cluster.js
Created March 9, 2014 10:32
Primus cluster
var cluster = require('cluster');
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < 20; i++) {
cluster.fork();
}
return ;
@gregberge
gregberge / Preferences.sublime-settings
Last active August 29, 2015 14:01
Sublime text config
{
"color_scheme": "Packages/User/Solarized (Dark) (SL).tmTheme",
"draw_white_space": "all",
"font_size": 17,
"ignored_packages":
[
"Markdown",
"Vintage"
],
"rulers":
@gregberge
gregberge / gist:0fff0ac542774d53e154
Created July 31, 2014 06:57
Docker without sudo
# You may have to logout and log back in again for
# this to take effect.
sudo gpasswd -a $USER docker
# Restart the docker daemon.
sudo service docker restart
@gregberge
gregberge / controller.test.js
Last active February 20, 2018 06:54
Angular controller test using mocha.
describe('My controller', function () {
var scope, createController;
beforeEach(module('app.controllers'));
beforeEach(inject(function ($injector) {
var $rootScope = $injector.get('$rootScope');
var $controller = $injector.get('$controller');
scope = $rootScope.$new();
@gregberge
gregberge / directive.test.js
Created September 1, 2014 12:55
Angular directive test using mocha.
describe('My directive', function () {
var scope, $compile;
beforeEach(module('app.directives'));
beforeEach(inject(function ($injector) {
$compile = $injector.get('$compile');
var $rootScope = $injector.get('$rootScope');
scope = $rootScope.$new();