Skip to content

Instantly share code, notes, and snippets.

View rchrd2's full-sized avatar

Richard Caceres rchrd2

View GitHub Profile
@rchrd2
rchrd2 / hello-backbone-react.js
Created February 17, 2016 18:46
Using React with Backbone
var HelloView = Backbone.View.extend({
initialize: function() {
this.listenTo(this.model, "change", this.render, this);
this.render();
},
render: function() {
var reactEl = React.createElement('div', {}, 'Hello, World!');
ReactDOM.render(reactEl, this.el);
return this;
}
@rchrd2
rchrd2 / html5-template.html
Last active February 16, 2016 23:56
Barebones html5 template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Hello</title>
<!--<link href="style.css" rel="stylesheet">-->
<style>
@rchrd2
rchrd2 / Restart_Celery
Created November 28, 2013 20:00
This sends a SIGHUP to the children of a master celery process. The benefit of this is that the master celery process keeps it's same PID.
# Send a SIGHUP to only the children (--ppid is the magic param here).
cat /var/run/celery.pid | xargs ps --no-headers --ppid | awk '{print $1}' | xargs kill -HUP
@rchrd2
rchrd2 / johnd1
Last active December 29, 2015 11:39
These are templates for creating an init.d script for a Procfile that needs to be run with virtualenv. The first uses `daemon`. The second uses `start-stop-daemon`.
#!/bin/bash
### BEGIN INIT INFO
# Provides: johnd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@rchrd2
rchrd2 / profile_render.sh
Created November 19, 2013 21:57
Watch a directory then automatically render and open profile graphs.
#!/bin/sh
watchmedo shell-command \
--pattern="*prof" \
--ignore-pattern="*png" \
--wait \
--command='find profile_data -name "*\.prof" -exec sh -c "test -f {}.png || (gprof2dot -f pstats {} | dot -Tpng -o {}.png && open {}.png)" \;' \
profile_data
@rchrd2
rchrd2 / convert.sh
Created November 4, 2013 20:17
Helper script to convert wav files to mp3 with ffmpeg.
#!/bin/bash
BITRATE=320
defvalue='.'
SOURCE_DIR=${1:-$defvalue}
# Validate arguments
if [[ "$#" == 0 ]]; then
echo >&2 "Usage: ./convert.sh ./exports/*.wav"
exit 1;
@rchrd2
rchrd2 / fix-camera.sh
Created October 19, 2015 21:27
fix isight camea
sudo killall VDCAssistant
/**
* jQuery plugin to add a faux browser around some images
* Based off of http://cloudcannon.com/deconstructions/2014/11/21/flat-css-browser-wrapper.html
*
* Example usage:
*
* <body>
* <img class="fakeBrowser" src="http://example.com/image.jpg"
* </body>
*
### Keybase proof
I hereby claim:
* I am rchrd2 on github.
* I am rchrd2 (https://keybase.io/rchrd2) on keybase.
* I have a public key whose fingerprint is A166 5BE1 E8F6 A2A3 BEC7 382A 8CCA 345A 01E9 EF4B
To claim this, I am signing this object:
@rchrd2
rchrd2 / .bash_profile
Created May 21, 2015 19:16
Disable pyc files!
# Add this to your ~/.bash_profile
# Disable pyc
export PYTHONDONTWRITEBYTECODE=x