Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
@RichardBronosky
RichardBronosky / URL_transforms.sh
Last active August 29, 2015 13:56
You can download this file and run it to see the result of the test suite via: curl -sL https://gist.github.com/RichardBronosky/8808048/raw/URL_transforms.sh | bash
#!/bin/bash
## The regex string to use for all detail page transforms is:
regex='s/([^:]{4,5}:\/\/)?((www|m).)?(.*)/http:\/\/m.\4?embed=copyright/'
## It is hardened against transient protocol and subdomain presence.
## It does not account for preexisting query strings.
## That would require 2 separate regexes and is not likely to occur in our feed.
## Here is the test suite.
@RichardBronosky
RichardBronosky / grant.py
Last active August 29, 2015 13:56
The GitHub web UI for adding access to repos for organization teams is pretty terrible. Luckily the API is pretty robust.
import re
import sys
from pygithub3 import Github
# Notice: there is a requirements.txt file to help you get pygithub3 via...
# pip install -r requirements.txt
if __name__ == '__main__':
larg = len(sys.argv)
if larg < 5 or larg == 6 or (larg > 7 and sys.argv[5] != '--include'):
print " {command} username password oranization team [--include 'RegularExpression']". format(command=sys.argv[0])
#!/bin/bash
for i in "$@"
do
case $i in
-e=*|--extension=*)
EXTENSION="${i#*=}"
shift
;;
-s=*|--searchpath=*)
@RichardBronosky
RichardBronosky / docker_install.txt
Last active August 29, 2015 14:14
Setting up Docker on Mac OS X 10.10.1
brew update
brew install caskroom/cask/brew-cask
brew cask install virtualbox
// At this point I was getting a sha256 mismatch.
// brew was expecting the same value listed at:
// https://www.virtualbox.org/download/hashes/4.3.20/SHA256SUMS
// But a different sha256 was found for multiple downloads of:
// http://download.virtualbox.org/virtualbox/4.3.20/VirtualBox-4.3.20-96996-OSX.dmg
// This was resolved by:
// rm /Library/Caches/Homebrew/virtualbox-4.3.20-96996.dmg
FROM ubuntu:14.04
MAINTAINER Richard Bronosky <bruno@bronosky.com>
# the default image doesn't have python, so this is going to be a big install
RUN apt-get update && apt-get install -y python-pip
# remove this next line when development is done
#RUN apt-get update && apt-get install -y tmux vim git
RUN pip install -U https://github.com/RichardBronosky/celery_test/archive/master.zip
USER nobody
ENTRYPOINT celery -A celery_test.tasks worker --loglevel=info
Running "cordovaBuild:statesman:android" (cordovaBuild) task
>> Error: Error: ENOENT, no such file or directory '/Users/bruno/src/mm/newspaper-app/projects/statesman/platforms/android/src/com/mm/cmg/newspaper/statesman'
>> at Error (native)
>> at Object.fs.readdirSync (fs.js:765:18)
>> at android_parser.update_from_config (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/android_parser.js:285:25)
>> at android_parser.update_project (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/android_parser.js:349:14)
>> at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:122:27
>> at Array.map (native)
>> at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:65:40
>> at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
@RichardBronosky
RichardBronosky / clone_into_here.sh
Created March 12, 2015 19:56
Clone a repo into the current directory. Good for moving an existing non-version-controlled project to github repo you just created.
# This script is designed so that you can either call it as a script or copy-paste the function into your shell and use it directly.
clone_into_here(){
repo=$1
git clone $repo ./tmp_repo
mv tmp_repo/* tmp_repo/.* ./
rm -r tmp_repo
}
clone_into_here($1)
@RichardBronosky
RichardBronosky / config
Last active August 29, 2015 14:17
.git/config of local service_layer_config.git
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/RichardBronosky/service_layer_config.git
fetch = +refs/heads/*:refs/remotes/origin/*
@RichardBronosky
RichardBronosky / Dockerfile
Last active August 29, 2015 14:17
Your Dockerfile ENTRYPOINT's dirty little secret.
FROM ubuntu
# Works the same on Centos too if you want to try it. ;-)
# "Shell Form"
# Don't do this. it fails to accept arguments from the docker cli
ENTRYPOINT cat
# "Exec Form"
# This is what you want. Even if the "Shell Form" seems to work for you. (See the transcript below.)
ENTRYPOINT ["cat"]
@RichardBronosky
RichardBronosky / Makefile
Created March 29, 2015 22:42
A hands on Makefile learning exercise
TARGET=hello.txt
# This is a hands on learning exercise I made for myself. I hope you get something out of it.
# Here are some experiments to try:
# 1. (notice the "Nothing to be done for")
# make; make;
#
# 2. (notice that it removes hello.txt which clears the previous error)
# make clean; make
#