Skip to content

Instantly share code, notes, and snippets.

View dive's full-sized avatar
👹

Artem Loenko dive

👹
View GitHub Profile
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"
@dive
dive / shouldStartLoadWithRequest_signature.m
Last active August 29, 2015 14:05
shouldStartLoadWithRequest
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
@dive
dive / debug_embedded_uiwebview.m
Last active August 29, 2015 14:05
Debug embedded UIWebView
#if TARGET_IPHONE_SIMULATOR
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
[NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];
#pragma clang diagnostic pop
#endif
@dive
dive / fix_google_drive_icon_black.sh
Last active August 29, 2015 14:13
Quick fix for Google Drive icon for dark menu bar (OS X 10.10)
#!/bin/sh
GOOGLE_DRIVE_DEFAULT_PATH=/Applications/Google\ Drive.app/Contents/Resources
# backup
find "$GOOGLE_DRIVE_DEFAULT_PATH"/ -type f -name 'mac-normal*.png' -exec cp -v '{}' '{}'.backup \;
# copy all needed files to tmp
cp -f -v "$GOOGLE_DRIVE_DEFAULT_PATH"/mac-normal*.png /tmp/
@dive
dive / gist:1952734
Created March 1, 2012 20:05
lepra stuff diff
--- 123.html
+++ (clipboard)
@@ -183,7 +183,7 @@
.main {
-
+ background:url(/i/login/field.jpg) 50% 64%;
@dive
dive / gist:1979003
Created March 5, 2012 16:02
coredata with dispatch
- (void)saveArrayOfImages:(NSMutableArray *)arrayOfImages
{
for (UIImage *imageObject in arrayOfImages)
{
dispatch_queue_t backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(backgroundQueue, ^{
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSData *dataFromImage = UIImagePNGRepresentation(imageObject);
@dive
dive / gist:2920023
Created June 12, 2012 20:46
iOS 5 cyrillic domain byg
NSString *string = [NSString stringWithUTF8String: @"http://президент.рф"];
NSURL *url = [NSURL URLWithString:[string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
After this operations I check NSURL with:
[[UIApplication sharedApplication] canOpenURL:url]
canOpenURL return true. Then I open this NSURL at build-in browser Safari,
Safari told me that this page cannot be opened
(encoded URL seems like: http://xn--d1abbgf6aiiy.xn--p1ai),
after this I just press Refresh at browser without any additional actions
@dive
dive / redefine_spotlight.scpt
Created June 16, 2012 16:27
Redefine Spotlight Privacy settings
set volume_path_to_disable to POSIX path of "/Volumes/Macintosh HD/"
set volume_path_to_enable to POSIX path of "/Volumes/OS X Mountain Lion"
set command to "mdutil -d " & quoted form of volume_path_to_disable & "&&" & "mdutil -i on " & quoted form of volume_path_to_enable
do shell script command with administrator privileges
@dive
dive / gist:2977600
Created June 23, 2012 08:49
instance variables (interface declaration)
/* 1 - непосредственно в интерфейсе класса (*.h) */
@interface IVExample : NSObject {
NSString *string;
int number;
}
@end
@dive
dive / gist:2977631
Created June 23, 2012 08:59
instance variables (extension declaration)
/* 2 - в class extension */
@interface IVExample () {
NSString *string;
int number;
}
@end