Skip to content

Instantly share code, notes, and snippets.

View mkll's full-sized avatar
😎

Alex Sherbakov mkll

😎
  • Home Sweet Home
View GitHub Profile
@mkll
mkll / TransparentBar.m
Last active April 18, 2016 03:33
How to draw a transparent UIToolbar or UINavigationBar in iOS7
/*
Setting translucent to YES on the navigation bar does the trick, due to a behavior discussed in the UINavigationBar documentation. I'll report here the relevant fragment:
If you set this property to YES on a navigation bar with an opaque custom background image, the navigation bar will apply a system opacity less than 1.0 to the image.
*/
// Transparent UINavigationBar
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
@mkll
mkll / SDImageCache+Private.h
Created March 29, 2014 13:40
How to get filesystem path to image cached by SDWebImage? There are private SDImageCache methods, so just make these methods public with category. Add the file below to your project.
#import "SDImageCache.h"
@interface SDImageCache (PrivateMethods)
- (NSString *)defaultCachePathForKey:(NSString *)key;
- (NSString *)cachedFileNameForKey:(NSString *)key;
@end
@mkll
mkll / webview.m
Created May 14, 2014 19:56
Определение актуальной высоты контента UIWebView
// CGSizeZero !!!
CGSize contentSize = [self.webView sizeThatFits:CGSizeZero];
@mkll
mkll / switch.m
Created May 26, 2014 04:25
How to set background color of UISwitch
mySwitch.tintColor = [UIColor blackColor];
mySwitch.backgroundColor = [UIColor redColor];
mySwitch.layer.cornerRadius = 16.0; // you must import QuartzCore to do this.
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@mkll
mkll / CoreLocationTest.m
Created September 28, 2016 20:02 — forked from tmiz/CoreLocationTest.m
Using CoreLocation on Mac OS X with command-line
//
// Using CoreLocation on Mac OS X with command-line
// $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation
// $ ./a.out
// location service enabled
// 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538
// 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900
// tmiz moo@tmiz.net
//
#import <cocoa/cocoa.h>
#import <Foundation/Foundation.h>
@interface NSBundle (Language)
+(void)setLanguage:(NSString*)language;
@end
@mkll
mkll / openBLESetting
Created June 21, 2018 19:47 — forked from johnny77221/openBLESetting
opening iOS BLE setting from app
NSURL *bluetoothURLOS8 = [NSURL URLWithString:@"prefs:root=General&path=Bluetooth"];
NSURL *bluetoothURLOS9 = [NSURL URLWithString:@"prefs:root=Bluetooth"];
NSURL *bluetoothURLOS10 = [NSURL URLWithString:@"Prefs:root=Bluetooth"];
if ([[[UIDevice currentDevice] systemVersion] intValue] >= 10) {
Class<NSObject> workSpaceClass = NSClassFromString(@"LSApplicationWorkspace");
if (workSpaceClass) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
id workSpaceInstance = [workSpaceClass performSelector:NSSelectorFromString(@"defaultWorkspace")];
SEL selector = NSSelectorFromString(@"openSensitiveURL:withOptions:");
@mkll
mkll / gist:12f317fe001747c597c9967bef838669
Created August 2, 2018 14:34 — forked from mestizo/gist:9167834
Completely disable IPv6 on OSX
#To Get List of Hardware
sudo networksetup -listallhardwareports
#To Disable IPv6 on Wifi Adapter
sudo networksetup -setv6off wi-fi
#To Disable IPv6 on Built-in Ethernet Adapter
sudo networksetup -setv6off Ethernet
@mkll
mkll / wifi_scan.m
Created August 21, 2018 07:27 — forked from pavel-a/wifi_scan.m
Wi-Fi scan for Apple OS X (maybe works for iOS too)
/* The official example for CoreWLAN is now obsolete,
so here's a small command-line example that works with Xcode 6 and Yosemite.
It only demonstrates how to get basic wi-fi connection properties and scan.
Enjoy!
pavel_a@fastmail.fm 01-Mar-2015
*/
#import <Foundation/Foundation.h>
#import <CoreWLAN/CoreWLAN.h>
#include <stdio.h>