Skip to content

Instantly share code, notes, and snippets.

View gabrielstuff's full-sized avatar

Gabriel gabrielstuff

View GitHub Profile
@gabrielstuff
gabrielstuff / rec_check.php
Created February 25, 2014 00:37
Recursive check php
private function recursiveCheck($array)
{
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $key => $current) {
$keyValid = array('section', 'block', 'text', 'item');
if(in_array($key, $keyValid) && $key !== 0 && $this->is_assoc($current)){
//error_log('key: '.$key);
$prevValue = $iterator->getInnerIterator()->offsetGet( $key );
$iterator->getInnerIterator()->offsetUnset($key);
@gabrielstuff
gabrielstuff / getCanvasUrl.js
Created March 7, 2014 10:26
Canvas to webkit url without crashing your browser see references : https://code.google.com/p/chromium/issues/detail?id=69227
function getCanvasURL(canvas){
var parts = canvas.toDataURL().match(/data:([^;]*)(;base64)?,([0-9A-Za-z+/]+)/);
//assume base64 encoding
var binStr = atob(parts[3]);
//convert to binary in ArrayBuffer
var buf = new ArrayBuffer(binStr.length);
var view = new Uint8Array(buf);
for (var i = 0; i < view.length; i++)
@gabrielstuff
gabrielstuff / post_data.js
Created September 12, 2014 22:27
async Meteorjs
Router.map(function() {
this.route('messages', {
path: '/api/messages',
where: 'server',
action: function() {
xml2js = Meteor.npmRequire('xml2js');
// GET, POST, PUT, DELETE
var req = this.request;
var res = this.response;
@gabrielstuff
gabrielstuff / ffmpeg.js
Last active August 29, 2015 14:13
ffmeg nodejs
var fs = require('fs'),
videoName = './record_10.mp4',
child_process = require("child_process"),
exec = child_process.exec;
/*This works like a charm*/
var ffmpeg = child_process.spawn("ffmpeg", [
'-i', videoName, // path
'-vf', 'thumbnail,scale=640:360',
'-r', '1',
@gabrielstuff
gabrielstuff / rename.js
Created January 17, 2015 02:29
Rename a file by incrementing its number
var fs = require('fs'),
schedule = require('node-schedule'),
currentfilename = '/Users/gabrielstuff/Desktop/default/iehg',
newFilename = '/Users/gabrielstuff/Desktop/default/video',
extension = 'mp4',
number = 0;
function rename() {
fs.rename(currentfilename+'.' + extension, newFilename + '_' + number + '.' + extension, function(err) {
if (err) {
db['cfs.medias.filerecord'].aggregate(
[
{
$project:
{
year: { $year: "$uploadedAt" },
month: { $month: "$uploadedAt" },
day: { $dayOfMonth: "$uploadedAt" },
hour: { $hour: "$uploadedAt" },
minutes: { $minute: "$uploadedAt" },
@gabrielstuff
gabrielstuff / ffmpeg.js
Created March 12, 2015 21:39
FSCollection.js
function generatePreview(fileObj, readStream, writeStream) {
fileObj.name('preview.jpg', {
store: 'thumbs'
});
fileObj.extension('jpg', {
store: 'thumbs'
});
fileObj.type('image/jpg', {
store: 'thumbs'
});
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid --with-libvidstab --with-libvpx
# Easy Peasy
ffmpeg -i video.mp4 video.webm
@gabrielstuff
gabrielstuff / remove_info.php
Created May 26, 2015 10:23
Wordpress security
add_filter('login_errors',create_function('$a', "return null;"));
@gabrielstuff
gabrielstuff / diff.sh
Created July 5, 2011 20:55
How to diff on files
diff --exclude=".svn" -rq ~/mounts/www.example.com/ /var/www/www.example.com/