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
| def buildCoder(shift): | |
| def gen(a, z): return zip(map(chr, range(a, z)), map(chr, range(a + shift, z - shift) + range(a + 25 - shift, z))) | |
| return dict( gen(ord('a'), ord('z')) + gen(ord('A'), ord('Z')) ) | |
| print buildCoder(3) |
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
| fun_closure = function(n) { | |
| for (i = 0; i < n; i++) | |
| (function(){ | |
| for (j = 0; j < n; j++) | |
| for (k = 0; k < n; k++) { | |
| if (j * k > n) return; | |
| j + k; | |
| } | |
| })() |
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/env ruby | |
| # Question: | |
| # If user_1 followed user_2, we will get an array item like: | |
| # [id_1, id_2] | |
| # Here is a sample user relationship list: | |
| # [ [2, 3], [1, 4], [3, 2], [1, 3], [4, 2], [7, 2], [5, 3], [4, 1] ] | |
| # If two items have two same IDs, print one of the items out. | |
| # So if we print out [3, 2] and [1, 4], that should be a right result. |
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/env python | |
| # Question: | |
| # If user_1 followed user_2, we will get an array item like: | |
| # [id_1, id_2] | |
| # Here is a sample user relationship list: | |
| # [ [2, 3], [1, 4], [3, 2], [1, 3], [4, 2], [7, 2], [5, 3], [4, 1] ] | |
| # If two items have two same IDs, print one of the them out. | |
| # So if we print out [3, 2] and [1, 4], that should be a right result. |
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
| nobone = require 'nobone' | |
| {kit, renderer} = nobone { renderer: {} } | |
| kit.watch_dir { | |
| dir: '.' | |
| pattern: ['*/', '*.styl'] | |
| handler: (type, path) -> | |
| kit.log path | |
| renderer.render(path, '.css', {}, false) |
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
| ### | |
| openssl genrsa -out key.pem | |
| openssl req -new -key key.pem -out csr.pem | |
| openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem | |
| rm csr.pem | |
| ### | |
| { kit } = require 'nobone' |
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
| dataUri = 'data:audio/mpeg3;base64,SUQzAwAAAAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4xjAAAAAAlwAAAAAtASxAAAAAAAARQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4xjAMQAAAlwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/4xjAbAAAAlwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' |
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
| Promise_Yaku = require '../src/yaku' | |
| Promise_Bird = require 'bluebird' | |
| Promise_Yaku.enableLongStackTrace() | |
| Promise_Bird.longStackTraces() | |
| test = (Promise) -> | |
| Promise.resolve() | |
| .then -> | |
| a() |
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 (opts, data, method, headers) { | |
| if (_.isString(opts)) | |
| opts = { url: opts }; | |
| opts = _.defaults(opts, { | |
| method: method || 'GET', | |
| data: data || null, | |
| header: headers || {}, | |
| statusFilter: function (status) { | |
| return status < 300; |
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
| var kit = require('nokit'); | |
| var _ = kit._; | |
| var Promise = kit.Promise; | |
| /** | |
| * A simple openstack client. | |
| * @param {Object} opts | |
| * ```js | |
| * { |