Skip to content

Instantly share code, notes, and snippets.

View detj's full-sized avatar
🖥️
deep into work

Debjeet Biswas detj

🖥️
deep into work
View GitHub Profile
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@detj
detj / app.js
Created August 18, 2016 11:43 — forked from Ajido/app.js
nodejs express4 cluster graceful restart / shutdown
...
app.use(function(req, res, next){
if (app.get('graceful_shutdown') === true) {
res.set('Connection', 'close');
}
next();
});
app.set('graceful_shutdown_start', function() {
description "Upstart script to run a nodejs app as a service"
author "Louis Chatriot"
env NODE_BIN=/usr/local/bin/node
env APP_DIR=/path/to/app/dir
env SCRIPT_FILE="scriptfile.js" # Entry point for the nodejs app
env LOG_FILE=/path/to/logfile.log
env RUN_AS="anyuser" # Upstart can only be run nicely as root, need to drop privileges
env SERVER_ENV="anything" # Usual apps can be run in different environments (development, test, production ...)
# I typically use the environment variable NODE_ENV (see below)
@detj
detj / handle-error.js
Last active December 23, 2015 10:19 — forked from sthawali/handle-error.js
var express = require('express');
var http = require('http');
var app = express();
app.use(
function handleError(req, res, next) {
var domain = require('domain').create();
res.on('close', function() {
domain.dispose();
@detj
detj / Bar.lua
Created July 2, 2012 19:37 — forked from juaxix/Bar.lua
Mágica Gems by juaxix for Codea - freesource - iPad
-- Bar class
-- LGPL Juan Belón Pérez
-- videojuegos.ser3d.es
--  2011
Bar = class()
function Bar:init()
    self.bgems = {}
    self.time  = 0
    for i=1,maxGemsRow do
@detj
detj / Button.js
Created April 17, 2012 15:30
A simple Button for Impact.js
// A Button Entity for Impact.js
// Has 4 States:
// * hidden - Not shown
// * idle - just sitting there
// * active - someone is pushing on it
// * deactive - shown, but not usable
// And 3 Events
// * pressedDown - activated when pressed Down
// * pressed - constantly fires when pressing
@detj
detj / dabblet.css
Created February 15, 2012 18:57 — forked from chriscoyier/dabblet.css
Based on email I got from andrea ricci
/* Based on email I got from andrea ricci */
a[href^="mailto:"]:before { content: "\2709"; }
.phone:before { content: "\2706"; }
.important:before { content: "\27BD"; }
blockquote:before { content: "\275D"; }
blockquote:after { content: "\275E"; }
.alert:before { content: "\26A0"; }
:before, :after {