- Step 1, create Service in Automator:
- Step 2, set Service for files:
- Step 3: insert bash script (see below)
- Step 4, save:
| function is32Bit(c) { | |
| return c.codePointAt(0) > 0xFFFF; | |
| } | |
| console.log(is32Bit("𠮷")); // true | |
| console.log(is32Bit("a")); // false |
| var Benchmark = require('benchmark'); | |
| var request = require('request'); | |
| var suite = new Benchmark.Suite; | |
| // add tests | |
| suite.add('Calling cow api', { | |
| defer: true, | |
| fn: function(deferred) { | |
| request({ |
| <link rel="import" href="../polymer/polymer.html"> | |
| <polymer-element name="my-element"> | |
| <template> | |
| <style> | |
| :host { | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; |
| <?php | |
| /** | |
| * Compares two strings. | |
| * | |
| * This method implements a constant-time algorithm to compare strings. | |
| * Regardless of the used implementation, it will leak length information. | |
| * | |
| * @param string $knownString The string of known length to compare against | |
| * @param string $userInput The string that the user can control | |
| * |
| <?php | |
| /** | |
| * Create a web friendly URL slug from a string. | |
| * | |
| * Although supported, transliteration is discouraged because | |
| * 1) most web browsers support UTF-8 characters in URLs | |
| * 2) transliteration causes a loss of information | |
| * | |
| * @author Sean Murphy <[email protected]> | |
| * @copyright Copyright 2012 Sean Murphy. All rights reserved. |
| <?php | |
| /** | |
| * @link http://stackoverflow.com/q/10212752/367456 | |
| * @link http://msdn.microsoft.com/en-us/magazine/ee335713.aspx | |
| */ | |
| $file = 'billion-laughs-2.xml'; | |
| $file = 'quadratic-blowup-2.xml'; | |
| printf("Mem: %s (Peak: %s)\n", number_format(memory_get_usage(), 0, '', ' '), number_format(memory_get_peak_usage(), 0, '', ' ')); |
| <?php | |
| function slugify($text) { | |
| // replace non letter or digits by - | |
| $text = preg_replace('~[^\\pL\d]+~u', '-', $text); | |
| // trim | |
| $text = trim($text, '-'); | |
| // transliterate | |
| $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); | |
| // lowercase | |
| $text = strtolower($text); |
| preg_match_all('/^(?:UPDATE|SELECT|INSERT INTO|CREATE).*;$/smU', file_get_contents('dump.sql'), $matches); |