Skip to content

Instantly share code, notes, and snippets.

@cho45
cho45 / yukkuri.txt
Created July 24, 2008 05:23 — forked from motemen/yukkuri.txt
ゆっくりしていってね!!!
   _,,....,,_  _人人人人人人人人人人人人人人人_
-''":::::::::::::`''>  ゆっくりした結果がこれだよ!!! <
ヽ::::::::::::::::::::: ̄^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄
 |::::::;ノ´ ̄\:::::::::::\_,. -‐ァ     __   _____   ______
 |::::ノ   ヽ、ヽr-r'"´  (.__    ,´ _,, '-´ ̄ ̄`-ゝ 、_ イ、
_,.!イ_  _,.ヘーァ'二ハ二ヽ、へ,_7   'r ´          ヽ、ン、
::::::rー''7コ-‐'"´    ;  ', `ヽ/`7 ,'==─-      -─==', i
r-'ァ'"´/  /! ハ  ハ  !  iヾ_ノ i イ iゝ、イ人レ/_ルヽイ i |
!イ´ ,' | /__,.!/ V 、!__ハ  ,' ,ゝ レリイi (ヒ_]     ヒ_ン ).| .|、i .||
`!  !/レi' (ヒ_]     ヒ_ン レ'i ノ   !Y!""  ,___,   "" 「 !ノ i |
def explain!
puts 'Want to embed this Gist?'
puts 'Use this: <script src="http://gist.github.com/2059.js"></script>'
end
explain!
@elim
elim / strimwidth.rb
Created July 24, 2008 06:48 — forked from dzfl/strimwidth.rb
strimwidth
class String
def strimwidth(width)
self.split(//)[0...width].join
end
end
#see also http://www.ruby-lang.org/ja/man/html/Array.html#self.5bstart.2e.2eend.5d
@motemen
motemen / gist:2074
Created July 24, 2008 07:41
Wizardry #1
+-+-+-+-+-+-+-----+-+ +-+-----------+-+-+
| |.| |.| |. . .|.'.|.'. .'. .'. .|.|.|
+---+'+-+'+-+ +-+ | |'+'+---+ +'+'|
|. .'. . . .'. . .|. .|.|.|.|. .|. .|. .|
|'+-+'+ +---+ | | +-+-+--'----+ +
|.| |.|.| |. . .|. .|.| |.'. .'. .'. .|
+-+-+-+ +---+-+-+'| | | | | +---+---+---+
|. . .|.|. . .| |.|.|.|.| |.| |. .|. .|
| |'| | | +-+ | | | | +-+--'+ |
|. . .'.'. . .| |.| |.|.| |.| |.'. .'. .|
/////////////////////////////////////////
// Sample for Embedding C++ into R //
/////////////////////////////////////////
//
// I keep forgetting how to do this so here's an example.
// If you're willing to use R's most primitive FFI interface,
// things are incredibly simple and easy to get going.
// -Brendan O'Connor (brenocon@gmail.com)
//
// Compile with, e.g. on mac:
   _,,....,,_  _人人人人人人人人人人人人人人人_
-''":::::::::::::`''>   ゆっくりしていってね!!!   <
ヽ::::::::::::::::::::: ̄^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ ̄
 |::::::;ノ´ ̄\:::::::::::\_,. -‐ァ     __   _____   ______
 |::::ノ   ヽ、ヽr-r'"´  (.__    ,´ _,, '-´ ̄ ̄`-ゝ 、_ イ、
_,.!イ_  _,.ヘーァ'二ハ二ヽ、へ,_7   'r ´          ヽ、ン、
::::::rー''7コ-‐'"´    ;  ', `ヽ/`7 ,'==─-      -─==', i
r-'ァ'"´/  /! ハ  ハ  !  iヾ_ノ i イ iゝ、イ人レ/_ルヽイ i |
!イ´ ,' | /__,.!/ V 、!__ハ  ,' ,ゝ レリイi (ヒ_]     ヒ_ン ).| .|、i .||
`!  !/レi' (ヒ_]     ヒ_ン レ'i ノ   !Y!""  ,___,   "" 「 !ノ i |
class Admin::JobsController < ApplicationController
layout 'admin'
moderation_fu :model => Job
before_filter :admin_required
def index
@jobs = Job.paginate(:page => params[:page])
end
def show
class Admin::JobsController < ApplicationController
layout 'admin'
moderation_fu :model => Job
before_filter :admin_required
def index
@jobs = Job.paginate(:page => params[:page])
end
def show
@mudge
mudge / deploy.rb
Created July 24, 2008 09:08
Using acts_as_solr with Monit and Capistrano
before :deploy, "solr:stop"
after :deploy, "solr:start"
namespace :solr do
task :stop, :roles => :app do
run "#{sudo} monit stop solr"
end
task :start, :roles => :app do
run "#{sudo} monit start solr"
get '/:post_id' do
last_modification_of_post = Blog::Post[ params[:post_id], {:only => ['id', 'updated_on']} ]
last_modified( last_modification_of_post.updated_on ) if last_modification_of_post
@post = Blog::Post[ params[:post_id] ]
throw :halt, [404, erb(not_found) ] unless @post
erb :post
end