Skip to content

Instantly share code, notes, and snippets.

View ronanguilloux's full-sized avatar

Ronan Guilloux ronanguilloux

View GitHub Profile
@ronanguilloux
ronanguilloux / dumpSingleDb.sh
Created January 11, 2012 11:46
Dump a mysql db
/usr/bin/mysqldump -u <username> -p<password> <my_database> | gzip > /path/to/backup/db/my_database_`date +%y_%m_%d`.gz
@ronanguilloux
ronanguilloux / mongodump.sh
Last active September 29, 2015 11:47
7-days retention, one-per-directory, damn simple dump of all your mongo dbs
#!/bin/sh
date=`date +%u`
/usr/bin/mongodump --directoryperdb -o /var/backups/mongo/$date
@ronanguilloux
ronanguilloux / mysqlBackup.sh
Created January 11, 2012 16:48
Mysql backup, per-directory, per-base, per-day
#!/bin/bash
#
#[ -f ~/.profile ] && . ~/.profile
# MySQL Backup Script
# VER. 2.6 - http://sourceforge.net/projects/automysqlbackup/
# Copyright (c) 2002-2003 [email protected]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@ronanguilloux
ronanguilloux / async_mysql_backup.sh
Created February 1, 2012 09:06
Occasional async production mysql bdd backup & local restore
ssh prod@server
cd /var/backups/mysql/someDir/
tar -cjf my_bdd.sql.tar.bz2 my_bdd.sql
exit
cd /tmp
rsync -e ssh -avz prod@server:/var/backups/mysql/someDir/my_bdd.sql.tar.bz2 .
tar -xjf my_bdd.sql.tar.bz2
mysql -u root -proot my_bdd < my_bdd.sql
rm my_bdd.sql.tar.bz2 my_bdd.sql
@ronanguilloux
ronanguilloux / disambiguation.js
Created February 9, 2012 15:56
Google Map markers : Same positions, disambiguation needed
// source : http://techxplorer.com/2010/02/05/managing-markers-with-the-same-coordinates-in-a-google-map/
// get the coordinates
var hash = points[i].getAttribute("lat") + points[i].getAttribute("lng");
hash = hash.replace(".","").replace(",", "").replace("-","");
// source : http://techxplorer.com/2010/02/05/managing-markers-with-the-same-coordinates-in-a-google-map/
// check to see if we've seen this hash before
if(coords[hash] == null) {
// get coordinate object
var latlng = new google.maps.LatLng(parseFloat(points[i].getAttribute("lat")), parseFloat(points[i].getAttribute("lng")));
@ronanguilloux
ronanguilloux / MSWordHtmlCleaners.js
Created June 12, 2012 07:56
2 js solutions to clean nasty MS Word HTML pasted in any CMS + 2 server-side tips
var CleanWordHTML = function ( str )
{
str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
@ronanguilloux
ronanguilloux / silex
Created July 15, 2012 21:30
Raspberry Pi Silex on Nginx
server {
listen 80; ## listen for ipv4
server_name silex;
access_log /var/log/nginx/silex.access.log;
error_log /var/log/nginx/silex.error.log;
root /var/www/silex;
@ronanguilloux
ronanguilloux / logo.sh
Created July 17, 2012 07:04
raspberry Pi logo, shell-friendly text version
#!/bin/bash
# source & MIT licence : http://exaviorn.com/raspiwrite/
echo " ;d0KOd. .oOK0x: "
echo " 0xlllcoxolkolllloX "
echo " ;OccloddKNdxdocckc "
echo " .dkddkWNNMOdoxd, "
echo " .o:,x0....xd,ck' "
echo " K:xOoloOOccloocW "
echo " .x;N:....xO....'K;k,"
echo " O..Nc...:XNl...:X.,X"
@ronanguilloux
ronanguilloux / patching.md
Created July 30, 2012 11:20
Patching sourcs made simple

Patching made simple

Summary

  • Create old/, new/ and patched/ directories, where patched/ is an exact copy of old/
  • Create a patch to be applied to patched/
  • Patch patched/ * Test patched/
@ronanguilloux
ronanguilloux / gist:3234640
Created August 2, 2012 06:58
Fix authentication issues with GIT repo
git config remote.origin.url [email protected]:username/project_name.git