Skip to content

Instantly share code, notes, and snippets.

@minikin
minikin / UIImageExtension.swift
Last active August 29, 2015 14:26
imageFromUrl
import UIKit
extension UIImageView {
public func imageFromUrl(urlString: String) {
if let url = NSURL(string: urlString) {
let request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {
(response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
self.image = UIImage(data: data)
@minikin
minikin / mapbox.log
Created February 19, 2016 15:17
mapbox crash
libc++abi.dylib`__cxa_throw:
-> 0x255b0584 <+0>: push {r4, r5, r6, r7, lr}
0x255b0586 <+2>: add r7, sp, #0xc
0x255b0588 <+4>: str r8, [sp, #-4]!
0x255b058c <+8>: mov r8, r2
0x255b058e <+10>: mov r6, r1
0x255b0590 <+12>: mov r4, r0
0x255b0592 <+14>: bl 0x255b018c ; __cxa_get_globals
0x255b0596 <+18>: mov r5, r0
0x255b0598 <+20>: bl 0x255b0d44 ; std::get_unexpected()
@minikin
minikin / Singleton.swift
Last active March 20, 2016 15:14
Singleton in Swift
// Singleton in Swift
import Foundation
class Animal: NSObject {
static let sharedAnimal = Animal()
}
let cat = Animal.sharedAnimal
let dog = Animal.sharedAnimal
@minikin
minikin / LICENSE
Created April 7, 2016 16:19 — forked from chriseidhof/LICENSE
A tiny networking library
Copyright 2015 Chris Eidhof
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@minikin
minikin / struct_vs_inheritance.swift
Created April 10, 2016 20:05 — forked from AliSoftware/struct_vs_inheritance.swift
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
@minikin
minikin / xcode-build-bump.sh
Created September 7, 2016 09:46 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
a:~$ realm-object-server --configuration /etc/realm/configuration.yml
module.js:583
return process.dlopen(module, path._makeLong(filename));
^
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:583:18)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
@minikin
minikin / commands
Created September 29, 2016 07:33
realm testing
:~$ node -v
v4.4.2
:~$ npm -v
2.15.0
:~$ nano /var/log/realm-sync.log
empty file
:~$ curl http://localhost:9080
@minikin
minikin / .bash_profile
Created October 27, 2016 09:09 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management