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: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 / mysvn
Last active March 13, 2018 10:20
Subversion script to add all unadded and remove all unremoved files.
#!/bin/bash
usage()
{
printf "Supported commands:\n\tadd - adds all new files\n\tremove - removes all deleted files\n\tdiff - colorized diff\n"
exit 1
}
if [ "$#" -eq "0" ]; then usage; fi
if [ $1 == "add" ]; then
svn st | grep ^? | sed 's/^\? *//' | xargs -I% svn add %@
@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 / move_and_rename.sh
Last active January 23, 2023 14:19
bash: Move and rename multiple files
find /path/to/directory -name "*.ext" -exec bash -c 'mv {} $(echo {} | sed -e "s/foo/bar/")' \;
@nestserau
nestserau / AtomicInteger.swift
Last active October 6, 2022 12:12
Atomic way to operate on integers in Swift. Inspired by Java's AtomicInteger
/// This is free and unencumbered software released into the public domain.
///
/// Anyone is free to copy, modify, publish, use, compile, sell, or
/// distribute this software, either in source code form or as a compiled
/// binary, for any purpose, commercial or non-commercial, and by any
/// means.
///
/// In jurisdictions that recognize copyright laws, the author or authors
/// of this software dedicate any and all copyright interest in the
/// software to the public domain. We make this dedication for the benefit