Skip to content

Instantly share code, notes, and snippets.

View rockkhuya's full-sized avatar

Luu Tuan Anh rockkhuya

View GitHub Profile
@rockkhuya
rockkhuya / git_flow_lta.zsh-theme
Created January 22, 2014 07:20
OH-MY-ZSH git-flow theme
# Created by Luu Tuan Anh, OKWave Inc.
function git_prompt_info_short() {
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
ref="${ref#refs/heads/}"
if echo "$ref" | egrep "feature" > /dev/null; then
ref="f/${ref#feature/}"
fi
if echo "$ref" | egrep "release" > /dev/null; then
@rockkhuya
rockkhuya / Write HTML in Javascript
Last active August 29, 2015 13:56
Use push to write HTML code in Javascript
var new_element = [];
new_element.push(
'<ul class="inline nested-fields" shp-role="dynamic_field_need_things" id="', num, '">',
'<li>',
'<input class="input-mini" id="', num, '" name="need_things" shp-role="dynamic_field_need_things" type="text" />',
'</li>\n',
'<li><a id="', num, '" shp-role="delete_field_need_things">×</a> </li>',
'</ul>'
);
@rockkhuya
rockkhuya / js
Created February 5, 2014 01:47
Use Jquery to add dynamic field and edit value before submit
$(function(){
$("a[shp-action=add_field_need_things]").click( function(){
var num = $("ul[shp-role=dynamic_field_need_things]").length + 1;
var new_element = [];
new_element.push(
'<ul class="inline nested-fields" shp-role="dynamic_field_need_things" id="', num, '">',
'<li>',
'<input class="input-mini" id="', num, '" name="need_things" shp-role="dynamic_field_need_things" type="text" />',
'</li>\n',
'<li><a id="', num, '" shp-role="delete_field_need_things">×</a> </li>',
@rockkhuya
rockkhuya / controller.rb
Last active August 29, 2015 13:56
use cocoon to create nested
accepts_nested_attributes_for :tour_irregular_schedules,
allow_destroy: true, reject_if: proc { |a| a["start_date"].blank? && a['all_season_flg'].blank? }
Javascript
function update_versions_div(project_id) {
jQuery.ajax({
url: "/update_versions",
type: "GET",
data: {"project_id" : project_id},
dataType: "html"
success: function(data) {
jQuery("#versionsDiv").html(data);