Skip to content

Instantly share code, notes, and snippets.

View lingceng's full-sized avatar

Kexian Zhong lingceng

View GitHub Profile
@lingceng
lingceng / vimrc (not maintained)
Last active June 6, 2017 07:43
vimrc with vundle, rails ctrp plugin and basic indent setting
" out of date
" see https://github.com/lingceng/lingceng-config
"
" lingceng vimrc
"
set nocompatible " be iMproved, required
filetype off " required
" vundle plugins ----------- {{{
" set the runtime path to include Vundle and initialize
@lingceng
lingceng / vimrc_win
Created December 4, 2013 02:44
vimrc on windows, ctrlp.vim, indent
" ctrlp.vim
"
" cd D:/Vim/vimfiles
" git clone https://github.com/kien/ctrlp.vim.git bundle/ctrlp.vim
"
" :helptags D:\Vim\vimfiles\bundle\ctrlp.vim\doc
"
set runtimepath^=D:\Vim\vimfiles\bundle\ctrlp.vim
@lingceng
lingceng / grep-operator.vim
Last active August 29, 2015 14:04
grep operator vim plugin, grep text recursily
" out of date
" see https://github.com/lingceng/lingceng-config
"
" Grep Operator Vim Plugin
"
" Description:
" Grep text recursively in current file and open the quickfix window.
"
" Install:
" Put this plugin here ~/.vim/plugin/grep-operator.vim
@lingceng
lingceng / gitconfig
Last active August 29, 2015 14:04
lingceng gitconfig
# out of date
# see https://github.com/lingceng/lingceng-config
[user]
name = zhongkx
email = zhongkx@reocar.com
[push]
default = simple
[alias]
st = status
ci = commit
@lingceng
lingceng / README.md
Last active August 29, 2015 14:06 — forked from eric1234/README.md

A module to automatically translate snake_case method calls into CamelCase method calls. For example:

class MyObject
  include Snakeable
  
  def FooBar
    "baz"
  end

end

@lingceng
lingceng / form_submit.js
Last active October 31, 2020 00:19
JavaScript request like a form submit
// http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
// form_submit('/contact/', {name: 'Johnny Bravo'});
function form_submit(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
@lingceng
lingceng / index.html.slim
Last active December 26, 2015 08:15
Export csv or excel by re-using existing HTML view
table
thead
tr
th = sort_link(@q, :number)
th = sort_link(@q, :production_status)
th = sort_link(@q, :current_step)
th = order_name(:production_type)
th = order_name(:type)
th = order_name(:brand)
th = order_name(:color)
@lingceng
lingceng / index.html.erb
Last active December 22, 2017 10:45
Custom ransacker predicates to query date range
<%= search_form_for @q, url: production_status_changes_path, class: 'form-inline' do |f| %>
<%= f.label 'Create At' %>
<%= f.search_field :created_at_end_of_day_lteq, class: 'form-control input-sm', 'datepicker' => true %>
<% end %>
@lingceng
lingceng / rails_callbacks.rb
Created January 22, 2016 09:07
Test rails callbacks order
# https://github.com/rails/rails/pull/15106
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
@lingceng
lingceng / SyntaxInclude.vim
Last active February 1, 2016 10:16
Vim slime embeded coffee sass syntax. Put at ~/.vim/after/syntax/slim/SyntaxInclude.vim
" Require SyntaxRange vim plugin
call SyntaxRange#IncludeEx('matchgroup=NonText keepend start="^sass" end="^\S"he=e-1,re=e-1 containedin=ALL', 'sass')
call SyntaxRange#IncludeEx('matchgroup=NonText keepend start="^coffee" end="^\S"he=e-1,re=e-1 containedin=ALL', 'coffee')