This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_select_selected(value){ | |
$("#my_field > option").filter(function() { | |
return $(this).text() == value //the condition | |
}).prop('selected', true); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# prepend example #1 (content_tag) | |
= f.input :date, :input_html => { :class => 'datepicker' }, :wrapper => :prepend do | |
= f.input_field :date | |
= content_tag :span, :class => 'input-group-addon' do | |
= content_tag :span, nil, :class => 'glyphicon glyphicon-search' | |
-# prepend example #2 (haml tag) | |
= f.input :date, :input_html => { :class => 'datepicker' }, :wrapper => :prepend do | |
= f.input_field :date | |
%span.input-group-addon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/a/18684021 | |
# Bootstrap 3 | |
inputs = %w[ | |
CollectionSelectInput | |
DateTimeInput | |
FileInput | |
GroupedCollectionSelectInput | |
NumericInput | |
PasswordInput | |
RangeInput |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_recurring_select_selected(){ | |
$("#transaction_recurrence_rule > option").filter(function() { | |
return $(this).data('custom') == true | |
}).prop('selected', true); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FeedDiscoverer | |
require 'open-uri' | |
# Constructor accepts options | |
# @param [Hash] opts | |
# Available options: | |
# * unique (default: true) - filter duplicate urls | |
def initialize(opts={}) | |
@opts = {:unique => true}.merge!(opts) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Mousetrap example | |
* provides data-keybinding property | |
* | |
* requirements: jQuery, Mousetrap (https://github.com/ccampbell/mousetrap) | |
* | |
* examples: | |
* 1: <input type='text' data-keybinding='ctrl+shift+f'> <!-- ctrl+shift+f will focus this input element --> | |
* 2: <button type='button' data-keybinding='ctrl+shift+b'>save</button> <!-- ctrl+shift+b will click this button --> | |
* 3: <input type='submit' data-keybinding='ctrl+shift+s'> <!-- ctrl+shift+s will click this input element --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SoftDelete | |
extend ActiveSupport::Concern | |
included do | |
define_model_callbacks :soft_delete | |
define_model_callbacks :recover | |
default_scope where(deleted_at: nil) | |
class_eval do | |
class << self | |
alias_method :with_deleted, :unscoped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo aptitude install libxml2 libxslt-dev libxml2-dev libmysqlclient-dev libcurl4-openssl-dev imagemagick libmagickwand-dev libsqlite3-dev libldap2-dev libssl-dev libgsasl7 libsasl2-dev | |
sudo apt-get --no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev | |
sudo aptitude install ttf-mscorefonts-installer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############# | |
# CONFIG | |
redisDB=0 | |
redisClient="/usr/local/bin/redis-cli" | |
redisServer="/usr/local/bin/redis-server" | |
diff(){ | |
awk 'BEGIN{RS=ORS=" "} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
import os | |
import types | |
from subprocess import Popen, PIPE | |
os.system("clear") | |
# show how it works | |
def usage(): |