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 Iterator < Enumerator | |
| def initialize obj, meth, *args | |
| super() do |y| | |
| loop do | |
| y << obj | |
| obj = obj.send(meth, *args) | |
| end | |
| end | |
| 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
| //Accept zoneStr such as '-0400', '-04:00', '0400', '+0400' | |
| //Return such as 4, -4, -4.75, -4.5 | |
| function tranformTimeZone(zoneStr) { | |
| var signSymbol, hours, minutes, zone; | |
| if (/^\+|-/.test(zoneStr)) { | |
| signSymbol = zoneStr[0]; | |
| zoneStr = zoneStr.slice(1); | |
| } else { | |
| signSymbol = '+'; |
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
| tutors = ["***", "***", "***"] | |
| girls = ["***", "***", "***"] | |
| number = "To be defined" | |
| tutors = tutors.shuffle(random: Random.new(number)) | |
| girls = girls.shuffle(random: Random.new(number)) | |
| result = Hash.new { |hash, key| hash[key] = [] } | |
| tutors.cycle(3).each_with_index do |tutor, i| | |
| result[tutor] << (girls[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
| let fs = require('fs') | |
| let parser = require("@babel/parser") | |
| let traverse = require("@babel/traverse") | |
| function collectCalls(filepath) { | |
| let results = [] | |
| let code = fs.readFileSync(filepath).toString() | |
| let ast = parser.parse(code, { | |
| // parse in strict mode and allow module declarations |
OlderNewer