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 / 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
@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:1292649
Created October 17, 2011 13:53
Invoke Juicer from Ant build script
<macrodef name="juicer">
<attribute name="inputFile" />
<!-- none|soft|rails|hard -->
<attribute name="cacheBuster" default="none" />
<!-- none|data_uri -->
<attribute name="embedImages" default="data_uri" />
<sequential>
<exec executable="juicer" failOnError="true" logError="true">
<arg value="-v" />
<arg value="merge" />
/**
* This will convert DateTime (.NET) object serialized as JSON by WCF to a NSDate object.
*/
+ (NSDate *)dateFromJSONTicks:(NSString *)inputString;
@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
@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 / 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: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: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;