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
| #!/bin/bash | |
| sudo apt-get update -y | |
| # Install the rbenv and Ruby dependencies with apt-get: | |
| sudo apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs |
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
| # coding: utf-8 | |
| def func(n, m, N): | |
| def state(cnt, acc): | |
| if N == cnt: | |
| return acc | |
| else: | |
| return state(cnt + 1, (1 - 1/n - 1/m) * acc + 1/m) | |
| return state(0, 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
| #! /bin/sh | |
| exec ruby -S -x "$0" "$@" | |
| #! ruby | |
| def main | |
| if $*.length == 0 | |
| ymd = [Time.now.year, Time.now.month].map &:to_i | |
| mon = MonthView.new ymd[0], ymd[1] | |
| print sprintf("%-6d",Time.now.year) | |
| puts mon.view |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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 wepkey2ascii(key) | |
| key.to_s.scan(/../).map { |s| s.hex.chr }.join | |
| end | |
| #=> "01fc91ab8b648" |
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
| 'use strict'; | |
| const Iconv = require('iconv').Iconv; | |
| const Chardet = require('jschardet'); | |
| /** | |
| * convertEncode: 生バイト列のエンコードを変換する | |
| * @param {Buffer} buf バイト列 | |
| * @param {String} decoding 期待する変換後の文字エンコード | |
| * @return {Promise(String)} 変換対象文字列を包んだPromise | |
| */ |
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
| 'use strict'; | |
| const HTTP = require('http'); | |
| /* | |
| @param url: String ゆーあーるえる | |
| @param conv: String -> String 型の関数 | |
| */ | |
| function getURL(url, conv) { | |
| /* | |
| resolve, rejectはそれぞれ 処理成功時、失敗時に(利用ユーザが)呼びだす関数 |
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
| extension Int { | |
| func fizzBuzz() -> String { | |
| switch (self % 3, self % 5) { | |
| case (0, 0): return "FizzBuzz" | |
| case (0, _): return "Fizz" | |
| case (_, 0): return "Buzz" | |
| case _: return String(self) | |
| } | |
| } |
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 char(str: String) -> ParseFunction { | |
| var letters = Set<Character>(str.characters) | |
| return { (target: String, position: Int) -> ParseResult in | |
| let range = stringRange(target, start: position, advance: 1) | |
| let char: Character = target.substringWithRange(range).characters.first! | |
| if letters.contains(char) { | |
| return (true, [String(char)], position) | |
| } else { |
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 Checker | |
| attr_accessor :reguler_array | |
| def initialize | |
| string = gets.chomp | |
| ary = string.split("") | |
| @reguler_array = make_good_ary(ary) | |
| end | |
| def make_good_ary(array) | |
| _ary = array |