Skip to content

Instantly share code, notes, and snippets.

View dbrugne's full-sized avatar

Damien Brugne dbrugne

  • Toulouse, France
View GitHub Profile
@dbrugne
dbrugne / create_user_database
Last active August 29, 2015 13:56
Create a new user and an associated database in MySQL
DROP DATABASE foo;
CREATE DATABASE foo;
GRANT ALL ON foo.* TO foo@localhost IDENTIFIED BY 'fooPassword';
FLUSH PRIVILEGES;
@dbrugne
dbrugne / gist:686ce36a753f446abd19
Last active August 29, 2015 14:09
Simple node process HTTP redirect
var http = require('http'),
url = require('url');
var fqdnToRedirect = 'http://fqdn.tld';
var server = http.createServer(function(req, res) {
var q = url.parse(req.url).path;
console.log('now redirect to '+q);
res.writeHead(302, {
'Location': fqdnToRedirect+q
@dbrugne
dbrugne / gist:349fcd788677d58e578a
Last active August 29, 2015 14:12
View bound ports on Linux
netstat -ln -A inet
@dbrugne
dbrugne / gist:84cb2845b10dc5fe4c70
Created January 15, 2015 17:55
Javascript full date and time string
// "20150115185533114"
var d = new Date();
var date = ''+d.getFullYear()+('0'+(d.getMonth()+1)).substr(-2, 2)+('0'+(d.getDate())).substr(-2, 2)+d.getHours()+d.getMinutes()+d.getSeconds()+d.getMilliseconds();
@dbrugne
dbrugne / app.js
Created February 1, 2015 15:07
Simplest static webserver with node and express
/**
* express could be installed globally (npm install -g) and loaded with global node_modules path set in NODE_PATH env
*/
var express = require('express');
var app = express();
app.use(express.static(__dirname));
app.listen(3000);
@dbrugne
dbrugne / gist:f454b85dd5596d0b066e
Created February 21, 2015 13:06
Uninstall NodeJS installed from .pkg on MacOS X
# installed node version 0.10
# http://stackoverflow.com/questions/9044788/how-do-i-uninstall-nodejs-installed-from-pkg-mac-os-x
sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
@dbrugne
dbrugne / gist:b99534a6b6a0cabb740f
Last active August 29, 2015 14:15
Install NodeJS from NVM on MacOS X
# https://academy.appgyver.com/installwizard/steps#/install-nvm
# as regular user (not root)
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
nvm install 0.10
nvm use 0.10
nvm alias default 0.10
node -v
@dbrugne
dbrugne / gist:a71048fdd422fac3eef9
Created March 26, 2015 10:35
Gandi DNS zone configuration for Mailgun
# The SPF record should be present as TXT to be able to be read by Mailgun, and optionnaly as SPF.
# To do that you need to edit the zone as "expert" cause Gandi IHM refuses to create a second TXT
# record for "@" (it can occurs if you have a Google Webmaster tool verification DNS record)
email 10800 IN CNAME mailgun.org.
krs._domainkey 10800 IN TXT "k=rsa; p=MIG...QAB"
@ 10800 IN SPF "v=spf1 include:mailgun.org ~all"
@ 10800 IN TXT "v=spf1 include:mailgun.org ~all"
@ 10800 IN TXT "google-site-verification=Gy0...xrY"
@dbrugne
dbrugne / gist:2a62d4dd88f11fa36b75
Last active March 24, 2022 21:50
MongoDB bulk insert from mongoose models
var mongoose = require('mongoose');
var hitSchema = mongoose.Schema({
text: String,
music: String
});
hitSchema.statics.bulkInsert = function(models, fn) {
if (!models || !models.length)
return fn(null);
@dbrugne
dbrugne / GoogleMapsWithOverlay.html
Last active March 31, 2017 10:38
Google Maps with custom tile server overlay
<!DOCTYPE html>
<html>
<head>
<style>
#map {
height: 430px;
position: relative;
width: 100%;
}
.maps-frame {