Skip to content

Instantly share code, notes, and snippets.

View 2bard's full-sized avatar

2bard 2bard

  • Newcastle-upon-tyne, United Kingdom
View GitHub Profile
@2bard
2bard / OSXuuidGEN
Last active April 21, 2016 23:42
OSX: Bash profile alias to generate a UUID and add to clipboard
To generate a v4 UUID then paste this to your bash/zsh profile:
alias givemeuuid="uuid -v4 | pbcopy && echo 'Copied a UUID to the clipboard.'"
Not tested on any OS other than OSX 10.9.5.
@2bard
2bard / mitmproxy cheat sheet
Created February 13, 2015 19:44
mitmproxy cheat sheet
Movement:
j, k down, up
h, l left, right (in some contexts)
space page down
pg up/down page up/down
arrows up, down, left, right
@2bard
2bard / .gitignore
Created April 25, 2014 15:15
.gitignore for Android Studio projects
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@2bard
2bard / droid_sqlite_dump_compare
Last active August 29, 2015 14:00
Android SQLite dump comparator
Debugging the SQLite database in Android can be a pain. A common technique is to dump the .sqlite database and inspect it using some program.
Sometimes we just want to know what has changed in the database within a time period, we can do this by dumping the database twice and comparing the two dumps.
This function speeds up the process of viewing differences between database dumps.
To use this function create an empty directory and navigate to it. This directory will be where we store dumps and perform comparisons.
Make sure you create a separate directory for each application you’re inspecting, or you may end up comparing dumps from different applications.
Usage: sqlitecompare <path_to_sqlite_file_on_device> e.g. sqlitecompare /data/data/com.2bard.foo/databases/userdb
@2bard
2bard / avd_launcher
Created February 13, 2014 12:11
Launch all Android Virtual Devices from command line
function launchavd {
names=$(android list avd | grep 'Name' | awk '{ print $2 }')
for item in $names; do
echo "Launching VM $item"
nohup emulator -avd $item -no-skin -no-audio -no-window &
done
}
@2bard
2bard / rgb2hex
Last active January 27, 2024 11:24
command line rgb to hex converter
EDIT: a quick google search revealed digitalcolor meter can show hex values so this task was pointless!
I've been doing some Android ui work recently. I keep finding myself needing to use a color from an image stored on my machine. I use OSX's digitalcolor meter tool to grab the rgb values from the image on screen then convert it into hex by asking google (e.g. searching '168 in hex').
Repeatedly doing this task can be frustrating (you might argue that I should just convert them in my head, but why do that when a computer can do it?). So I made a quick function in my .bash_profile which allows me to do it at the command line:
rgb2hex(){
for var in "$@"
@2bard
2bard / dump_var.sublime-snippet
Created June 23, 2013 16:31
Sublime text PHP var dump
<snippet>
<content><![CDATA[
echo '<pre>' . print_r($0, true) . '</pre>'; exit;
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>dump</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
</snippet>
@2bard
2bard / translation_notes
Created December 18, 2012 16:29
Using Symfony translation component in Twig outside of Symfony2 framework.
Note: I've left some of the full package names in tact to show exactly where the class comes from.
#### Pull dependencies in using composer ####
//Example composer.json
{
"require": {
"symfony/config" : "2.1.0",
"symfony/yaml" : "2.1.0",
"twig/twig": "1.9.0",
@2bard
2bard / .haiku.cfg
Created July 18, 2012 20:09
Bash poem echo
function unsetvars {
unset word
unset poem
unset poems
unset line
unset counter
unset linenumber
}