Skip to content

Instantly share code, notes, and snippets.

View yasulab's full-sized avatar
💎
\\ Rubyist! //

Yohei Yasukawa yasulab

💎
\\ Rubyist! //
View GitHub Profile
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@yortz
yortz / post-receive
Created June 26, 2011 00:28 — forked from carlosantoniodasilva/post-receive
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
@keikubo
keikubo / README.md
Created March 20, 2012 01:38
Nginx + Unicorn for Rails on Rackhub

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

@justinko
justinko / Plea.markdown
Created May 30, 2012 19:40
Am I doing it wrong?

Dear Rubyists,

I just lost a contract because of my code in a Rails project.

The specific code in question is related to a "posting a comment" feature. Here are the details:

In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.

The "senior developer", whom is the stake holder's right hand man, said this:

@keikubo
keikubo / README.md
Created June 17, 2012 21:52
チケットの利用 on Rackhub

チケットの利用方法 - Rackhub

キャンペーンや友達からのプレゼント等で受け取ったRackhubチケットの利用方法を説明します。

チケットの概要

  • Rackhubのチケットのコードは、以下のような16文字の文字列(4x4)になっています。
(*
(* CR jfuruse: なんたら *) というのは前職でのコードレビューの書き方で、私の癖になっている。すべて、「私ならば…こうするかな?」が省略されています。
私ならやっつけモードでこう書く、という例です。人様のコードを元にしているので、ほんとにこう書くのかよ?という突っ込みはありかと思います。
元コードも実際のものを簡略化されたものだそうですので、私の提案コードのように書きたいけれども実は書けないんだ!ということもあるでしょう。
OCaml のプログラミングスタイルは決まったものはなくいろいろと流儀があります。その一つと思ってください。
*)
@judofyr
judofyr / fizzbuzz.rb
Created August 1, 2012 21:37 — forked from JEG2/fizzbuzz.rb
Writing FizzBuzz with flip-flops
a=b=c=(1..100).each do |num|
print num, ?\r,
("Fizz" unless (a = !a) .. (a = !a)),
("Buzz" unless (b = !b) ... !((c = !c) .. (c = !c))),
?\n
end
@colrichie
colrichie / parsrc.sh
Last active September 14, 2017 09:00
[MOVED] CSV & JSON & XML file scraping tools
#! /bin/sh
#
# parsrc.sh
# CSV(Excel形式(RFC 4180):ダブルクォーテーションのエスケープは"")から
# 行番号列番号インデックス付き値(line field indexed value)テキストへの正規化
# (例)
# aaa,"b""bb","c
# cc",d d
# "f,f"
# ↓
@jugyo
jugyo / gist:3509080
Created August 29, 2012 09:32
とあるプロジェクトで使ったライブラリたち

とある Rails プロジェクトで使ったライブラリたち

  • carrierwave - ファイルアップロードを処理するやつ
  • carrierwave_backgrounder - アップロードされたフィアルの処理(画像のリサイズ等)をバックグラウンドで処理する
  • delayed_job_active_record - バックグラウンド処理
  • fog - AWS との連携に使う。 carrierwave がこれを使って S3 にファイルを保存してくれたりする
  • haml-rails - haml 使いたいねん
  • twitter-bootstrap-rails - あれ
  • will_paginate - ページネーション
  • bootstrap-will_paginate - twitter-bootstrap 的にいい感じのタグを出力してくれる
@keikubo
keikubo / stripe_webpay_gem.diff
Created September 11, 2012 04:25
Diff between Stripe gem and Webpay gem.
diff --git a/lib/stripe.rb b/lib/stripe.rb
index fb4a6a6..7e77804 100644
--- a/lib/stripe.rb
+++ b/lib/stripe.rb
@@ -46,7 +46,7 @@ require 'stripe/errors/authentication_error'
module Stripe
@@ssl_bundle_path = File.join(File.dirname(__FILE__), 'data/ca-certificates.crt')
@@api_key = nil
- @@api_base = 'https://api.stripe.com/v1'
+ @@api_base = 'https://api.webpay.jp/v1'