Skip to content

Instantly share code, notes, and snippets.

View etolstoy's full-sized avatar
🥦

Egor Tolstoy etolstoy

🥦
View GitHub Profile
@etolstoy
etolstoy / better-navigation-1
Last active August 29, 2015 14:14
Better Navigation in iOS
#pragma mark - IBActions
- (void)button1Clicked:(id)sender {
[self performSegueWithIdentifier:@"detailSegue1"];
}
- (void)button2Clicked:(id)sender {
[self performSegueWithIdentifier:@"detailSegue2"];
}
@etolstoy
etolstoy / parse-security-1
Created January 11, 2015 12:57
Parse Security in iOS Applications
PFQuery *query = [PFQuery queryWithClassName:@"ParseClassName"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
NSLog(@"%@", objects);
}];
@etolstoy
etolstoy / printmethods.cy
Last active August 29, 2015 14:10
Dropbox & Cycript
function printMethods(className) {
var count = new new Type("I");
var methods = class_copyMethodList(objc_getClass(className), count);
var methodsArray = [];
for(var i = 0; i < *count; i++) {
var method = methods[i];
methodsArray.push({selector:method_getName(method), implementation:method_getImplementation(method)});
}
free(methods);
free(count);
@etolstoy
etolstoy / zbar
Created September 4, 2014 06:30
ZBar Configuration
ZBarImageScanner *scanner = _viewPreview.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
[scanner setSymbology: ZBAR_QRCODE
config: ZBAR_CFG_Y_DENSITY
to: 1];
[scanner setSymbology: ZBAR_QRCODE
config: ZBAR_CFG_X_DENSITY
to: 1];
@etolstoy
etolstoy / nsbt-1
Last active August 29, 2015 14:03
No So Boring UITableViews
@property (strong, nonatomic) NSNumber* cellZoomXScaleFactor;
@property (strong, nonatomic) NSNumber* cellZoomYScaleFactor;
@property (strong, nonatomic) NSNumber* cellZoomXOffset;
@property (strong, nonatomic) NSNumber* cellZoomYOffset;
@property (strong, nonatomic) NSNumber* cellZoomInitialAlpha;
@property (strong, nonatomic) NSNumber* cellZoomAnimationDuration;
NSString *newKey = @"NewPassKey";
[database rekey:newKey];
- (FMDatabase *)openWriteableDatabase
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"encrypted.sqlite"];
FMDatabase* database = [FMDatabase databaseWithPath:writableDBPath];
[database open];
NSString *key = @"PassKey";
[database setKey:key];
@etolstoy
etolstoy / AppDelegate.m
Created May 12, 2014 18:52
sqlcipher-1
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [documentPaths objectAtIndex:0];
self.databasePath = [documentDir stringByAppendingPathComponent:@"sqmple.sqlite"];
[self createAndCheckDatabase];
return YES;
}
- (void) stopReading:(BroadcastTableViewCell *)cell
{
if([_speechSynthesizer isSpeaking]) {
[_speechSynthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@""];
[_speechSynthesizer speakUtterance:utterance];
[_speechSynthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
cell.megaphoneButton.selected = NO;
@etolstoy
etolstoy / BroadcastViewController.m
Last active August 29, 2015 13:58
texttospeech-2
- (void) readCellText:(NSString *)text withCell:(BroadcastTableViewCell *)cell
{
[self stopReading:cell];
cell.megaphoneButton.selected = YES;
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ru-RU"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];