Skip to content

Instantly share code, notes, and snippets.

View JulienSansot's full-sized avatar

Julien Sansot JulienSansot

View GitHub Profile
@JulienSansot
JulienSansot / nginx-site-conf
Created March 5, 2015 00:16
nginx config for proxy with certificate and Basic Auth
#
# Example of nginx config to proxy the port 443 to port 7547
# Adding a certificate and Basic Auth in the process
#
server {
listen 443;
server_name abc.def.example.com;
var util = require('util');
var d = require('domain').create();
d.on('error', function(err){
try {
// make sure we close down within 10 seconds
var killtimer = setTimeout(function() {
process.exit(1);
@JulienSansot
JulienSansot / remove all redis keys starting with prefix:
Last active August 29, 2015 14:19
remove all redis keys starting with prefix:
redis-cli KEYS "prefix:*" | xargs redis-cli DEL
@JulienSansot
JulienSansot / ssh to ubuntu on ec2
Last active August 29, 2015 14:19
ssh to ubuntu on ec2
ssh -i ~/path/to/key.pem [email protected]
@JulienSansot
JulienSansot / percentage of free memory
Created April 20, 2015 05:38
percentage of free memory
free | grep Mem | awk '{print $4/$2 * 100.0}'
@JulienSansot
JulienSansot / generate ssh key
Last active August 29, 2015 14:19
generate ssh key
ssh-keygen -t rsa -C "something@something"
@JulienSansot
JulienSansot / dump and restore postgreSQL database
Created April 22, 2015 06:27
dump and restore postgreSQL database
#dump the db :
#http://postgresguide.com/utilities/backup-restore.html
sudo -u postgres pg_dump -Fc your_db > dump.bak
#restore a db :
sudo -u postgres pg_restore --clean -d your_db -Fc dump.bak
@JulienSansot
JulienSansot / mongodb dump and restore
Last active April 18, 2022 03:07
mongodb dump and restore
#with docker
docker run -it -v "$PWD"/mongo_dump:/data/dump --rm mongo:3.0.5 sh -c 'exec mongodump --out /data/dump --host=1.2.3.4 --db the_database'
docker run -it -v "$PWD"/mongo_dump:/data/dump --rm mongo:3.0.5 sh -c 'exec mongorestore --host=1.2.3.4 --db the_database /data/dump/the_database --drop'
#dump
sudo mongodump
#restore (droping previous data)
sudo mongorestore
@JulienSansot
JulienSansot / linux. get a nice date format for a file name
Created April 24, 2015 08:13
linux. get a nice date format for a file name
date +%Y_%m_%d_%H-%M-%S
#2015_04_24_17-12-09
@JulienSansot
JulienSansot / script to check linux distro
Created May 14, 2015 01:14
script to check linux distro
#!/bin/sh
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
OS=`uname -s`
REV=`uname -r`
MACH=`uname -m`
GetVersionFromFile()
{
VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `