Skip to content

Instantly share code, notes, and snippets.

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)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@abhibeckert
abhibeckert / gist:6503790a8735979751ff
Last active August 29, 2015 14:08
open/create file in ruby
#!/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
@abhibeckert
abhibeckert / gist:711645229cba2bd9224f
Last active August 29, 2015 14:08
open/create file in swift
#!/usr/bin/swift
import Cocoa
// remove $0 from args
var args = Process.arguments
args.removeAtIndex(0)
// process input files
for arg in args {
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)
#!/usr/bin/swift
import Foundation
print("Content-type: text/html\n\n")
// load all data files
let dataDir = "/Users/abhi/www/data.json-files"
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
// 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 ()");
}
#import "COTarget.h"
@implementation COTarget
+ (instancetype)targetWithAction:(MOJavaScriptObject *)action
{
return [[[self class] alloc] initWithAction:action];
}
/* 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"]
@abhibeckert
abhibeckert / gist:b28dc08e58ef17901efd
Last active March 11, 2016 04:31
Sequel Pro Content Filters
{
number = (
{
MenuLabel = "=";
NumberOfArguments = 1;
Clause = "= '${}'";
},
{
MenuLabel = "\U2260";
NumberOfArguments = 1;