Skip to content

Instantly share code, notes, and snippets.

@tetu1225
tetu1225 / app.rb
Created June 27, 2011 09:25
Amazon AWS Code
require 'rubygems'
require 'sinatra'
require 'amazon/aws/search'
require 'haml'
require 'sass'
include Amazon::AWS
include Amazon::AWS::Search
get '/' do
!!! 5
%html
%head
%title Amazon aaws
:css
div{
border: 1px dashed;
color: #444444;
width: 450px;
margin: 10px;
!!! 5
#content
%strong= @var
%p
これはPタグ
%div{:id => "aaa", :class => "bbb"}
IDとかクラスも指定できるよ
@tetu1225
tetu1225 / .htaccess
Created July 10, 2011 08:13
LimonadeのHello World(Url rewiteあり)
<IfModule mod_rewrite.c>
Options +FollowSymlinks
Options +Indexes
RewriteEngine on
# if your app is in a subfolder
# RewriteBase /my_app/
# test string is a valid files
RewriteCond %{SCRIPT_FILENAME} !-f
@tetu1225
tetu1225 / gist:1086001
Created July 16, 2011 04:23
RubyでHashを構造体にしてアクセサのように取得する
def Struct(hash)
# ハッシュのキーを構造体のメンバーとして設定
st = Struct.new(*hash.keys)
# 構造体に新しい要素を突っ込む
st.new(
*hash.values.map do |s|
# ハッシュの場合は再帰
Hash === s ? Struct(s) : s
end
@tetu1225
tetu1225 / app.rb
Created July 18, 2011 06:00
Sinatraで画像ファイルをアップロードして表示する
require 'sinatra'
require 'haml'
# 静的コンテンツ参照のためのパス設定
set :public, File.dirname(__FILE__) + '/public'
# アップロード
get '/' do
haml :index
@tetu1225
tetu1225 / hello.php
Created August 21, 2011 08:09
Fuelを試す。
<h1>Hello!</h1>
<p>Hey <?php echo $name ?>, how's it going?</p>
@tetu1225
tetu1225 / gogakuru_bookmarklet
Created September 11, 2011 07:06
ゴガクルフレーズ検索ブックマークレット
javascript:var%20d=document;var%20tx=d.selection?d.selection.createRange().text:d.getSelection();var%20subw=window.open('http://gogakuru.com/english/phrase/keyword/'+tx+'.html').document;
@tetu1225
tetu1225 / rails_cycle.html.erb
Created October 16, 2011 06:02
Rails Cycle ヘルパー
<table>
<tr>
<th>名前</th>
<th>性別</th>
<th>血液型</th>
</tr>
<% @people.each do |person| %>
<tr style="background-color:<%= cycle('#FFffFF', '#FFff99') %>
<td><%= person.name %></td>
<td><%= person.sex %></td>
@tetu1225
tetu1225 / gist:1396950
Created November 27, 2011 04:13
楽天APIレスポンス例(XML)
<response>
<header:header xmlns:header="http://api.rakuten.co.jp/rws/rest/Header">
<args>
<arg key="User-Agent" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2">
true
</arg>
<arg key="developerId" value="1a17906c3ca67237529280545156b4e9">
true
</arg>
<arg key="apiVersion" value="30">