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 stringToDraw = self.storage.createAttributedStringWithByteRange(self.line.range) | |
let typesetter: CTTypesetterRef = CTTypesetterCreateWithAttributedString(stringToDraw) | |
Result: | |
error: cannot convert the expression's type 'CTTypesetter!' to type 'CFAttributedString!' | |
let typesetter: CTTypesetterRef = CTTypesetterCreateWithAttributedString(stringToDraw) | |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
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/ruby | |
require 'io/console' | |
for arg in ARGV | |
# expand the full path | |
file_path = File.expand_path(arg) | |
# if file doesn't exist, create it |
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/swift | |
import Cocoa | |
// remove $0 from args | |
var args = Process.arguments | |
args.removeAtIndex(0) | |
// process input files | |
for arg in args { |
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 updateKeys() | |
{ | |
CATransaction.begin() | |
CATransaction.setDisableActions(true); | |
var x: CGFloat = 0 | |
var y: CGFloat = 0 | |
var rowHeight = ceil(self.inputView.frame.size.height / 5) | |
var colWidth = ceil(self.inputView.frame.size.width / 10) | |
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/swift | |
import Foundation | |
print("Content-type: text/html\n\n") | |
// load all data files | |
let dataDir = "/Users/abhi/www/data.json-files" |
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
Option 1: | |
let urlRegex = "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))" | |
Option 2: | |
let urlRegex = """ | |
(?xi) | |
\b |
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
// as many inserts as possible before 30 second timeout hits | |
// 226,465 inserts | |
// auto_increment int(11) | |
while (1) { | |
$uuidstr = gen_uuid(); | |
$uuidbin = DB::escape(pack("h*", str_replace('-', '', $uuidstr))); | |
DB::query("insert into test values ()"); | |
} |
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 "COTarget.h" | |
@implementation COTarget | |
+ (instancetype)targetWithAction:(MOJavaScriptObject *)action | |
{ | |
return [[[self class] alloc] initWithAction:action]; | |
} |
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
/* example usage in Cocoa Script: | |
// create a window | |
var window = [[NSWindow alloc] init] | |
// create an OK button | |
var okButton = [[NSButton alloc] initWithFrame:NSMakeRect(10, 10, 100, 100)] | |
[okButton setTitle:"Continue"] | |
[okButton sizeToFit] | |
[okButton setKeyEquivalent:"\r"] |
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
{ | |
number = ( | |
{ | |
MenuLabel = "="; | |
NumberOfArguments = 1; | |
Clause = "= '${}'"; | |
}, | |
{ | |
MenuLabel = "\U2260"; | |
NumberOfArguments = 1; |