Skip to content

Instantly share code, notes, and snippets.

@Kozlov-V
Kozlov-V / gist:7f15066c0c7188146fae
Last active August 26, 2015 19:26 — forked from DenTelezhkin/gist:beab675d853fcd2fd464
Multipart-form PUT request for image upload. NSURLSession, iOS 7
+(void)uploadUserPhoto:(UIImage *)image
success:(void (^)(void))success
failure:(FailureBlock)failure
{
GTSessionManager * manager = [GTSessionManager manager];
NSString* tmpFilename = [NSString stringWithFormat:@"%f", [NSDate timeIntervalSinceReferenceDate]];
NSURL* tmpFileUrl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:tmpFilename]];
NSString * query = [NSString stringWithFormat:@"%@user?auth_token=%@",[manager.baseURL absoluteString],[[UserManager shared] authToken]];
@Kozlov-V
Kozlov-V / canceltask.m
Created August 28, 2015 18:53
Cancel NSURLSessionTask
- (void)cancel
{
for(NSURLSessionTask *task in _tasks) {
[task cancel];
}
}
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz --no-check-certificate
tar -xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr --enable-shared
make
sudo make install
cd ..
#!/sbin/runscript
# This script assumes that Riemann has a user and group set up, and that the
# service files have been extracted to `/var/lib/riemann/current`.
#
# Author: Greg Look (greg@mvxcvi.com)
extra_started_commands="reload"
CFG_DIR=/etc/riemann
FancyHotSpot *hotSpotA;
FancyHotSpot *hotSpotB;
// notifications from hotSpotA should call hotSpotATouched:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hotSpotATouched:) name:@"HotSpotTouched"
object:hotSpotA]; // only notifications from hotSpotA will be received
// notifications from hotSpotB should call hotSpotBTouched:
[[NSNotificationCenter defaultCenter] addObserver:self
// NSString+Extension.h
@interface NSString (Extension)
+ (NSString *) getUUID;
+ (NSString *) sha1:(NSString *)input;
@end
@Kozlov-V
Kozlov-V / genuuid.m
Created February 15, 2015 12:44
Generate UUID xcode random
+(NSString *) generateUUID
{
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuid);
CFRelease(uuid);
NSString* newUuid = [(NSString *)uuidString copy];
CFRelease(uuidString);
@Kozlov-V
Kozlov-V / dialog_position.java
Created February 24, 2015 18:05
Show AlertDialog in any position of the screen
private CharSequence[] items = {"Set as Ringtone", "Set as Alarm"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if(item == 0) {
} else if(item == 1) {
} else if(item == 2) {
@Kozlov-V
Kozlov-V / statsbarhght.java
Created February 24, 2015 20:29
get Status Bar Heigh
public int getStatusBarHeight() {
int statusBarHeight = 0;
if (!hasOnScreenSystemBar()) {
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
}
@Kozlov-V
Kozlov-V / org.chameleon.Boot.plist
Last active August 29, 2015 14:20
org.chameleon.Boot.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Default Partition</key>
<string>hd(0,2)</string>
<key>EthernetBuiltIn</key>
<string>Yes</string>
<key>Graphics Mode</key>
<string>1024x768x32</string>