Skip to content

Instantly share code, notes, and snippets.

View kyanny's full-sized avatar

Kensuke Nagae kyanny

View GitHub Profile
@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
@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')
@rcrowley
rcrowley / gist:447393
Created June 21, 2010 19:55
Resque Nagios plugin
We couldn’t find that file to show.
@kzys
kzys / escfilter
Created September 9, 2010 10:35 — forked from kyanny/escfilter
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw(HelpMessage VersionMessage);
use Term::ANSIColor qw(colored);
our $VERSION = '0.01';
$VERSION = eval $VERSION;
my %color_map = (
@priithaamer
priithaamer / config.ru
Created October 21, 2010 09:30
Gollum rackup script
#!/usr/bin/ruby
require 'rubygems'
require 'gollum/frontend/app'
system("which git") or raise "Looks like I can't find the git CLI in your path.\nYour path is: #{ENV['PATH']}"
gollum_path = '/Users/priit/Documents/Fraktal/Wiki'
disable :run
@keithamus
keithamus / Nano Git Commit Syntax highlighting
Created December 10, 2010 13:58
Add this to your ~/.nanorc and when running "git commit" (if your editor is nano) you'll have syntax highlighting in your commit message. Includes support for "git commit -v" too!
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|deleted).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"
@yoggy
yoggy / ldr2pin.rb
Created January 12, 2011 06:19
Livedoor ReaderのPinをまとめてpinboard.inにブックマークするスクリプト
#!/usr/bin/ruby
#
# ldr2pin.rb - Livedoor ReaderのPinをまとめてpinboard.inにブックマークするスクリプト
#
$KCODE='utf8'
require 'rubygems'
require 'net/netrc'
require 'mechanize'
@tyuki39
tyuki39 / waitjob.groovysh
Created February 26, 2011 14:16
Jenkinsで、指定ジョブがビルド中でない場合は即実行、指定ジョブがビルド中の場合は待って実行する例
//
// 1. depjobnameで指定したジョブよりも自分自身が先にキューに入った場合は、自分自身のビルドを即実行する。
// 2. depjobnameで指定したジョブよりも自分自身が後にキューに入った場合は、depjobnameの終了を待つ。
// 2-1. ポーリング方式で終了を待つ
// 2-2. 最大リトライ回数は retrycount で指定
// 2-3. リトライ間隔は sleeptime で指定(単位はミリ秒)
// 3. depjobnameで指定したジョブが存在しなかった場合は、ビルドを失敗させるためにあえて例外が発生する
// ようにしています。
// 4. 設定手順
// 4-1. Groovy Pluginをインストールする
@juliocesar
juliocesar / best-localStorage-polyfill-evar.js
Created April 18, 2011 23:19
This is the best localStorage polyfill in the world
// I mean, seriously, localStorage is supported even by your mum. How about instead of
// casing the feature out, you give users in-memory (stale) storage instead?
// If they close your application, they deserve to lose data anyway.
// if (!('localStorage' in window)) {
if (!Modernizr.localstorage) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
@tobert
tobert / config.ru
Created May 18, 2011 02:01
Gollum rackup for Unicorn
$: << 'lib'
require 'rubygems'
require 'gollum'
require 'gollum/frontend/app'
use Rack::ShowExceptions
Precious::App.set(:gollum_path, Dir.pwd)
Precious::App.set(:wiki_options, {})