This file contains 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
# will_paginate(collection, renderer: PaginationCustomLinkRenderer) | |
class PaginationCustomLinkRenderer < WillPaginate::ActionView::LinkRenderer | |
def prepare(collection, options, template) | |
options[:params] ||= {} | |
options[:params]['_'] = nil | |
options[:page_links] ||= false | |
options[:class] ||= "pagination" | |
super(collection, options, template) | |
end |
<fieldset class="rating">
<legend>Please rate:</legend>
<input type="radio" id="star5" name="rating" value="5" /><label for="star5" title="Rocks!">5 stars</label>
<input type="radio" id="star4" name="rating" value="4" /><label for="star4" title="Pretty good">4 stars</label>
<input type="radio" id="star3" name="rating" value="3" /><label for="star3" title="Meh">3 stars</label>
<input type="radio" id="star2" name="rating" value="2" /><label for="star2" title="Kinda bad">2 stars</label>
<input type="radio" id="star1" name="rating" value="1" /><label for="star1" title="Sucks big time">1 star</label>
</fieldset>
after initializing typeahead:
var el = $('#your-input-element')
el.typeahead({...})
find the element and mess it with
var tt = el.data("ttTypeahead")
-
Paste them into a
images.csv
-
open a new file called
download.rb
require 'open-uri'
require 'csv'
require 'pry'
links_to_images = CSV.read('images.csv').flatten
queryHook
is a hook function that provides the query, and the search callback. You can do your own debouncing or special logic here.
default debounce example:
var timeout = 500;
var queryHook = _.debounce(function(query, search){
search(query)
},timeout);
This file contains 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
- data ||= {} | |
%table{:border => "0", :cellpadding => "5", :cellspacing => "5"} | |
- if data.is_a?(Hash) | |
%tbody | |
- data.each do |name, value| | |
%tr | |
%td | |
%strong= name | |
%td= value |
new_result = old_result = new_ms = old_ms = nil
old_ms = Benchmark.ms do
old_result = Conversation.slow_method_thing(person_id)
end
# 5% of requests
if rand(20) == 1
# [safely](https://github.com/ankane/safely) is shorthand for begin/rescue
safely do