Skip to content

Instantly share code, notes, and snippets.

Yours

<h5>Comments:</h5>
<% @post.comments.each do |comment| %>
  <div class='well span8'>
    <p>
      <em><%= comment.body %></em>
    </p>
 
// Fix sliders for mobile devices
YAHOO.util.Event.onDOMReady(function(){
slider_handles = YAHOO.util.Dom.getElementsByClassName('minthumb');
for(i=0; i<slider_handles.length; i++) {
slider_handles[i].addEventListener("touchstart", touchHandler, true);
slider_handles[i].addEventListener("touchmove", touchHandler, true);
slider_handles[i].addEventListener("touchend", touchHandler, true);
slider_handles[i].addEventListener("touchcancel", touchHandler, true);
BlackJack_Procedural ➤ ruby blackjack.rb
Hello, Welcome to Lucky Larry's BlackJack....feeling lucky?
Player goes first
Press [ENTER]
--------------------------------------------------
--------------------------------------------------
You drew a J of clubs!
--------------------------------------------------
Your score is 10! [ENTER]
<div class="row">
<div class="span0 well text-center">
<% if logged_in? %>
<%= link_to vote_post_path(post, vote: true), method: 'post', remote: :true do %>
<i class="icon-arrow-up"></i>
<% end %>
<% end %>
<br>
<span id="post_<%=post.id%>_votes"><%= post.total_votes %> votes</span>
irb(main):001:0> def doubler(start)
irb(main):002:1> puts start
irb(main):003:1> end
=> nil
irb(main):004:0>
irb(main):005:0* doubler(2)
2
=> nil
irb(main):006:0> doubler(4)
4
@brandoncc
brandoncc / country_and_state_lists.rb
Last active August 29, 2015 14:12
country and state utility actions
# requires geonames_api gem
# config/initializers/geo_names.rb
GeoNamesAPI.username = ENV["GEONAMES_USERNAME"]
GeoNamesAPI.lang = :en
# utility routes
get '/utilities/country_list(.:format)', to: 'utilities#country_list', as: :country_list
get '/utilities/state_list/:country(.:format)', to: 'utilities#state_list', as: :state_list
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#rc()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-repeat'
def balance_to_dollars(balance)
balance = "#{'%.2f' % balance}"
dollars = balance.split('.')[0]
cents = balance.split('.')[1]
dollars = dollars.reverse.gsub(/...(?=.)/,'\&,').reverse
"$#{dollars}.#{cents}"
end
print "What is your current age? "
// choose a random number which is inclusively between min and max
chooseRandomBetween = function(min, max) {
var difference = Math.abs(max - min) + 1;
return Math.floor(Math.random() * difference) + Math.min(min, max);
}
require "net/http"
require "nokogiri"
unless [1, 2].include? ARGV.length
puts "Usage: TERM [max number of results to display]"
exit
end
def max_results
max = ARGV[1].to_i