Skip to content

Instantly share code, notes, and snippets.

View tsbits's full-sized avatar
👾

Olivier Destenay tsbits

👾
View GitHub Profile
@tsbits
tsbits / Step to prepare JSON for the Frame player
Last active December 31, 2015 12:39
Video to frame player video
//FFMPEG PART
ffmpeg -i "path/to/the/video.ext" -an -f image2 -q:v 8 "path/to/destination/folder/%d.ext"
-> -q:v n ( quality : n = int 1 -> 32 where 1 is best than 32 )
//FRAME PLAYER PART ( http://vagnervjs.github.io/frame-player/ )
cd converter
node app.js x y folder/to/imgs/ json/video.json
-> x : startImgNumber, y : endImgNumber
@tsbits
tsbits / gist:9213759
Created February 25, 2014 17:33
JS - Detect iOS Version
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
var version = iOSversion();
@tsbits
tsbits / gist:11111001
Created April 20, 2014 10:46
Config default Apache OSX
In /etc/apache2/users/username.conf
<Directory "/www">
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
@tsbits
tsbits / gist:3869bc4d5d9e36f754ab
Created May 11, 2014 11:42
Create sample user on WordPress
//This script creat a lot of 'fake' users for your WordPress
//Usefull for developper
//This is a modified version of that script : http://wpengineer.com/2054/create-users-automatically-in-wordpress/
//Add this to the functions.php file of your theme then visite the dashboard.
function fb_wp_insert_user(){
for ($i = 1; $i <= 100; $i++) {
$user_data = array(
'ID' => '',
'user_pass' => wp_generate_password(),
@tsbits
tsbits / gist:1a391f1fc35a5a1210a8
Created May 17, 2014 23:38
Degree to radian and vice-versa
//From http://cwestblog.com/2012/11/12/javascript-degree-and-radian-conversion/
// Converts from degrees to radians.
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
};
// Converts from radians to degrees.
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
@tsbits
tsbits / gist:45a336cdf7eee0107e75
Created June 5, 2014 09:27
Check if a string contains only numbers
function checkNumber(testedString) {
var newStr = testedString.replace(/(^\s+|\s+$)/g,'');
if (newStr.length > 0) {
if (/[^0-9]/.test(newStr)) return false;
else return true;
} else return false;
}
@tsbits
tsbits / Check if a string contains only letters
Last active August 29, 2015 14:02
Check if a string contains only letters
function checkAlpha(word) {
var newStr = word.replace(/(^\s+|\s+$)/g,'');
if (newStr.length > 0) {
if (/[^A-Za-zàáâãäåæçèéêëæìíîïñòóôõöøßùúûüÿÀÁÂÃÄÅÆÇÈÉÊËÆÌÍÎÏÑÒÓÔÕÖØßÙÚÛÜŸ \-']/.test(newStr)) return false;
else return true;
} else return false;
}
export PATH=/mongo/bin:$PATH
export PATH=/phantomjs/bin:$PATH
function tabname {
printf "\e]1;$1\a"
}
function winname {
printf "\e]2;$1\a"
}
@tsbits
tsbits / Canvas to image
Created October 17, 2014 22:00
Canvas to image
var img = new Image();
img.src = canvas.toDataURL();
document.body.appendChild(img);
@tsbits
tsbits / Find a random point on a line
Last active August 29, 2015 14:07
Find a random point on a line
var r = Math.random();
var randomPoint = {
'x': (1-r)*this.v1.x + r*this.v2.x,
'y' : (1-r)*this.v1.y + r*this.v2.y
}
//Where v1 & v2 are the two points defining the line.