Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# myservice This shell script takes care of starting and stopping
# the /home/webreports/report-listen
#
# Source function library
. /etc/rc.d/init.d/functions
@deivuh
deivuh / Objective C REST
Last active August 29, 2015 14:03
Objective C REST request, receive and parse json into dictionary
- (void) sendRequest {
receivedData = [[NSMutableData alloc] init];
NSLog(@"Initial data length: %d",[receivedData length]);
requestURL = [NSString stringWithFormat:@"<#URL HERE#>"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:requestURL]];
[request setHTTPMethod:@"GET"];
@deivuh
deivuh / PrepareForSegueiOS
Created July 10, 2014 02:51
Prepare for Segue iOS, to pass around objects between view controllers when using story board segues
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"<#SEGUE_NAME#>"])
{
TheViewController *vc = [segue destinationViewController];
[vc setObject:object];
}
@deivuh
deivuh / customURL.m
Last active August 29, 2015 14:04 — forked from mralexgray/customURL.m
Here is what you need to do to register your app for a custom URL scheme (for the example we will use a "myapp" scheme).
1) In your Info.plist, add a new entry for CFBundleURLTypes:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>MyApp's URL</string>
<key>CFBundleURLSchemes</key>
@deivuh
deivuh / gist:01af021bfd3b32ac921a
Created July 24, 2014 06:04
Git ignore file changes
Ignore file changes
git update-index --assume-unchanged <file>
Undo
git update-index --no-assume-unchanged <file>
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@deivuh
deivuh / osx_install.sh
Last active August 29, 2015 14:07 — forked from t-io/osx_install.sh
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
# install wallpaper cli
sudo gem install desktop
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  1. The new API will crash if we call it on iOS 7
  2. The new API won't compile if we build it using the iOS 7 SDK
  3. The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

These three problems require three different technical solutions:

  1. We can avoid calling the new API on an old OS version by using runtime detection (e.g. respondsToSelector:)
  2. We can avoid compiling new APIs on old SDKs using the __IPHONE_OS_VERSION_MAX_ALLOWED macro
### Keybase proof
I hereby claim:
* I am deivuh on github.
* I am deivuh (https://keybase.io/deivuh) on keybase.
* I have a public key whose fingerprint is 44E2 08D8 A6CB 8DD3 CCA6 C17A 2F22 BB13 E4A0 8CC2
To claim this, I am signing this object:
@deivuh
deivuh / install-cask-apps.sh
Last active January 4, 2022 07:17
Brew Cask Script
#!/bin/sh
# brew install emacs
# Better version of emacs (w/ GUI)
#brew tap railwaycat/emacsmacport
#brew install emacs-mac --with-no-title-bars # Switched for Emacs-Plus, better maintained and now supports no-title bar option
brew tap d12frosted/emacs-plus
brew install emacs-plus --with-no-titlebar