Skip to content

Instantly share code, notes, and snippets.

@tka
tka / gist:6064129
Last active December 20, 2015 03:29
rails dump db schema to html table
ActiveRecord::Base.connection.tables.map{|table|
x=ActiveRecord::Base.connection.select('show full columns from '+table);
x.columns.slice!(7);
x.rows.each{|r| r.slice!(7)};
"<h1>#{table}</h1>"+'<table class="table table-bordered table-striped"><tr><th>'+x.columns.join('</th><th>')+"</th><th></th></tr>\n" + x.rows.map{|y| '<tr><td>'+y.join('</td><td>')+"</td><td></td></tr>\n"}.join('')+"</table>\n"}.join('</hr>')
* 升級
* bootstrap-sass 2.3.1.1
* zurb-foundation 4.1.5
* sass-3.2.8
* support livereload protocol version 7
* compass 0.13.alpha.4
* chunyk_png 1.2.8
* 修正
* ubuntu 13.04 下 System tray 顯示問題
@tka
tka / view_helpers.rb
Created April 11, 2013 09:15
fire.app 相對路徑版 stylesheet_link_tag, javascript_include_tag
module ViewHelpers
def rel_stylesheet_link_tag(*f)
styles=stylesheet_link_tag *f
script_path = self.parser.script_filename.gsub(Compass.configuration.project_path, '')
child_folder= File.dirname( script_path.gsub(/\/[^\/]+/, '/..')[1..-1] )
styles.gsub 'href="', "href=\"#{child_folder}"
end
def rel_javascript_include_tag(*f)
styles=javascript_include_tag *f
require 'open3'
class JadeHandler
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /\/$/
env["PATH_INFO"] += "index.jade"
資料使用限制
政府電子採購網安全保護聲明 http://web.pcc.gov.tw/pis/main/pis/client/pssa/security.do
非經行政院公共工程委員會或各權利人之同意,使用者不得以任何形式利用政府電子採購網上之內容,使其存在於任何出版物、網站、檢索系統或相類似之場所。
政府電子採購著作權聲明 http://web.pcc.gov.tw/pis/main/pis/client/pssa/right.do
1.行政院公共工程委員會網站上刊載之所有內容,除著作權法規定不得為著作權之標的(如法律、命令、公務員撰擬之講稿、新聞稿等--請參考著作權法第9條規定)外,其他包括文字敘述、攝影、圖片、錄音、影像及其他資訊,均受著作權法保護。
2.上述不得為著作權標的者,任何人均得自由利用,歡迎各界廣為利用。
@tka
tka / _layout.erb
Last active December 11, 2015 02:59
<%
@page_body=yield
special_comment_regexp = /<!--ruby:(.*)-->/m
if @page_body.match(special_comment_regexp)
eval($1)
@page_body.gsub!(special_comment_regexp, '')
elsif @page_body.match(/<h1.*?>(.*)<\/h1>/)
@page_title = $1
@tka
tka / JRuby 1.7.1 result
Created December 5, 2012 05:13
JRuby 1.7.1 vs MRI 1.9.3-p327 write binary string to file when Encoding.default_internal is UTF-8
When Encoding.default_internal is nil
==============================
Wirte remote_binary_data to test_file
Encoding.default_external:#<Encoding:UTF-8>
Encoding.default_internal:nil
data encoding: #<Encoding:ASCII-8BIT>
file external encoding: nil
file internal encoding: nil
file size: 13686
export XIM=hime
export XIM_PROGRAM=/usr/bin/hime
export XIM_ARGS=
export XMODIFIERS="@im=hime"
export GTK_IM_MODULE=hime
export QT_IM_MODULE=hime
export QT4_IM_MODULE=hime
x220t[~/test]$ rvm use jruby --ignore-gemsets
Using /home/tka/.rvm/gems/jruby-1.6.7.2
x220t[~/test]$ gem list
*** LOCAL GEMS ***
x220t[~/test]$ wget http://rubygems.org/downloads/rawr-1.4.5.gem 100%[============================================================================================================>] 3,542,528 764KB/s in 8.8s
2012-08-25 01:00:35 (395 KB/s) - ‘rawr-1.4.5.gem’ saved [3542528/3542528]
x220t[~/test]$ gem install rawr-1.4.5.gem rvm:jruby-1.6.7.2
@tka
tka / create_gems_folder.sh
Created July 19, 2012 07:47
建立 custom gems folder
#!/bin/bash
gem install sass --prerelease -i $1 --no-rdoc --no-ri
gem install compass --prerelease -i $1 --no-rdoc --no-ri
gem install rack-test fssm execjs coffee-script rack tilt activesupport tzinfo i18n rake haml slim kramdown -i $1 --no-rdoc --no-ri
curl -o tka-serve.zip --location-trusted https://github.com/tka/serve/zipball/master
unzip tka-serve.zip
rm tka-serve.zip
mv tka-serve-* $1/gems/serve-1.5.1
cp $1/gems/serve-1.5.1/serve.gemspec $1/specifications
curl -o tka-rack-coffee.zip --location-trusted https://github.com/tka/rack-coffee/zipball/master