http://reefpoints.dockyard.com/2013/11/05/design-patterns-command-pattern.html
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
| -# 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
| 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
| class IceCube::Occurrence | |
| def self.evolve(occurrence) | |
| occurrence.to_time | |
| end | |
| 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
| #ApplicationController | |
| after_action :set_pages | |
| def set_pages | |
| max_size = 5 | |
| session[:pages] = [] unless session[:pages] | |
| session[:pages].shift while(session[:pages].size >= max_size) | |
| session[:pages] << request.original_url | |
| 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
| # ApplicationController | |
| around_filter :global_request_logging | |
| def global_request_logging | |
| logger.tagged('USERAGENT'){ logger.info "#{request.headers['HTTP_USER_AGENT']}" } | |
| begin | |
| yield | |
| ensure | |
| logger.info "response_status: #{response.status}" | |
| 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
| # ActiveLdapExtensions | |
| # | |
| # @author Christian Nennemann | |
| # | |
| module ActiveLdapExtensions | |
| extend ActiveSupport::Concern | |
| module Time | |
| # Convert the time to the FILETIME format, a 64-bit value representing the | |
| # number of 100-nanosecond intervals since January 1, 1601 (UTC). |
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 | |
| # Requirements: imagemagick, ghostscript, pdftk | |
| ############################################# | |
| # create pdf for each png | |
| ############################################# | |
| for image in *.png; do | |
| filename="${image%%.*}".pdf |
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
| # Support for http digest auth | |
| # Discovered here: http://johan.bingodisk.com/public/code/net_digest_auth.rb | |
| require 'digest/md5' | |
| require 'net/http' | |
| module Net | |
| module HTTPHeader | |
| @@nonce_count = -1 | |
| CNONCE = Digest::MD5.new("%x" % (Time.now.to_i + rand(65535))).hexdigest |