Skip to content

Instantly share code, notes, and snippets.

@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@koseki
koseki / sendgmail.rb
Created March 27, 2009 16:59
rubyで日本語のメール送信
# Send Japanese mail using Gmail SMTP server. You need tlsmail.
# $ sudo gem install tlsmail
require "rubygems"
require "tlsmail"
require "nkf"
require "net/smtp"
def sendgmail(from, to, subject, body, user, pass, host = "smtp.gmail.com", port = 587)
body = <<EOT
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
【あ】:あまり調子に乗ってると裏世界でひっそり幕を閉じる
%
【い】:今のがリアルでなくて良かったな、リアルだったらお前はもう死んでるぞ
%
【う】:うるさい、気が散る。一瞬の油断が命取り
%
【え】:FFではナイトだがリアルではモンクタイプだからな
%
【お】:おれの怒りが有頂天になった
%
@sunaot
sunaot / gist:613106
Last active April 28, 2020 00:30
バグを生まないプログラミングのために

話しをしたいポイントは3つ。

  • 条件分岐を避けましょう
  • 一時変数の使い方に注意しましょう
  • 状態の使い方に気を使いましょう

これを徹底することで、バグの入り込む余地を最小限に保つプログラミングをしましょう。

条件分岐を避けましょう

@zoras
zoras / fixes.md
Created November 7, 2011 06:34 — forked from thbar/fixes.md
Getting rid of nokogiri segfaults

This readme is a mixture of everything I read on SO+nokogiri wiki, which ultimately worked out for me.

Here are the steps which worked for me to get rid of segfaults with Nokogiri 1.4.4, on both Lion and Snow Leopard, with Ruby 1.8.7 (patchlevel 334 and +).

First diagnose which version of libxml2 you're using:

bundle exec nokogiri -v

If you have 2.7.3 listed somewhere, you're in bad waters (known to segfault). Install this:

@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@Gab-km
Gab-km / github-flow.ja.md
Last active April 25, 2024 04:01 — forked from juno/github-flow.ja.md
GitHub Flow (Japanese translation)
@onteria
onteria / kaomoji.txt
Created October 19, 2012 05:08
顔文字.txt
a(;`・ω・)o━ヽ_。_・_゚_・_フ))
?(っ´。ω゜`c)
☝(〃`l _ l´)☝
☝( ◠‿◠ )☝
༼(*꒪ั❥꒪ั*༽༽
(✿꒪ั◡꒪ั✿)
(੭ु ˃̶͈̀ x ˂̶͈́)੭ु⁾⁾
:(ヽ'ω`):
+。:.゚٩(๑>◡<๑)۶:.。+゚
(★l ω l)
@matope
matope / Introducing Gizzard a framework for creating distributed datastores.markdown
Created November 15, 2012 16:45
分散データベースを作るためのフレームワーク Gizzardのご紹介[和訳]