Skip to content

Instantly share code, notes, and snippets.

View nestserau's full-sized avatar

Aleks Nestserau nestserau

  • Nederland, Randstad
View GitHub Profile
@nestserau
nestserau / gist:11364086
Last active August 29, 2015 14:00
One-line git log formatting with short hash. Supports terminal colorizing.
$ git config format.pretty "format:%C(auto)%h %s"
@nestserau
nestserau / gist:11364748
Last active August 29, 2015 14:00
Launches an Android emulator with some predefined settings
pushd ~/.android/avd/$1.avd/
sed -i .bak 's/\(window.[xy] = \)-*[0-9]*/\10/g' emulator-user.ini
popd
pushd ~/android-sdks/tools/
if [ ! -z "$2" ]; then
emulator @$1 -scale $2
else
emulator @$1
fi
popd
@nestserau
nestserau / gist:11364907
Created April 28, 2014 08:02
Git commands aliases
function changes() {
if [ "$1" = "show" ]
then
git log -n 10 --no-merges
elif [ "$1" = "get" ]
then
git pull --rebase
elif [ "$1" = "post" ]
then
git push
@nestserau
nestserau / gist:955e609f8c8175c5212d
Created April 29, 2014 20:41
How to search for a word in entire content of a directory in linux
If your grep supports the -r or -R option for recursive search, use it.
grep -r word .
Otherwise, use the -exec primary of find. This is the usual way of achieving the same effect as xargs, except without constraints on file names. Reasonably recent versions of find allow you to group several files in a single call to the auxiliary command. Passing /dev/null to grep ensures that it will show the file name in front of each match, even if it happens to be called on a single file.
find . -type f -exec grep word /dev/null {} +
Older versions of find (on older systems or OpenBSD, or reduced utilities such as BusyBox) can only call the auxiliary command on one file at a time.
@nestserau
nestserau / gist:1f6e1621fdad199b5fce
Created May 1, 2014 11:40
View the change history of a file using Git versioning
I have got as far as:
git log -- [filename]
which shows me the commit history of the file, but how do I get at the content of each of the changes?
gitk [filename]
You can use
@nestserau
nestserau / gist:d97e5b3fffc95471ea4f
Last active August 29, 2015 14:06
Embed artwork with atomicparsley, oneliner, Mac OS X tested
for f in *.m4a; do atomicparsley "$f" --artwork folder.jpg; done; rm !(*temp*); for f in *.m4a; do g=${f//-temp*./.}; mv "$f" "$g"; done;
@nestserau
nestserau / gist:a8e3df58c13a9b92b185
Last active August 29, 2015 14:07
Backup APK content from the currently connected device
#!/bin/bash
output=~/data.ab
package=${1:-"com.my.package"}
openssl="/usr/local/opt/openssl/bin/"
export PATH=$openssl:$PATH
adb -d backup -f $output -noapk $package
pushd ~
dd if=$output bs=1 skip=24 | openssl zlib -d | tar -xvf -
rm $output
@nestserau
nestserau / gist:f46a8abbc69a9697180d
Created June 25, 2015 07:19
Draw line in UIView
/* http://stackoverflow.com/questions/3128752/draw-line-in-uiview */
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
// Draw them with a 2.0 stroke width so they are a bit more visible.
CGContextSetLineWidth(context, 2.0f);
@nestserau
nestserau / gist:296671
Created February 6, 2010 11:52
Picking an email address from Address Book with no fail
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)
peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef emails = ABRecordCopyValue(person, property);
CFStringRef email = ABMultiValueCopyValueAtIndex(emails, identifier);
NSString *str = [textField text];
if (![str isEqualToString:@""]) {
@nestserau
nestserau / MainController.h
Created February 6, 2010 11:39
Простое введение в компонентно-ориентированное программирование под iPhone
@class SCViewSlider;
@interface MainController : UIViewController {
@private
SCViewSlider *_viewSlider;
}
@property (nonatomic, retain) IBOutlet SCViewSlider *viewSlider;
@end