Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / .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
!!! 5
#content
%strong= @var
%p
これはPタグ
%div{:id => "aaa", :class => "bbb"}
IDとかクラスも指定できるよ
!!! 5
%html
%head
%title Amazon aaws
:css
div{
border: 1px dashed;
color: #444444;
width: 450px;
margin: 10px;
@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