Skip to content

Instantly share code, notes, and snippets.

View erikcox's full-sized avatar

Erik erikcox

View GitHub Profile
@erikcox
erikcox / android_sdk_update.sh
Last active October 14, 2015 17:37
Android Notes
android update sdk --no-ui --all
// One
if(BuildConfig.DEBUG) {
Toast.makeText(this, "Debug mode", Toast.LENGTH_SHORT).show();
}
// Two
try {
appInfo = pacMan.getApplicationInfo(pacName, 0);
} catch (NameNotFoundException e) {
Toast.makeText(this, "Could not find package " + pacName, Toast.LENGTH_SHORT).show();
@erikcox
erikcox / grid.java
Created November 5, 2015 17:25
A grid to help line things up when using graphics in Java
// Paste inside public void paint()
g.setColor(Color.black);
g.setFont(new Font(null));
for ( int X=0; X<800; X += 50 )
g.drawString( String.valueOf(X), X, 50 );
for ( int Y=100; Y<600; Y += 50 )
g.drawString( String.valueOf(Y), 28, Y );
// lines
g.setColor(Color.lightGray);
for ( int X=0; X<800; X += 50 )
@erikcox
erikcox / progress_bar.py
Created December 12, 2015 22:08
Progress bar function in Python
def update_progress(progress):
print '\r{1}%[{0}] '.format('#' * (progress/2), str(progress).zfill(2)),
# Useage
data = []
count = 0.0
total = len(data)
print 'Starting...'
# iterate over something and update count
@erikcox
erikcox / SublimeText2.txt
Created August 2, 2013 03:35
Sublime Text notes
Ctrl+D to select next occurence of word.
Alt+F3 to select all occurences of a word.
R-Click & Shift for column select. Ctrl to add to selection.
Make selection, Ctrl+Shift+L (L for lines)
Ctrl+Shift+P for command bar. Type somethign like syntax or just javascript (it does fuzy searching)
Ctrl+P searches your file system (fuzzy search as well). Enter @ symbol on highlighted file to get Ctrl+R functionality (see)
Ctrl+R to browse symbols / method names / style sheets.
Ctrl+I is incremental search (what does this do?)
Ctrl+Shift+P and type snipper for the working files language snippets
You can create your own snippets.
@erikcox
erikcox / tmux.txt
Last active February 17, 2016 19:00
tmux notes
tmux new -s session_name -n window_name # Creates a new session with a named window
tmux attach -t session_name # Attaches to tmux session
tmux ls # Lists all tmux sessions
#PREFIX is Ctrl-b by default
PREFIX ? # Lists all commands available
PREFIX d # Detaches window
PREFIX c # New window
PREFIX , # Rename window
PREFIX n # Next window
@erikcox
erikcox / hide_keyboard.xml
Created September 22, 2016 23:12
Hide the soft keyboard on Activity load in Android
<!-- AndroidManifest.xml -->
<activity android:name="com.your.package.ActivityName"
android:windowSoftInputMode="stateHidden" />
@erikcox
erikcox / update_pip_modules.py
Created August 1, 2014 15:56
Update Python modules with pip (*nix/OS X)
#!/usr/bin/env python
import os
import pip
dists = []
for dist in pip.get_installed_distributions():
dists.append(dist.project_name)
for dist_name in sorted(dists, key=lambda s: s.lower()):
@erikcox
erikcox / todo.pre-push.sh
Created December 11, 2015 03:31
Add git pre-push hook to check for TODO: in comments
# create the pre-commit file & make it executable
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# The line below is important!
#!/bin/bash
# Don't push if TODO is in the source for HEAD
dont_push_flag="TODO"
flag_found=`git grep --color "$dont_push_flag" HEAD`