Skip to content

Instantly share code, notes, and snippets.

View MKSG-MugunthKumar's full-sized avatar

Mugunth Kumar MKSG-MugunthKumar

  • Melbourne, Australia
  • 11:39 (UTC +11:00)
View GitHub Profile
//
// Created by Mugunth Kumar, Copyright © 2019 MK. All rights reserved.
//
import Foundation
import UIKit
import ImageIO
public extension UIImageView {
@MKSG-MugunthKumar
MKSG-MugunthKumar / measure.swift
Last active February 22, 2016 23:34
Measures Time Taken for a closure to run
func measure(prefix: String = "Time Taken", closure:()->()) {
let a = CFAbsoluteTimeGetCurrent()
closure()
let b = CFAbsoluteTimeGetCurrent()
let m = ((b-a) * 1000.0)
print("\(prefix): \(m) ms")
}
@MKSG-MugunthKumar
MKSG-MugunthKumar / NSURLRequest+cURL
Created May 5, 2015 04:05
NSURLRequest cURL description
- (NSString *)description {
__block NSMutableString *displayString = [NSMutableString stringWithFormat:@"curl -v -X %@", self.HTTPMethod];
[displayString appendFormat:@" \'%@\'", self.URL.absoluteString];
[self.allHTTPHeaderFields enumerateKeysAndObjectsUsingBlock:^(id key, id val, BOOL *stop) {
[displayString appendFormat:@" -H \'%@: %@\'", key, val];
}];
#!/bin/bash
function check {
status=`curl -Is http://store.apple.com/sg/ | grep "HTTP/1.1"`
echo ${status:9:3}
if [ "${status:9:3}" == "200" ]; then
while true; do
say "Its here... Its here... Its here"
echo -en "\007"
done
fi
@MKSG-MugunthKumar
MKSG-MugunthKumar / gist:5044533
Created February 27, 2013 02:41
UIAppearance for nav bar customization.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setBackgroundImage:[[UIImage imageNamed:@"NavButton"] stretchableImageWithLeftCapWidth:10 topCapHeight:0]
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setBackButtonBackgroundImage:[[UIImage imageNamed:@"BackButton"] stretchableImageWithLeftCapWidth:15 topCapHeight:0]
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTintColor:[UIColor rmRedColor]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBarBG"]
@MKSG-MugunthKumar
MKSG-MugunthKumar / Base Init
Created January 20, 2013 03:55
Initializing a custom control.
-(void) baseInit_ {
<#Your code here#>
}
-(id) initWithCoder:(NSCoder *)aDecoder {
if(self = [super initWithCoder:aDecoder]) {
#if ! __has_feature(objc_arc)
#error This file/class is targeted for the ARC compiler. Either turn on ARC for your project or use -fobjc-arc flag
#endif
@MKSG-MugunthKumar
MKSG-MugunthKumar / gist:2036521
Created March 14, 2012 13:35
UIView Shadow within PNG
self.myView.layer.masksToBounds = NO;
self.myView.layer.shadowColor = [UIColor blackColor].CGColor;
self.myView.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
self.myView.layer.shadowOpacity = 0.7f;
self.myView.layer.shadowRadius = 3.0f;
@MKSG-MugunthKumar
MKSG-MugunthKumar / gist:1576556
Created January 8, 2012 00:11
MKNetworkEngine and UIImageView
[AppDelegate.imageFetcher imageAtURL:self.profile.avatarURL
onCompletion:^(UIImage *image, NSURL *url, BOOL isInCache)
{
// this "if" is to prevent images flashing repeatedly when cells are reused.
if ([[self.profile.avatarURL absoluteString] isEqualToString:[url absoluteString]]) {
self.avatarImageView.image = resizedImage;
}
}];
@MKSG-MugunthKumar
MKSG-MugunthKumar / initgit.sh
Created January 19, 2011 02:13
Initialize a git repository and copy a git ignore file from your home directory
# Copy this file to /usr/local/bin/ on your Mac
# type chmod +x initgit.sh
# From now on, on any folder, you can just type initgit.sh and a new git repo with a default .gitignore file will be created for you.
#! /bin/sh
git init
cp ~/.gitignore .
rm -r build/
git add .gitignore