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
# Array#sample | |
# I recently moved a project from ruby 1.9.1 to ruby 1.8.6, which doesn't have | |
# Array#sample. I couldn't find it online quickly, so I wrote one. | |
class Array | |
def sample(sample_size=1, acc=[]) | |
sample_size = self.size if acc.empty? && sample_size > self.size | |
return acc if sample_size==0 | |
index_to_sample = (rand * self.size).floor | |
if acc.include?(self[index_to_sample]) |
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
find -iname "*.html" -exec sh -cC ' | |
sed 's/search/replace/' "$1" > "$1".new | |
' {} {} \; |
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
alias g='gvim --remote-silent' | |
alias fri='ri' | |
alias lh='ls --color=always -lasth | less -R' | |
alias be='bundle exec' | |
alias gr='grep -r --color' | |
alias rm='gvfs-trash' |
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
<!-- app/views/items/_items.html.erb --> | |
<ul> | |
<% items.each do |item| %> | |
<li><%= item.name %></li> | |
<% end %> | |
</ul> | |
<%= ajax_will_paginate items, :update => 'my_items_list' %> |
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
#!/home/danielpcox/.rvm/rubies/ruby-1.9.2-p180/bin/ruby | |
require 'active_record' | |
require './ticket' | |
require './extra' | |
require './show_info' | |
require 'gruff' | |
conn_params = { |
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
<!-- defining a tag --> | |
<def tag="messages"> | |
<br /><br /> | |
<ul> | |
<li param="msg1">Message 1</li> | |
<li param="msg2">Message 2</li> | |
<li param="msg3">Message 3</li> | |
</ul> | |
</def> |
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
Testing, testing, 1, 2, 3... |
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
Testing again |
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
1. e4 c6 | |
2. Bc4 d5 | |
3. Bd3 e5 | |
4. Nf3 Bg4 | |
5. Nc3 Nd7 | |
6. exd5 Bb4 | |
7. Qe2 c5 | |
8. Nb5 h5 | |
9. a3 h4 | |
10. axb4 f6 |
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
#!/usr/bin/env ruby | |
# | |
require "dbus" | |
session_bus = DBus::SessionBus.instance | |
# Get the Pidgin Service | |
pidgin_dbus = session_bus.service("im.pidgin.purple.PurpleService") | |
# Get the object from this service |
OlderNewer