Skip to content

Instantly share code, notes, and snippets.

View christophior's full-sized avatar

Chris Villarreal christophior

View GitHub Profile
@christophior
christophior / git_autocomplete.sh
Created July 28, 2015 18:38
Git auto complete
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
# add following to .bash_profile
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
@christophior
christophior / metadata.proto
Created July 18, 2015 20:03
metadata.proto
package spotify.metadata.proto;
option optimize_for = SPEED;
option java_package = "com.spotify.metadata.proto";
option java_outer_classname = "Metadata";
message TopTracks {
optional string country = 1;
repeated Track track = 2;
}
@christophior
christophior / .gitconfig
Last active June 1, 2018 20:34
My .gitconfig
[alias]
st = status
br = branch
co = checkout
ci = commit
up = rebase
one = log --oneline --decorate
dif = git diff --word-diff
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
@christophior
christophior / .bash_profile
Last active August 29, 2015 14:22
Terminal Setup
# directory name in terminal tab
function tab_title {
echo -n -e "\033]0;${PWD##*/}\007"
}
PROMPT_COMMAND="tab_title ; $PROMPT_COMMAND"
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
"effective.
Power
لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ
冗"
@christophior
christophior / wireless_debugging
Last active August 29, 2015 14:06
Android Wireless Debugging
// Add sdk path to .bash_profile
// example
// export PATH=/Users/ChrisV/Development/adt-bundle-mac-x86_64-20131030/sdk/platform-tools:/Users/ChrisV/Development/adt-bundle-mac-x86_64-20131030/sdk/tools:$PATH
// Connect device
adb tcpip 5555
adb connect <device ip>:5555
// now you can disconnect your device
adb usb // goes back to usb debugging

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

# http://goo.gl/sxbh65
# Presentbot.py
import praw
import pickle
import time
# log in
# reading login info from a file, it should be username \n password
with open("login.properties", "r") as loginFile:
login_info = loginFile.readlines()
from Queue import Queue # Threadsafe queue for threads to use
from collections import Counter # To count stuff for us
import datetime # Because datetime printing is hard
from pprint import pprint
import time # Should be obvious
import subprocess # Used to send notifications on mac
import sys # Get system info
import threading # Should be obvious
import json # Also obvious

A crash course in setting up your Python Reddit bot on Heroku

You'll need to do the following:

  • You need to make your bot a python app. Do this by making another directory (can be the same name as the regular one) and put all your python code in that, and make an empty file called __init__.py in it as well. See how I structured mine if this isn't clear. In your base directory, create two files: "requirements.txt" and "runtime.txt". The requirements.txt file should be the output of pip freeze (you can run the command "pip freeze > requirements.txt"). If you're not using virtualenv, you'll need to go through after and delete all the lines with packages your code doesn't actually use. Check out mine to see what I mean. Runtime.txt just specifies with python version for heroku to use. Mine just has the line "python-2.7.4" in it. All of this will tell heroku to recognize your bot as a python app.

  • Make a heroku account and