Skip to content

Instantly share code, notes, and snippets.

View mdigan's full-sized avatar

Matt Digan mdigan

View GitHub Profile
@mdigan
mdigan / count.sh
Created September 27, 2012 13:49
Count all the lines of all the files in a directory
#!/bin/bash
find . -type f -exec wc -l {} \; | cut -f1 -d" " | awk '{a+=$0}END{print a}'
@mdigan
mdigan / tweets.js
Created September 27, 2012 14:53
Twitter JSON feed with JQuery, Knockout.js, and Bootstrap
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tweets</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://github.com/downloads/SteveSanderson/knockout/knockout-2.0.0.debug.js"></script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootswatch/2.1.0/spacelab/bootstrap.min.css" rel="stylesheet">
<style>
@mdigan
mdigan / freq.R
Created September 27, 2012 14:58
Use R to plot a frequency distribution
x = read.table("foo.txt", sep="\t", header=T)
span = seq(0,10, by=1)
span.cut = cut(x$V1, span, right=FALSE)
span.freq = table(span.cut)
cbind(span.freq)
plot(span.freq)
prop.table(span.freq)
cbind(prop.table(span.freq))
plot(prop.table(span.freq))
@mdigan
mdigan / gist:3821129
Created October 2, 2012 16:59
sample javascript project layout
javascript project
├── css
├── data
├── fonts
├── html
├── images
├── js
│   ├── controllers
│   │   └── product
│   ├── utils
@mdigan
mdigan / test_flask.py
Created October 5, 2012 15:57 — forked from k4ml/test_flask.py
Flask+SQLAlchemy
from flask import Flask, request, session
from sqlalchemy import create_engine, Table, MetaData
from sqlalchemy.orm import mapper, relationship, sessionmaker, scoped_session
from sqlalchemy.sql import select
app = Flask(__name__)
engine = create_engine('postgresql+psycopg2://kamal@localhost/clinic_dev')
metadata = MetaData(bind=engine)
DBSession = scoped_session(sessionmaker(bind=engine))
@mdigan
mdigan / new-iterm-tab.scpt
Last active February 23, 2018 07:32
Create a new iterm tab with a random background color
tell application "iTerm"
activate
tell the first terminal
set mysession to (make new session at the end of sessions)
-- talk to the session
tell mysession
@mdigan
mdigan / sqoop_1.4.4_java_api_on_windows.md
Last active December 23, 2015 07:19
Get the Sqoop 1.4.4 Java API running on Windows (for development only)
# Load balancer configuration
upstream exampleApp {
# Directs to the process with least number of connections.
least_conn;
# One failed response will take a server out of circulation for 20 seconds.
server 127.0.0.1:10080 fail_timeout=20s;
server 127.0.0.1:10081 fail_timeout=20s;
#server 127.0.0.1:10082 fail_timeout=20s;
#server 127.0.0.1:10083 fail_timeout=20s;

Node.js - npm Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

##List of less common (however useful) NPM commands

######Install a package and also update package.json with the installed version and package name.

####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade