Skip to content

Instantly share code, notes, and snippets.

View juno's full-sized avatar
💰
writing code (almost) every weekday

Junya Ogura juno

💰
writing code (almost) every weekday
View GitHub Profile
@cdmwebs
cdmwebs / friendly_urls.markdown
Created September 11, 2011 15:50 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@denisahearn
denisahearn / test_http_digest_rails3_patch.rb
Created October 12, 2011 19:31
Testing HTTP Digest Authentication in Rails 3
# Adds support for http digest authentication in Rails 3
# Inspired by: http://lightyearsoftware.com/2009/04/testing-http-digest-authentication-in-rails/
# Place this code in test/test_helper.rb
# In your test, call authenticate_with_http_digest prior to calling get, post, put or delete
# Tested with Rails 3.0.7
class ActionController::TestCase
require 'digest/md5'
def authenticate_with_http_digest(user = API_USERNAME, password = API_PASSWORD, realm = API_REALM)
@matope
matope / NoSQLデータモデリング技法.markdown
Created April 16, 2012 03:35
NoSQLデータモデリング技法

#NoSQLデータモデリング技法

原文:NoSQL Data Modeling Techniques « Highly Scalable Blog

I translated this article for study. contact matope[dot]ono[gmail] if any problem.

NoSQLデータベースはスケーラビリティ、パフォーマンス、一貫性といった様々な非機能要件から比較される。NoSQLのこの側面は実践と理論の両面からよく研究されている。ある種の非機能特性はNoSQLを利用する主な動機であり、NoSQLシステムによく適用されるCAP定理がそうであるように分散システムの基本的原則だからだ。一方で、NoSQLデータモデリングはあまり研究されておらず、リレーショナルデータベースに見られるようなシステマティックな理論に欠けている。本稿で、私はデータモデリングの視点からのNoSQLシステムファミリーの短い比較といくつかの共通するモデリングテクニックの要約を解説したい。

本稿をレビューして文法を清書してくれたDaniel Kirkdorfferに感謝したいと思う

@momo-lab
momo-lab / pocket.rb
Created May 31, 2012 14:35
Pocket(旧 ReadItLater)にツイート内のURLを追加するearthquake.gem用プラグイン
# -*- coding: utf-8 -*-
# earthquake.gem plugin
# add url to Pocket(http://getpocket.com)
require 'uri'
require 'open-uri'
Earthquake.init do
cfg = config[:pocket] || {}
command :pocket do |m|
pocket_uri = URI.parse('https://readitlaterlist.com/v2/add')
@joerichsen
joerichsen / parallel_assets_compiler.gemspec
Created June 5, 2012 06:23
Microgem for compiling assets in parallel
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'parallel_assets_compiler'
s.version = '0.2.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jørgen Orehøj Erichsen'
s.email = 'joe@erichsen.net'
s.summary = 'Compile assets in parallel'
s.description = 'Compile assets in parallel to speed up deployment'
@dschneider
dschneider / gist:2941985
Created June 16, 2012 17:15
RSpec - Stub Remote IP Request
ActionDispatch::Request.any_instance.stub(:remote_ip).and_return("192.168.0.1")
@Gab-km
Gab-km / productivity_vs_guilt_and_self-loathing.rst
Created August 3, 2012 06:34
生産性 vs. 罪悪感と自己嫌悪

生産性 vs. 罪悪感と自己嫌悪

原文

http://www.hanselman.com/blog/ProductivityVsGuiltAndSelfLoathing.aspx

著者

Scott Hanselman

罪の意識が迫ってきます。あなた以外の皆が物事を片づけているように見えます。あなたは自分をベッドから引きずり出し、会社に行き、Eメールをチェックし始め、削除しだし、そしてあっという間にお昼です。昼食を、もしかしたら自分のデスクで摂り、幾つかのひどい会議に出席し、もう3時です。そこから 本 当 に 働き始め、いい感じになってきたなと感じてきたところで5時か6時になっています。もう帰り始める時間です。今日は本当に何もできなかったと感じるので、残業して―今日みたいに―取り返そうとするでしょう。

共有データベース (Shared Database) から Heroku Postgres への移行について


Migrating from a Shared Database to Heroku Postgres を @jugyo が勝手に翻訳したものです(2012-08-04)。


    1. データベースの準備
    1. データの移行
@voluntas
voluntas / gist:73efe2f36ac1513c02a8
Created August 5, 2012 16:13
レビューのススメ?

レビューのススメ?

typo 死ぬほど多いので突っ込みまってます

バージョン

0.2.3

作者

@voluntas

考え方はコロコロ変わるタイプなのですが、最近はレビューが実はとても大事でとにもかくにもレビューなのでは?と思い始めてきています。

@troy
troy / oneline_detailed_logging.rb
Created August 10, 2012 02:13
One-line detailed logging for Rails 3 (ActiveSupport::Notifications) and later
# Outputs this at warn log level:
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
#
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP