Skip to content

Instantly share code, notes, and snippets.

View thiphariel's full-sized avatar
💤

Thiph thiphariel

💤
  • 07:53 (UTC +02:00)
View GitHub Profile
@thiphariel
thiphariel / array_insert.php
Last active August 29, 2015 13:57
Insert array PHP
<?php
/**
* Insert an array in another array
* @param : (array) &$array, our main array
* @param : (array) $insert, the array we want to insert
* @param : (integer) $position, where we want to insert the array
*/
function array_insert(Array &$array, Array $insert, $position)
{
@thiphariel
thiphariel / nodejs.sh
Last active August 29, 2015 13:57
nodejs install
#Packages required to build sources :
apt-get install build-essential
#Download nodejs sources :
wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
#Extract the tar archive :
tar zxvf node-v0.10.26.tar.gz
#Make sure gcc, g++ and make are enabled
@thiphariel
thiphariel / fix_infowindow.js
Created April 3, 2014 10:16
Remove infowindow on Google Maps POI's markers
function fixInfoWindow() {
//Here we redefine set() method.
//If it is called for map option, we hide InfoWindow, if "noSupress" option isnt true.
//As Google doesn't know about this option, its InfoWindows will not be opened.
var set = google.maps.InfoWindow.prototype.set;
google.maps.InfoWindow.prototype.set = function (key, val) {
if (key === 'map') {
if (!this.get('noSupress')) {
console.log('This InfoWindow is supressed. To enable it, set "noSupress" option to true');
return;
@thiphariel
thiphariel / arrow.scss
Created April 3, 2014 12:05
CSS triangle arrow
.arrow-up {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid black;
}
.arrow-down {
@thiphariel
thiphariel / browser_update.js
Last active August 29, 2015 14:01
browser update
/*
* Dependencies
* - Bowser : https://github.com/ded/bowser
* - Smoke : https://github.com/hxgf/smoke.js
*/
/*
* Detect which browser is used and it's version to automaticaly redirect the user on the browser's download page if the version is quite old
*/
@thiphariel
thiphariel / stats.js
Created July 2, 2014 09:15
Js stats about FPS and scripts speed
/**
* @author mrdoob / http://mrdoob.com/
*/
/**
* Just call in the body :
*
* // Stats
* var stats = new stats();
*
@thiphariel
thiphariel / autoload.php
Created September 28, 2014 08:42
Light autoloader
<?php
/**
* Autoloader class
* @author Thomas Collot
*/
namespace Light\App;
class Autoload
{
function JSON_stringify(s, emit_unicode)
{
var json = JSON.stringify(s);
return emit_unicode ? json : json.replace(/[\u007f-\uffff]/g,
function(c) {
return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4);
}
);
}
@thiphariel
thiphariel / ghost_api.js
Created October 26, 2014 18:34
ghost api call authentication token
var postData = querystring.stringify({
grant_type: "password",
username: "<username>",
password: "<password>",
client_id: "ghost-admin"
});
var uriBase = '/ghost/api/v0.1/';
var requestOptions = {
@thiphariel
thiphariel / yiq.js
Created November 3, 2014 14:57
Light color detection
/**
* Light color detection
* source : http://en.wikipedia.org/wiki/YIQ
*/
var light = function(hex) {
var r = parseInt(hex.substr(0, 2), 16);
var g = parseInt(hex.substr(2, 2), 16);
var b = parseInt(hex.substr(4, 2), 16);
var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
return yiq <= 196;