Skip to content

Instantly share code, notes, and snippets.

View jkmathew's full-sized avatar
🎯
Focusing

Johnykutty Mathew jkmathew

🎯
Focusing
View GitHub Profile
@jkmathew
jkmathew / LoadGithubUsers
Created June 21, 2019 14:11
For spm-tutorial
func loadUsers() {
Alamofire.request("https://api.github.com/search/users?q=language:swift&sort=followers")
.validate()
.responseData { [weak self] (response) in
switch response.result {
case .success:
guard let data = response.data else {
print("empty data received.. handle error")
return
}
//Just an initial draft
func color(for row: Int) -> UIColor {
let block = { (row: Int) -> CGFloat in
let floatValue = min(CGFloat(row), maxValue)
return floatValue / maxValue
}
let green = block(row)
let red = block(10 - row)
@jkmathew
jkmathew / gist:fbfe8c2d015adb448c330687320ada91
Created March 23, 2017 03:36
Startin av capture layer from a view controller
func startSession() {
//Capture Session
let session = AVCaptureSession()
session.sessionPreset = AVCaptureSessionPresetPhoto
//Add device
let device =
AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
//reference https://gist.github.com/tempire/0bd8cb78290aa9bc6adf
func addSignature(_ signature:UIImage, onPDFAt path: String) {
let pdf = CGPDFDocument(NSURL(fileURLWithPath: path))!
let pageCount = pdf.numberOfPages;
UIGraphicsBeginPDFContextToFile(path, CGRect.zero, nil)
for index in 1...pageCount {
xctool -workspace ProjectName.xcworkspace -scheme ProjectName clean
#for project use
#xctool -workspace ProjectName.xcodeproj -scheme ProjectName clean
xctool -workspace ProjectName.xcodeproj -scheme ProjectName -reporter json-compilation-database:compile_commands.json build
#for project use
#xctool -project ProjectName.xcodeproj -scheme BLEDataTransfer -reporter json-compilation-database:compile_commands.json build
oclint-json-compilation-database -- oclint_args -report-type html -o report.html
@jkmathew
jkmathew / Move textfield for keyboard
Last active April 11, 2016 09:29
You have a textfield/textview in the bottom(like in message/whatsapp) of view and keyboard is hiding it? Don't worry, use the following code!!! Connect an NSLayoutConstraint via IBOutlet for the bottom spacing. Also, If you are not using presented view controller with modalPresentationStyle as UIModalPresentationFormSheet , no need to use UIKeyb…
- (void)viewDidLoad {
//register for keyboard notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@jkmathew
jkmathew / MakeYosemiteInstaller
Last active December 17, 2019 17:16
Shell script to create USB installer for OS X Yosemite
#!/bin/sh
# MakeYosemite.sh
#
#
# Created by Johnykutty on 12/24/14.
#
red_color='\033[1;31m'
green_color='\033[0;32m'