Skip to content

Instantly share code, notes, and snippets.

View mingliangfeng's full-sized avatar

Andrew Feng mingliangfeng

  • Melbourne
View GitHub Profile
@mingliangfeng
mingliangfeng / bs-wizard.html
Last active December 21, 2015 03:09
Demo code snippets
<div class="row bs-wizard">
<div class="col-lg-3">
<ol class="bs-wizard-sidebar">
<li class="bs-wizard-todo bs-wizard-active"><a href="javascript:void(0)">Step1</a></li>
<li class="bs-wizard-todo"><a href="javascript:void(0)">Step2</a></li>
<li class="bs-wizard-todo"><a href="javascript:void(0)">Step3</a></li>
</ol>
</div>
<div class="col-lg-9">
@mingliangfeng
mingliangfeng / source.rb
Last active December 17, 2015 22:39
show source files of a class or method
find_source = lambda do |clazz, include_super=false|
files = clazz.methods(include_super).inject([]) {|c, m| c << clazz.method(m).source_location.first if clazz.method(m) and clazz.method(m).source_location; c }
files.uniq
end
puts find_source.call(Rails)
puts self.method(:get).source_location
@mingliangfeng
mingliangfeng / migration.sh
Last active December 15, 2015 21:29
RefineryCMS
# how to add a migration to an extension
1. Under app folder:
> rails g migration add_a_field_to_a_table ...
2. Copy this migration from app db/migrate folder to extension db/migrate folder and rename the file:
> mv db/migrate/1222_add...rb <extension's db/migrate>
> # then rename the migration file to #_add...
3. still on app folder, run the following command to copy the migrate from extension to app:
> rake refinery_<extension name>:install:migrations
# render empty page from controller
render :nothing => true, :status => 200, :content_type => 'text/html'
@mingliangfeng
mingliangfeng / JSPLocationInterceptor.java
Last active December 11, 2015 06:49
Interceptor to append JSP location to outputted html by struts2, for development or debug only.
package com.fml.java.struts2.interceptor;
import java.io.CharArrayWriter;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import org.apache.commons.lang.StringUtils;