Skip to content

Instantly share code, notes, and snippets.

View linjunpop's full-sized avatar
🐚
Sleeping

Jun Lin linjunpop

🐚
Sleeping
View GitHub Profile
@linjunpop
linjunpop / rails2-stl-cache_classes-issue.md
Created September 26, 2012 07:39
Rails 2 STI changes behavior depending on environment
@linjunpop
linjunpop / _document_fields.html.slim
Created October 24, 2012 09:07
Nested form and twitter bootstrap css.
- if f.object.file?
= f.input :file, label: false, wrapper: :append do
= f.input_field :file, as: :string, readonly: true
span
= link_to 'Download', f.object.file_url, class: 'btn'
= f.link_to_remove 'Remove document', class: 'btn btn-danger'
- else
= f.input :file, label: false, wrapper: :append do
= f.input_field :file, as: :file
span
@linjunpop
linjunpop / README.md
Created October 29, 2012 06:34
Git basic

Git basic

Commit

Pricinple

  • One commit one small feature or bug fix
  • Include unit test in one commit
  • Exclude non-associated files
  • Don't commit un-finished or wrong code
@linjunpop
linjunpop / nodes.xquery
Created November 14, 2012 03:29
XQuery taste
(: return a deep copy of the element and all sub elements :)
declare function local:copy($elements as element()+) as element()+ {
for $element in $elements
return element {node-name($element)}
{$element/@*,
for $child in $element/node()
return
if ($child instance of element())
then local:copy($child)
else $child
@linjunpop
linjunpop / README.md
Created November 14, 2012 06:29
Programmers are procrastinators

From http://en.wikibooks.org/wiki/Computer_programming/Functional_programming

Programmers are procrastinators. Get in, get some coffee, check the mailbox, read the RSS feeds, read the news, check out latest articles on technical websites, browse through political discussions on the designated sections of the programming forums. Rinse and repeat to make sure nothing is missed. Go to lunch. Come back, stare at the IDE for a few minutes. Check the mailbox. Get some coffee. Before you know it, the day is over.

@linjunpop
linjunpop / format-date.xquery
Created November 15, 2012 07:27
Convert 'Wednesday, October 10, 2012' to '20121010'
declare function local:format-date($date as xs:string)
{
format-date(
local:string-to-date(substring-after($date, ", ")),
"[Y][M][D]"
)
};
declare function local:string-to-date($date as xs:string) as xs:date
{
@linjunpop
linjunpop / example.rb
Created December 3, 2012 06:23
An example of generating IIF file with Riif.
Riif::IIF.new.trns do
row do
trnsid 123
trnstype 'INVOICE'
date '8/31/1988'
accnt 'Accounts Receivable'
name 'Customer'
amount 20
docnum 1
clear 'N'
@linjunpop
linjunpop / gist:4281577
Created December 14, 2012 00:57
Payment method comparison
http://www.redweek.com/resources/payment-method-comparison
@linjunpop
linjunpop / rubyconf-china-2012.markdown
Last active October 14, 2015 00:48
RubyConf China 2012 resources.
@linjunpop
linjunpop / Capybara-Rspec-Rails-assets-pipeline.md
Last active August 14, 2021 05:42
Capybara, Rspec, Rails assets pipeline