Skip to content

Instantly share code, notes, and snippets.

Avatar
👹

Artem Loenko dive

👹
View GitHub Profile
View xcode_ramdisk.sh
#!/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"
View shouldStartLoadWithRequest_signature.m
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
@dive
dive / debug_embedded_uiwebview.m
Last active Aug 29, 2015
Debug embedded UIWebView
View debug_embedded_uiwebview.m
#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 Aug 29, 2015
Quick fix for Google Drive icon for dark menu bar (OS X 10.10)
View fix_google_drive_icon_black.sh
#!/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 Mar 1, 2012
lepra stuff diff
View gist:1952734
--- 123.html
+++ (clipboard)
@@ -183,7 +183,7 @@
.main {
-
+ background:url(/i/login/field.jpg) 50% 64%;
@dive
dive / gist:1979003
Created Mar 5, 2012
coredata with dispatch
View gist:1979003
- (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 Jun 12, 2012
iOS 5 cyrillic domain byg
View gist:2920023
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 Jun 16, 2012
Redefine Spotlight Privacy settings
View redefine_spotlight.scpt
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 Jun 23, 2012
instance variables (interface declaration)
View gist:2977600
/* 1 - непосредственно в интерфейсе класса (*.h) */
@interface IVExample : NSObject {
NSString *string;
int number;
}
@end
@dive
dive / gist:2977631
Created Jun 23, 2012
instance variables (extension declaration)
View gist:2977631
/* 2 - в class extension */
@interface IVExample () {
NSString *string;
int number;
}
@end