Skip to content

Instantly share code, notes, and snippets.

View mingliangfeng's full-sized avatar

Andrew Feng mingliangfeng

  • Melbourne
View GitHub Profile
@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;
# render empty page from controller
render :nothing => true, :status => 200, :content_type => 'text/html'
@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
@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 / 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">
<form novalidate="novalidate" id="signin-form" method="get" action="" accept-charset="UTF-8">
<fieldset>
<legend>Please fill in your details</legend>
<div class="form-group">
<label for="client_email">Email</label>
<div class="input-group">
<span class="input-group-addon"><i class="icon-envelope"></i></span>
<input id="client_email" name="client[email]" class="required email form-control" placeholder="Your Email" type="text">
</div>
</div>
<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)">Your Account Details</a></li>
<li class="bs-wizard-todo"><a href="javascript:void(0)">Your Website Details</a></li>
<li class="bs-wizard-todo"><a href="javascript:void(0)">Review and Sign up</a></li>
</ol>
</div>
<div class="col-lg-9">
<form method="get" id="signup_form" class="new_client" action="" accept-charset="UTF-8">
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
for (node in Jenkins.instance.nodes) {
@mingliangfeng
mingliangfeng / ubuntu-maven-3
Last active August 29, 2015 14:28 — forked from stephanetimmermans/ubuntu-maven-3
Install Maven3 on Unbuntu 14.04
#sudo apt-get remove maven2
sudo add-apt-repository "deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main"
sudo apt-get update
sudo apt-get install maven3
#If you encounter this:
#The program 'mvn' can be found in the following packages:
# * maven
# * maven2
@mingliangfeng
mingliangfeng / README.md
Created March 2, 2016 02:43 — forked from boopathi/README.md
Creating a Swift-ReactNative project

Settings

  1. Create a project in XCode with the default settings
    • iOS > Application > Single View Application
    • Language: Swift
  2. Under project General settings, add ReactKit to Linked Framework and Libraries
    • + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
  3. Now ReactKit would have been imported. Link it by choosing it from the list.
    • + > lib.ReactKit.a
  4. Under project Build Settings,