Instantly share code, notes, and snippets.

View livestream
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
View gist:5188206

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on

// loosely based on
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory
View admin_head_post_edit_check.php
/* actions fired when listing/adding/editing posts or pages */
/* admin_head-(hookname) */
add_action( 'admin_head-post.php', 'admin_head_post_editing' );
add_action( 'admin_head-post-new.php', 'admin_head_post_new' );
add_action( 'admin_head-edit.php', 'admin_head_post_listing' );
function admin_head_post_editing() {
echo 'you are editing a post';
View gist:1384192
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Filemanager extends Controller {
private $file = '/var/www/assets/img/big/IMG_2083.JPG';
private $new_file = '/var/www/assets/encrypt/';
private $key = 'your key';
private $cipher = MCRYPT_RIJNDAEL_256;
private $mode = MCRYPT_MODE_CBC;
View oauth.php
class Controller_Oauth extends Controller_App {
* Models
* - Consumer (for keeping track of sites which have access to your oAuth provider)
* - Token (request token (type 0) or an access token, (type 1))