Skip to content

Instantly share code, notes, and snippets.

View psobko's full-sized avatar

Piotrek Sobkowski psobko

View GitHub Profile
@psobko
psobko / gist:c4ba658266867bf4cf90
Created August 19, 2015 14:15
Robocraft consumer.exe dump
Game events controller is now connected!
-------------------------
Received 7 new info db updates:
<playerData, username>: buttskratc
<playerData, playerLevel>: 100
<playerData, playerExperience>: 1
overwolf.games.events.onError.addListener(
function (value) {
console.log('error');
console.log(value);
}
);
overwolf.games.events.onInfoUpdates.addListener(
function (value) {
@psobko
psobko / DLOG
Last active August 29, 2015 14:20
DLog Debug Logger
// DEBUG ////////////////////////////////////////////////////
#ifndef DEBUG_LEVEL
#define DEBUG_LEVEL 0
#endif
#if DEBUG
#define DLog(fmt, ...) if(DEBUG_LEVEL)NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DLog(...)
@psobko
psobko / DeviceStorage.m
Created October 30, 2014 17:02
Get device storage using NSFileManager API. This code will print the results of each possible NSSearchPathDirectory.
#import <Foundation/Foundation.h>
void logStorageForLocation(NSSearchPathDirectory location) {
NSError *error;
NSArray * const paths = NSSearchPathForDirectoriesInDomains(location, NSUserDomainMask, YES);
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject]
error:&error];
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;
NSMutableArray* animationBlocks = [NSMutableArray new];
typedef void(^animationBlock)(BOOL);
animationBlock (^getNextAnimation)() = ^{
animationBlock block = animationBlocks.count ? (animationBlock)animationBlocks[0] : nil;
if (block)
{
[animationBlocks removeObjectAtIndex:0];
return block;
@implementation NSNumber (Subscripting)
// call it like this: [@0:1];
- (NSIndexSet*):(NSUInteger)length
{
return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self unsignedIntegerValue], length)];
}
@end
#pragma mark - Phone Number Field Formatting
// Adopted from: http://stackoverflow.com/questions/6052966/phone-number-formatting
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField == self.mobileNumberField || textField == self.homeNumberField || textField == self.workNumberField) {
int length = [self getLength:textField.text];
if(length == 10) {
if(range.length == 0)
@psobko
psobko / UIImagePickerController(HideStatusBar)
Created March 11, 2014 19:41
Hide the status bar in UIImagePickerController on iOS7
@implementation UIImagePickerController (HideStatusBar)
- (BOOL)prefersStatusBarHidden
{
return YES;
}
- (UIViewController *)childViewControllerForStatusBarHidden
{
return nil;
@psobko
psobko / CGRectGetCenter
Created February 7, 2014 17:44
Get the center of a CGRect
CGPoint (^CGRectGetCenter)(CGRect) = ^(CGRect rect)
{
return CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
};
@psobko
psobko / Check UIButton Wired To Action
Created December 19, 2013 17:35
Check if a UIButton is wired to an action
-(BOOL)validateButton:(UIButton*)button WiredToAction:(NSString*)action
{
NSArray *actions = [button actionsForTarget:testSubject forControlEvent:UIControlEventTouchUpInside];
XCTAssertNotNil(actions);
return ([actions indexOfObject:action] != NSNotFound);
}