Skip to content

Instantly share code, notes, and snippets.

View dcosson's full-sized avatar

Danny Cosson dcosson

  • San Francisco, CA
View GitHub Profile
#!/bin/bash
#
# Uses github's hub command line tool and r10kdiff gem to open a pull request
# for a repository containing a Puppetfile used by r10k.
#
# Assumes it should be from the current branch <Puppet Environment Name> in a
# fork to the same branch upstream (since you can't use feature branches in the
# same repository with r10k as it might deploy them as environments)
#

Keybase proof

I hereby claim:

  • I am dcosson on github.
  • I am dcosson (https://keybase.io/dcosson) on keybase.
  • I have a public key whose fingerprint is 7315 7FF6 9E72 ABBC 1CB1 0C11 5399 BD81 8F48 C11F

To claim this, I am signing this object:

@dcosson
dcosson / hello.py
Last active August 29, 2015 14:06
Flask Hello
# Simple http server to test concurrency or load balancing or whatever,
# specifying numprocs greater than 1 will run that many instances of the
# flask app in subprocesses on incrementing ports beginning with the one specified
# Run:
# sudo pip install flask
# python hello.py [PORT-NUM] [NUMPROCS]
from flask import Flask
import os
import signal
@dcosson
dcosson / gist:27bcca9b9ad28a38ab60
Last active August 29, 2015 14:08
Rename an ios project

I was renaming a project from GrowthKit to Mave, and updating the prefix.

This got me 95% of the way there, there were a few things to clean up manually (not really sure why because the things I fixed manually matched these rules). Luckily the previous project name wasn't "View" or something that would conflict with any builtin types or setting names

rm -rf Pods
brew install rename 
shopt -s globstar     # requires bash 4.0+, makes ** recursive

rename s/GrowthKit/Mave/ **
@dcosson
dcosson / gist:2defd0bd596f00e14f60
Last active August 29, 2015 14:22
Add an extra share button to mave
MaveSDK *mave = [MaveSDK sharedInstance];
[mave presentInvitePageModallyWithBlock:^(UIViewController *inviteController) {
if ([inviteController isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController *)inviteController;
// Here replace the method "foo" with your method to present a share sheet
// And you can of course use a button with an image instead of the title "Share"
UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithTitle:@"Share"
style:UIBarButtonItemStylePlain
target:self action:@selector(foo)];
@dcosson
dcosson / ableton-post-merge.py
Created March 3, 2012 23:10
A post-merge script to go with the ableton-pre-commit.py
#!/usr/bin/env python
""" Converts all the .xml files back to .als (i.e. gzips them)
"""
import os
import sys
import subprocess
import gzip
@dcosson
dcosson / gist:2698090
Created May 14, 2012 23:40
Brubeck Websockets - testing them out based on implementation in https://github.com/stuntgoat/brubeck.git commit=1e97a9ff196927523a506b6423a1a34d0e6959c0
class TestHandler(WebMessageHandler):
""" Testing out sending data to arbitrary websockets
"""
def get(self):
ws_message = "I like websockets"
to_user_id = self.get_argument('to_user_id')
if not to_user_id:
body = "enter arg ?to_user_id=X"
else:
conn_ids = WSSession.get_active_conn_ids(to_user_id)
@dcosson
dcosson / gist:3321717
Created August 11, 2012 06:18
kill zombie procs
# a quick shell command to kill all procs matching a grep pattern
for i in `ps aux | grep 'manage.py runserver' | grep -v grep | awk '{ printf "%s ", $2 }'` ; do sudo kill $i ; done
@dcosson
dcosson / gist:3430463
Created August 22, 2012 23:12
Phone number regex in js
// allows:
// 1235554567
// (123) 555-4567
// 123.555.4567
// 123-555-4567
/^\(?[0-9]{3}[.\-\)]?\s?[0-9]{3}[.-\s]?[0-9]{4}$/
@dcosson
dcosson / gist:3839768
Created October 5, 2012 13:20
Count viewers on a mongrel2 site
# bash command to count the number of unique ip addresses in the mongrel2 access log (default format)
cat mongrel2.access.log | cut -f 4 -d : | cut -f 1 -d , | sort | uniq | wc -l