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
| >>> $dt1 = new DateTime() | |
| => <DateTime #000000007766f6860000000009e51d7d> { | |
| date: "2015-02-09 12:13:50", | |
| timezone_type: 3, | |
| timezone: "Asia\/Tokyo" | |
| } | |
| >>> $dt2 = new DateTime('@'.$dt1->getTimestamp()) | |
| => <DateTime #000000007766f6810000000009e51d7d> { | |
| date: "2015-02-09 03:13:50", | |
| timezone_type: 1, |
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
| (function() { | |
| var elsWithId = document.querySelectorAll("*[id]"); | |
| var IGNORE_TAGS = { | |
| SCRIPT: true, | |
| IFRAME: true | |
| }; | |
| for (var i = 0, len = elsWithId.length; i < len; ++i) { | |
| var el = elsWithId[i]; |
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
| {spawn} = require "child_process" | |
| runCommand = (cmd, args, opts) -> new Promise (resolve, reject) -> | |
| p = spawn cmd, args, opts | |
| buf = [] | |
| p.stdout.on "data", (data) -> buf.push data | |
| p.stderr.on "data", (data) -> buf.push data | |
| p.on "error", reject | |
| p.on "close", (code) -> | |
| result = buf.join("").trim() |
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
| {spawnSync} = require "child_process" | |
| do -> | |
| ENV = [ | |
| "PATH" | |
| "GOPATH" | |
| ] | |
| result = spawnSync process.env.SHELL, ["-lc", "printenv"] | |
| envLines = result.stdout.toString().split("\n") |
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
| class Foo | |
| def foo(segv?: nil, suruyo: nil) | |
| end | |
| end |
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
| require 'active_support' | |
| require 'active_support/core_ext' | |
| module Tenuki | |
| class Validator | |
| def initialize(field, value) | |
| @field = field | |
| @value = value | |
| end |
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
| _ = require "lodash" | |
| class BrainWrapper | |
| constructor: (@brain, @key, @initialData, @migrator = _.identity) -> | |
| get: (path = null, defaultValue = null) -> | |
| data = @_get() | |
| if path then _.get(data, path, defaultValue) else data | |
| set: (path, value) -> |
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
| class StackedGraphTransformer | |
| # @param [IO] io | |
| def initialize(io) | |
| @io = io | |
| end | |
| def gets_tsv | |
| (line = @io.gets) ? line.chomp.split("\t") : nil | |
| end |
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
| ruby -rjson -e 'puts "<resources>"; JSON.parse(File.read(ARGV[0]))["icons"].each {|icon| puts " <string name=\"#{ARGV[1]}_#{icon["properties"]["name"]}\">&#x#{icon["properties"]["code"].to_s(16)};</string>"}; puts "</resources>"' path/to/icomoon/selection.json prefix > path/to/values/fonts.xml |
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 | |
| $num_iterates = $argv[1]; | |
| echo "iterates: $num_iterates\n"; | |
| foreach (range(1, $num_iterates) as $i) { | |
| sleep($i); | |
| echo "$i\n"; | |
| echo "ping\n"; |