Skip to content

Instantly share code, notes, and snippets.

View adrienjoly's full-sized avatar
☺️
In the flow

Adrien Joly adrienjoly

☺️
In the flow
View GitHub Profile
@adrienjoly
adrienjoly / elasticsearch.yml
Created October 3, 2012 13:44
Spotify-like search/filter using ElasticSearch
# to store in ./config
index:
analysis:
analyzer:
full_text_analyzer:
type: custom
tokenizer: standard
filter: [standard, lowercase, asciifolding]
partial_text_analyzer :
type : custom
@adrienjoly
adrienjoly / dumpRemoteDB.sh
Created December 4, 2012 21:43
dump a dotcloud-hosted mongodb database and retrieve it locally, on mac os
dotcloud run db "mongodump -h APPNAME.dotcloud.com:DBPORT -u root -p PASSWORD -d DBNAME"
dotcloud run db -- \
"tar -chf- dump 2>/dev/null | base64 -w0" \
| base64 -d > backup-`date +%s`.tar
@adrienjoly
adrienjoly / loader.js
Created June 24, 2013 14:27
Function to include a javascript file dynamically into a HTML page, with a callback when the script is loaded.
function loadJS(src, cb) {
var inc = document.createElement("script");
inc.onload = inc.onreadystatechange = function() {
if (cb && inc.readyState == "loaded" || inc.readyState == "complete" || inc.readyState == 4)
cb();
};
inc.src = src;
document.getElementsByTagName("head")[0].appendChild(inc);
};
@adrienjoly
adrienjoly / hsbc-scrape-history.js
Last active December 28, 2015 23:38
scrape payment history from HSBC website (limited to 2 months, unfortunately...)
var lines = [];
var win = document.getElementsByName("FrameWork")[0].contentWindow;
var doc = win.document;
function nextPage() {
//doc.getElementsByClassName("pagination")[0].getElementsByTagName("a")
win.location.href = "javascript:suivante()";
}
function scrapeLine(tr) {
@adrienjoly
adrienjoly / restartCoreAudio.sh
Created December 25, 2013 01:07
Mac Os X command to restart the core audio. I needed to use this in order to fix my AirPlay issue.
# You have to restart the core audio be pasting the following line into termnal
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
@adrienjoly
adrienjoly / nb_requests_per_sec_from_log.sh
Created January 6, 2014 16:02
Count number of requests per second (read in real-time from appd.out log file)
echo Number of requests per second (read in real-time from appd.out log file)
tail -F appd.out | sed -u -n -e '/===/p' | pv -l -i10 -r >/dev/null
@adrienjoly
adrienjoly / makeColorConsole.js
Created February 13, 2014 10:58
add color to console.warn and console.error outputs
var colors = require('colors');
function makeColorConsole(fct, color){
return function(){
for (var i in arguments)
if (arguments[i] instanceof Object || arguments[i] instanceof Array)
arguments[i] = sys.inspect(arguments[i]);
fct(Array.prototype.join.call(arguments, " ")[color]);
};
}
#!/usr/bin/python
"""
based on @rochacbruno Python http server version 0.1 (for testing purposes only)
Save this file as server.py
>>> python server.py 0.0.0.0 8001
serving on 0.0.0.0:8001
or simply
@adrienjoly
adrienjoly / find_dupes.sh
Created April 14, 2014 08:48
recursively find the list of files that have duplicates names
sudo find . "*" -print0 | xargs -0 -I {} basename {} | uniq -d -i >~/dupes.txt
@adrienjoly
adrienjoly / hideAd.js
Created June 12, 2014 15:29
hide a div (and keep it hidden forever) when clicking a "close" link
var COOKIE_DEF = "showAd=0", COOKIE_EXP = 365 * 24 * 60 * 60 * 1000; // 1 year
var display = (document.cookie || "").indexOf(COOKIE_DEF) == -1;
var $ad = $("#myAd").toggle(display);
$ad.find(".removeAd").click(function() {
document.cookie = COOKIE_DEF + "; expires=" + new Date(Date.now() + COOKIE_EXP).toGMTString();
$ad.animate({height:0}, function() {
$(this).remove();
});
});