Skip to content

Instantly share code, notes, and snippets.

View peco8's full-sized avatar
💭
Where's my Boy Bawang?

Toshiki Inami peco8

💭
Where's my Boy Bawang?
  • Rakuten, Inc
  • Tokyo
View GitHub Profile
@sunaot
sunaot / hello_ruby.md
Last active April 4, 2017 11:04
さらっと読んで Ruby がわかった気になれるプログラミング言語 Ruby のかんたんな紹介
@tallgreentree
tallgreentree / das_download.rb
Created March 21, 2012 15:37
Download all Destroy All Software Screencasts
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require 'mechanize'
# gem 'mechanize-progressbar'
email = ARGV[0] or raise('Please provide the email address for your account')
password = ARGV[1] or raise('Please provide the password for your account')
path = ARGV[2] || './'
@francisco-rojas
francisco-rojas / ruby_splat.rb
Last active January 12, 2019 04:23
Ruby Splat Operator
# https://gist.github.com/francisco-rojas/db0fb04ed6aa509acc18
# https://dev.firmafon.dk/blog/drat-ruby-has-a-double-splat/
# http://blog.simplificator.com/2015/03/20/ruby-and-the-double-splat-operator/
# http://chriszetter.com/blog/2012/11/02/keyword-arguments-in-ruby-2-dot-0/
# ------------------------------------------------------Method Definition-----------------------------------------------------
puts "\n---Method Definition---\n"
def say(what, *people)
people.each { |person| puts "#{person}: #{what}" }
end
say "Hello!", "Alice", "Bob", "Carl"
@ewoodh2o
ewoodh2o / a_description.md
Created October 3, 2012 19:50
Bash-Style Curly Brace Expansion

Bash-Style Curly Brace Expansion

Expands the curly-brace notation as supported by Bash.

expand "ab{c,d}e"
  => [ "abce", "abde" ]

expand "ab{c,d}e{1,2}"
 => [ "abce1", "abce2", "abde1", "abde2" ]
@icy
icy / expand.rb.md
Last active March 6, 2019 14:20
Bash-liked Curly Brace Expansion in ruby

System-call method

Use Bash to expand the brace. If you don't like this, you may look at more professional way at https://gist.github.com/ewoodh2o/3829405 This method invokes a system call to ask Bash to expand.

FIXME: This is not secure!!!

class String
@kyohei-shimada
kyohei-shimada / ruby_memo.md
Last active February 27, 2020 06:27
RubyのちょっとしたTips

RubyのちょとしたTips

ちょっと便利なことだったり,今さら知った恥ずかしいことなど

ローカル変数のスコープ

小文字または`_'で始まる識別子はローカル変数また はメソッド呼び出しです。ローカル変数スコープ(クラス、モジュー ル、メソッド定義の本体)における小文字で始まる識別子への最初 の代入はそのスコープに属するローカル変数の宣言になります。宣 言されていない識別子の参照は引数の無いメソッド呼び出しとみな されます。 ローカル変数のスコープは、((宣言した位置から))その変数が宣 言されたブロック、メソッド定義、またはクラス/モジュール定義 の終りまでです。寿命もそのブロックの終りまで(トップレベルの ローカル変数はプログラムの終了まで)ですが、例外としてブロッ クが手続きオブジェクト化された場合は、そのオブジェクトが消滅 するまで存在します。同じスコープを参照する手続きオブジェクト 間ではローカル変数は共有されます。

@ozzozz
ozzozz / about_cf-ssh.md
Last active February 28, 2020 10:50
cf ssh コマンドについて

cf ssh コマンドについて

この記事は、Cloud Foundry Advent Calendar 2017の10日目の記事です。

アプリケーションコンテナの中にSSHしたいだと?

Cloud Foundryがユーザとして想定している人たちって、どういう人達なのでしょう。

それはやっぱり、このAdvent Calender1日目で @jacopen さんがKubernetesとの使い分けの中で言及していたように、あくまでも アプリケーション開発をしており、それの運用を楽にしたいということでプラットフォームを選ぶ ような人なのです。 そういう人って、以下のような考え方が強いんじゃないですかね。

@mikeda
mikeda / analyze_access_log.rb
Last active June 30, 2021 02:44
アクセスログ集計スクリプトのとりあえず版
#!/usr/local/bin/ruby
# アクセスログを1時間ごとに集計。アクセスタイプごとのアクセス数をTSV形式で出力する
# usage : analyze_access_log.rb <YYYYMMDD> <access_log>...
require 'json'
require 'time'
require 'pp'
ANALYZE_DATE = ARGV.shift # YYYYMMDD

sysctlで設定可能な項目について調査した内容。