Skip to content

Instantly share code, notes, and snippets.

// 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);
}
# I wrote this script because I had a bunch of heroku apps on my account that I didn't know what
# local apps they matched. Just search the heroku app name and this script will find the local
# app for you.
#
# Feel free to use and alter this script as much as you want.
unless ARGV[0]
fail 'You pust provide repo name to search for'
end
namespace :figaro do
desc "SCP transfer figaro configuration to the shared folder"
task :setup do
on roles(:app) do
upload! "config/application.yml", "#{shared_path}/config/application.yml", via: :scp
end
end
desc "Symlink application.yml to the release path"
task :symlink do