Skip to content

Instantly share code, notes, and snippets.

@jayzeng
jayzeng / syntax_check.py
Created May 25, 2013 03:14
syntax check for modified puppet template and manifests
#!/usr/bin/python
import os.path
import subprocess
import sys
def get_modified_files():
"""
return a list of modified files tracked by git
"""
git_status = subprocess.Popen(['git', 'status', '-s'], stdout=subprocess.PIPE)
@jayzeng
jayzeng / curl.md
Created May 27, 2013 01:59 — forked from btoone/curl.md

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@jayzeng
jayzeng / server.sh
Created June 11, 2013 05:49
server function from paul irish
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
python -m SimpleHTTPServer "$port"
}
@jayzeng
jayzeng / findmax.php
Created June 11, 2013 06:09
Find max
<?php
function findMax(array $input, $range) {
$curSum = 0;
for($i=0;$i<count($input);$i++) {
$subArr = array_slice($input, $i, $range);
$sum = 0;
foreach($subArr as $arr) {
$sum += $arr;
@jayzeng
jayzeng / gruntfile.js
Created June 17, 2013 00:32
php grunt task From http://chrsm.org/
/**
* Gruntfile.js
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
php: {
dist: {
options: {
port: 8080,
@jayzeng
jayzeng / mat_remote
Last active December 19, 2015 13:09
mat remote
#!/usr/bin/python
import subprocess
devs = {}
devs['jayzeng'] = 'jayzeng'
devs['niek'] = 'nieksand'
devs['lee'] = 'leehasoffers'
devs['lucas'] = 'lucasoffers'
devs['josh'] = 'joshs633'
devs['jack'] = 'jackofseattle'
@jayzeng
jayzeng / list_repo.py
Created July 9, 2013 19:23
list repo
#!/usr/bin/env python
from github3 import login
def list_branches(token, target_repo):
github_login = login(token=token)
repos = github_login.iter_repos()
for r in repos:
if r.name == target_repo:
@jayzeng
jayzeng / psql
Last active December 19, 2015 16:58
psql cheat sheet
\l list databases
\d list tables
\d table describe table
@jayzeng
jayzeng / get_sample.py
Created July 30, 2013 20:47
down load sample
import os
import logging
import argparse
from boto.s3.connection import S3Connection
def create_dir(type):
if not os.path.exists(type):
os.mkdir(type)
def get_aws_credentials():
@jayzeng
jayzeng / find.py
Created July 31, 2013 23:07
find files per pattern
import os
import fnmatch
def gen_find(filepath, loc):
for path, diralist, filelist in os.walk(loc):
for name in fnmatch.filter(filelist, filepath):
yield os.path.join(path, name)
pyfiles = gen_find('*.py', '.')