This file contains hidden or 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
| <?php | |
| $substitution = '5tv0WiPg2YoSNCRzzBUZc7Bozp2WhLmODSMmc8qlTNh8MdUJVyPx9lj3vngJzFn'; | |
| $regexPattern = str_replace('*', $substitution, $customRulePattern); // replace "*" with random substitution, to avoid being preg_quote() escaped | |
| $regexPattern = preg_quote($regexPattern); // escape all regex syntax | |
| $regexPattern = str_replace('/', '\/', $regexPattern); // also escape the "/" character, since we are using that as the preg delimiter | |
| $regexPattern = str_replace($substitution, '.*', $regexPattern); // convert $substitution into the correct regex pattern | |
| $regexPattern = "/$regexPattern/s"; // wrap in / and add the "DOTALL" flag | |
This file contains hidden or 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 foo(closure: Void -> Void) | |
| { | |
| closure() | |
| } | |
| // correct syntax | |
| foo({ | |
| println("Hello") | |
| }) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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]; | |
| } |
OlderNewer