This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_number_of_lines(path, suffix) | |
count = 0 | |
Dir.chdir(path) do | |
cmd = 'find . -type f -name "*.SUFFIX" -print0 | xargs -0 cat | wc -l' | |
cmd.gsub!('SUFFIX', suffix) | |
result = `#{cmd}` | |
count = result.to_i | |
end | |
return count | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern | |
class Foo <T: Any> : T { | |
func hello() { println("hello") } | |
} | |
class Bar { | |
func world() { println("world") } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIColor { | |
// usage: | |
// myButton.backgroundColor = UIColor.rgb(240, 10, 20) | |
class func rgb(red: Int, _ green: Int, _ blue: Int) -> UIColor { | |
return rgba(red, green, blue, 255) | |
} | |
// usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prompt> sudo touch /etc/crontab | |
Password: *************** | |
prompt> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lldb | |
import re | |
import shlex | |
# This script allows Xcode to selectively ignore Obj-C exceptions | |
# based on any selector on the NSException instance | |
def getRegister(target): | |
if target.triple.startswith('x86_64'): | |
return "rdi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Forbind | |
import ForbindExtensions | |
class RemoteImageView: UIImageView { | |
private(set) var URL: NSURL? | |
private var imagePromise: Promise<Result<UIImage>>? | |
init() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by Paul Slot's awesome PSCustomViewFromXib, https://github.com/PaulSolt/CustomUIView | |
class CustomViewFromXib: UIView { | |
var customView: UIView? | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
let className = String(self.dynamicType) | |
let anyObjectOrNil: AnyObject? = NSBundle.mainBundle().loadNibNamed(className, owner: self, options: nil)?.first | |
guard let anyObject = anyObjectOrNil else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright © 2015 Simon Strandgaard. All rights reserved. | |
// MIT license | |
#include "environment.hpp" | |
#include <unistd.h> | |
#include <iostream> | |
#include <boost/algorithm/string/predicate.hpp> | |
extern char **environ; | |
void Environment::populateWithGlobalEnvironment() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user neoneye staff; | |
worker_processes 1; | |
error_log /Library/Logs/nginx/error.log debug; | |
events { | |
worker_connections 256; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROMPT> hostname | |
abcdef.local | |
PROMPT> ifconfig -a | |
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 | |
options=3<RXCSUM,TXCSUM> | |
inet6 ::1 prefixlen 128 | |
inet 127.0.0.1 netmask 0xff000000 | |
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 |
OlderNewer