Skip to content

Instantly share code, notes, and snippets.

View cbednarski's full-sized avatar

Chris Bednarski cbednarski

View GitHub Profile
@cbednarski
cbednarski / mongo_doc.py
Created April 8, 2014 21:27
Lightweight MongoDB abstraction around python classes
class MongoDoc(object):
connection = None
__fields__ = {}
__required__ = []
__optional__ = []
__meta__ = ['_id', 'updated']
def set_data(self, data):
'''
You can set individual fields like this:
@cbednarski
cbednarski / aminator.md
Last active August 29, 2015 13:56
Aminator Chef-Solo Setup Instructions

Aminator

You'll need to create / use a few security groups, IAM roles, etc. I recommend naming them all aminator to make it easy to remember what they're for. If you're following along, I've already set these up.

Security Configuration

Create a IAM Role for AWS EC2 with the following custom security policy:

{

"Statement": [

@cbednarski
cbednarski / camera.py
Last active February 17, 2024 05:54
Webcam capture for python - Pops up a preview from your webcam and snaps a picture when you press 'q'
import cv2
# Windows dependencies
# - Python 2.7.6: http://www.python.org/download/
# - OpenCV: http://opencv.org/
# - Numpy -- get numpy from here because the official builds don't support x64:
# http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
# Mac Dependencies
# - brew install python
@cbednarski
cbednarski / .zshrc
Created October 15, 2013 00:57
zsh config
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
export EDITOR=vim
export PROMPT="%{$fg[green]%}%n%{$fg[white]%}@%{$fg[green]%}%m%{$fg[white]%} "$PROMPT
# Java
@cbednarski
cbednarski / jenkins.md
Created October 11, 2013 06:51
Install Jenkins on Ubuntu

Install Jenkins on Ubuntu

sudo apt-get install openjdk-7-jre-headless nginx -y
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
echo "deb http://pkg.jenkins-ci.org/debian binary/" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install jenkins -y

Nginx config

@cbednarski
cbednarski / closures.js
Created October 9, 2013 10:42
Example of private data in a closure in javascript
var lib = (function (win) {
var sum = 0;
return {
makeSum: function (arr) {
win.document.body;
JSoop.each(arr, function (value, index) {
sum = sum + value;
});
@cbednarski
cbednarski / events.js
Last active December 25, 2015 01:59
Enumerate all jquery event handlers on the page
// jQuery 1.4
$("*").each(function(){
var data = $(this).data();
if(typeof data !== "undefined" && typeof data.events === "object") {
console.log(data.events);
}
});
// jQuery 1.7
$("*").each(function(){
@cbednarski
cbednarski / Preferences.sublime-settings
Created September 16, 2013 07:10
Preferences file for Sublime Text 3
{
"color_scheme": "Packages/User/Monokai Soda.tmTheme",
"font_face": "Menlo",
"font_size": 12,
"ignored_packages":
[
"Vintage"
],
"soda_folder_icons": true,
"theme": "Soda Dark 3.sublime-theme",
@cbednarski
cbednarski / octocats.js
Last active December 22, 2015 23:29
Pull a list of octocats and their creators from http://octodex.github.com/
var items = [];
var pics = jQuery('.item-shell');
for (var i in pics) {
if (i < 165) { // Hack
var artist = jQuery(pics[i]).find('.footer>a');
var item = {
"name":jQuery(pics[i]).find('.purchasable a').html(),
"url" :jQuery(pics[i]).find('.preview-image img').attr('src')
@cbednarski
cbednarski / nginx.conf
Last active January 11, 2019 12:07
Nginx and php-fpm configs for local development
server {
listen 8080;
server_name local.webblob.com;
root /Users/cbednarski/code/WebBlob/src;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 /500.html;
error_page 502 /502.html;
error_page 503 /503.html;