Skip to content

Instantly share code, notes, and snippets.

View tsbits's full-sized avatar
👾

Olivier Destenay tsbits

👾
View GitHub Profile
@tsbits
tsbits / Colored console.log
Last active August 29, 2015 14:08
Colored console.log
// Pour les retours à la ligne mettre \n
// %c applique du css. A chaque %c, ca applique le css suivant,
// donc de 'Made by Creaktif' a '\n' ca applique 'background: #cdcdcd; color: #fff'
// et après celui ci 'background: #8a8a8a; color: #fff', car il y a de nouveau un %c après le \n
console.log('%c MADE BY CREAKTIF \n%c www.creaktif.com ', 'background: #cdcdcd; color: #fff', 'background: #8a8a8a; color: #fff');
@tsbits
tsbits / Twitter card with picture
Created November 19, 2014 16:37
Twitter card with picture
/* https://dev.twitter.com/cards/types */
<meta name="twitter:card" content="photo" />
<meta name="twitter:title" content="Découvrez le nouveau calendrier de l'avent #Milka" />
<meta name="twitter:description" content="Comptez les nuit jusqu'à Noël grâce au nouveau calendrier de l'avent #Milka et découvrez des surprises sur avent.milka.fr" />
<meta name="twitter:image" content="https://avent.milka.fr/img/tcard.jpg" />
<meta name="twitter:url" content="https://avent.milka.fr" />
@tsbits
tsbits / Quick server from anywhere on Mac OSX
Created November 28, 2014 17:02
Quick server from anywhere on Mac OSX
python -m SimpleHTTPServer
@tsbits
tsbits / Mobile OS detection
Last active August 29, 2015 14:10
Mobile OS detection
//From http://stackoverflow.com/questions/12606245/detect-if-browser-is-running-on-an-android-or-ios-device
var isMobile = {
Android: function() {
return /Android/i.test(navigator.userAgent);
},
BlackBerry: function() {
return /BlackBerry/i.test(navigator.userAgent);
},
iOS: function() {
@tsbits
tsbits / app.js
Created February 6, 2015 12:00
Basic setup for Express + socket.io
// From http://stackoverflow.com/questions/9914816/what-is-an-example-of-the-simplest-possible-socket-io-example
var http = require('http'),
fs = require('fs'),
// NEVER use a Sync function except at start-up!
index = fs.readFileSync(__dirname + '/index.html');
// Send index.html to all requests
var app = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(index);
@tsbits
tsbits / main.js
Created April 13, 2015 09:20
Renaming an image sequence with nodeJS & fs
var fs = require('fs');
//That function list all the files in the directory.
//Loop all the file in the folder
//If the current object is a folder -> ignore it
//Else if the file name index of 'mairie' (the original image sequence file was named "mairie"+n, where n started at 200)
//rename it in "mairie"+i, to get an image sequence that begin at 0 and not 200
function getFiles (dir, files_){
files_ = files_ || [];
var files = fs.readdirSync(dir);
@tsbits
tsbits / Terminal :
Created June 11, 2015 09:23
Open multiple slack on OSX Desktop
open -n /Applications/Slack.app
@tsbits
tsbits / countryCode.txt
Created August 24, 2015 14:33
Country code
Afar => aa
Abkhazian => ab
Avestan => ae
Afrikaans => af
Akan => ak
Amharic => am
Arabic => ar
Assamese => as
Avar => av
Aymara => ay
@tsbits
tsbits / Normalize data to 0-1 range?
Created February 12, 2016 14:28
Normalize data to 0-1 range?
var v = (value-min)/(max-min) ;
@tsbits
tsbits / [Terminal & finder] config & alias
Last active December 5, 2016 11:24
[Terminal & finder] config & alias
// Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
// Reload Finder instances
killall Finder
// Show path in finder
Option + Command + P
// Show tab bar