Skip to content

Instantly share code, notes, and snippets.

View mytholog's full-sized avatar

Igor Gavrilov mytholog

  • 2Gis
  • Russia
View GitHub Profile
#!/bin/sh
# streaming 1080p h264 to the ipad
# vod style program
ffmpeg -i infile.mkv -acodec libfaac -ac 2 -ar 48000 -ab 160k -vcodec copy -vbsf h264_mp4toannexb -f mpegts - | mediastreamsegmenter -f /Users/username/Sites/video/stream -t 30 -p
# delete files to save space
ffmpeg -i infile.mkv -acodec libfaac -ac 2 -ar 48000 -ab 160k -vcodec copy -vbsf h264_mp4toannexb -f mpegts - | mediastreamsegmenter -f /Users/username/Sites/video/stream -t 30 -s 4 -D
@mytholog
mytholog / gist:f792eb69d5941676a426
Created September 24, 2015 02:01 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# First:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
#go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@mytholog
mytholog / gist:4490916
Last active December 10, 2015 20:49
isAssoc
public static function isAssoc(array $arr)
{
return array_keys($arr) !== range(0, count($arr) - 1);
}
@mytholog
mytholog / auto_widgets.js
Created January 16, 2013 10:30
jQuery UI auto widgets
$("[data-role]").each(function () {
var self = $(this);
self[self.data("role")](self.data("options"));
});
//example: <a href='#' data-role='button' data-options='{"icons":{"primary":"ui-icon-plus"}}'>Click me</a>
<?php
class Process_Manager implements Countable
{
protected $processes = array();
protected $is_child = FALSE;
public function count()
{
return count($this->processes);
<?php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( 'http://ftp.free.org/mirrors/releases.ubuntu-fr.org/11.04/ubuntu-11.04-desktop-i386-fr.iso' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );
alias nginx.start='sudo launchctl load /Library/LaunchAgents/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchAgents/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
alias nginx.logs.error='tail -250f /usr/local/etc/nginx/logs/error.log'
arr1
.filter(function (x) { return arr2.indexOf(x) === -1;})
.concat(arr2.filter(function (x) {return arr1.indexOf(x) === -1;}));
var counts = {};
array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });