Skip to content

Instantly share code, notes, and snippets.

View michaelBenin's full-sized avatar
🏠
Remote

Michael Benin michaelBenin

🏠
Remote
View GitHub Profile
@michaelBenin
michaelBenin / Grunt Convert Video FFMPEG
Created June 19, 2013 14:58
Grunt task to convert Video to HTML5 Formats.
/*
convertVideo_config: {
ffmpeg: 'bin/ffmpeg/./ffmpeg',
mp4: '-vcodec libx264',
m4v: '-vcodec libx264',
'3gp': '-acodec libvo_aacenc -vcodec libx264',
webm: '-acodec libvorbis -vcodec libvpx',
ogv: '-acodec libvorbis'
},
@michaelBenin
michaelBenin / gist:6175250
Created August 7, 2013 15:41
Todos for grunt tasks
grunt-json-htmltemplate:
- readme needs to show me why I need this. If i were to stumble upon it I would have no idea what I would use it for.
- task name in the grunt config should be camelCase for JS consistency: `json_html_template` => `jsonHtmlTemplate`
- package.json: You need `gruntplugin` as a keyword for it to show up in the grunt plugin page
- use `this.files`, instead of this.data.src/this.data.dest
- You could use grunt.util.async.forEach to make it faster
- make sure to include tests when done.
grunt-browser-dependencies
(function (global) {
"use strict";
function empty(obj) {
var key;
for (key in obj) if (obj.hasOwnProperty(key)) return false;
return true;
}
var Ember = global.Ember,
@michaelBenin
michaelBenin / pid.js
Created September 17, 2013 02:25 — forked from FGRibreau/pid.js
//
// Usage: require('./pid')("myapp");
//
var fs = require('fs');
module.exports = function(appname){
process.title = appname;
var PID_FILE = "/usr/local/var/run/"+process.title+".pid";
@michaelBenin
michaelBenin / gist:6640460
Created September 20, 2013 16:50
Airbnb delete all messages. Paste this in console.
$('.hide').find('a').trigger('click');
@michaelBenin
michaelBenin / gist:6945361
Last active December 25, 2015 08:19
Sharing templates between the client and server is a good thing when dealing with single page web apps that need SEO. Here is an example in a current project that utilizes Django and BackboneJS. This custom template tag renders out the context to a handlebars template with pybars.
from django import template
from django.conf import settings
from pybars import Compiler
# Needed to register a custom template tag
register = template.Library()
# Handlebars compiler
compiler = Compiler()
# Decorator to register a tag that takes the context
@register.simple_tag(takes_context=True)
@michaelBenin
michaelBenin / gist:9037900
Created February 16, 2014 17:45
TODO: Shim config for browserify with bower
var shimConfig = (function (grunt) {
return function (property) {
var shim = {};
var dir = grunt.file.readJSON('package.json').browserDependencies[property].dir;
grunt.file.readJSON('package.json').browserDependencies[property].files
.forEach(function (conf) {
var currentShim = shim[conf.require_by] = {};
currentShim.path = dir + '/' + Object.keys(conf)[0];
currentShim.exports = conf.exports;
if (conf.depends) {
@michaelBenin
michaelBenin / gist:9181690
Created February 24, 2014 03:51
Sample grunt browserify config
browserify: {
modern: {
src: ['client/js/init.js'],
dest: 'built/static/js/<%= pkg.name %>.js',
options: {
debug: true,
noParse: [],
transform: [
'hbsfy'
]
@michaelBenin
michaelBenin / gist:9181847
Created February 24, 2014 04:10
Python script to install Java, NodeJS, Ruby, Redis, NGINX, gem and npm packages, and git configuration
#!/usr/bin/env python
'''
This file is meant to setup your environment on AWS ec2 instance from a sample
config.json file.
'''
import os
import apt
import sys
@michaelBenin
michaelBenin / gist:9302474
Created March 2, 2014 05:41
Alphabetize your json file
# python alphabetize-json test.json
import json
import sys
args = sys.argv[1:]
for json_file in args:
with open(json_file, 'r') as file:
alphabetized = json.loads(file.read())
with open(json_file, 'w') as w: