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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# KEYWORDS=@n,@n1 TWITTER_USERNAME=n TWITTER_PASSWORD=password ruby blockem.rb | |
require 'rubygems' | |
require "uri" | |
require "yajl/http_stream" | |
def twitter_uri(path, stream = false) | |
u = ENV['TWITTER_USERNAME'] | |
p = ENV['TWITTER_PASSWORD'] |
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
/* | |
$ gcc -std=c99 a.c | |
$ ./a.out 10000000 | |
10000000 bits... | |
precmp8: 11ms (1250001) | |
POPCNT: 6ms (1250001) | |
$ ./a.out 100000000 | |
100000000 bits... | |
precmp8: 111ms (12500001) | |
POPCNT: 62ms (12500001) |
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 has_nothing_to_do_with_n(text): | |
if type(text) == unicode: | |
text = text.encode('utf-8') | |
reason = False | |
if len(text) < 5: | |
reason = 'too short' | |
elif text[2:].startswith(('\xc3','.','!','@','_','-','~','\xe9\x9f\xbf')): | |
reason = 'not for n' | |
elif len(text.split('@')) > 5: | |
reason = '#ff' |
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
Index: chrome/browser/global_keyboard_shortcuts_mac.mm | |
=================================================================== | |
--- chrome/browser/global_keyboard_shortcuts_mac.mm (revision 184327) | |
+++ chrome/browser/global_keyboard_shortcuts_mac.mm (working copy) | |
@@ -79,8 +79,10 @@ | |
//--- ----- ----- ------ | |
{true, false, false, false, kVK_LeftArrow, 0, IDC_BACK}, | |
{true, false, false, false, kVK_RightArrow, 0, IDC_FORWARD}, | |
+#if USE_IDIOTIC_SHORTCUT_KEYS | |
{false, false, false, false, kVK_Delete, 0, IDC_BACK}, |
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
int32_t GetSystemUptime() | |
{ | |
int mib[2] = {CTL_KERN, KERN_BOOTTIME}; | |
size_t mib_size = sizeof(mib) / sizeof(int); | |
struct timeval boottime; | |
size_t boottime_size = sizeof(boottime); | |
if (!sysctl(mib, mib_size, &boottime, &boottime_size, NULL, 0)) { | |
time_t now; | |
time(&now); |
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 <Foundation/Foundation.h> | |
@interface NSObject (AssociatedDictionary) | |
+ (NSMutableDictionary*)associatedDictionary; | |
- (NSMutableDictionary*)associatedDictionary; | |
@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
class NumberString { | |
var number = 0 | |
var string: String = "" { | |
didSet { number = string.toInt()! } | |
} | |
init(foo: String) { | |
string = foo // Will NOT cause didSet | |
} |
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
extension Float { | |
func __conversion() -> Double { return Double(self) } | |
} | |
let two = 2.0 | |
let n1 = 1 / 2.0 // Ok | |
let n2 = Float(1) / 2.0 // Ok | |
let n3 = Double(1) / 2.0 // Ok | |
let n4 = CGFloat(1) / 2.0 // Ok | |
let n5 = 1 / two // Ok |
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
// let qrcodeImage = UIImage(message: "Hello, QRCode", size: 200) | |
extension UIImage { | |
// correctionLevel can be L(7%), M(15%), Q(25%), or H(30%) | |
convenience init?(message: String, size: CGFloat, correctionLevel: String = "M") { | |
let filter = CIFilter(name: "CIQRCodeGenerator") | |
filter.setValue(correctionLevel, forKey: "inputCorrectionLevel") | |
filter.setValue(message.dataUsingEncoding(NSUTF8StringEncoding)!, forKey: "inputMessage") | |
var uiImage = UIImage(CIImage: filter.outputImage, scale: 1.0, orientation: UIImageOrientation.Up)! |
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
func keyboardWillShow(notification: NSNotification) { | |
let info = notification.userInfo! | |
let rect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue() | |
let duration = info[UIKeyboardAnimationDurationUserInfoKey] as! Double | |
let curve = notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as! UInt | |
let opts = UIViewAnimationOptions(rawValue: curve << 16) | |
UIView.animateWithDuration(duration, delay: 0, options: opts, animations: { | |
self.bottomConstraint.constant = rect.height | |
self.view.layoutIfNeeded() |
OlderNewer