This is code used to control the playback speed of a video playing in Quicktime Player. Upload arduino_read_potentiometer.cpp on your Arduino and run processing_control_video.pde in Processing. See video demo at http://www.youtube.com/watch?v=UfDRINiV4Kg
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
#!/usr/bin/env ruby -wKU | |
require 'date' | |
# strptime %z parses all of the following in Ruby | |
iso_8601_timezones = %[ | |
Z | |
UTC | |
PST |
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
#!/usr/bin/env ruby -KU -rubygems | |
require 'sinatra' | |
get '/:time' do | |
sleep params[:time].to_i | |
"Just slept for #{sleep_time} seconds" | |
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
class Rut(id: String, checksumDigit: String) { | |
def checksum: String = { | |
val digits = id.map(_.toString.toInt) | |
val digitsWithMultipliers = digits.zip( | |
Rut.ChecksumMultipliers.drop(Rut.ChecksumMultipliers.size - digits.size) | |
) | |
val productSum = digitsWithMultipliers.foldLeft(0)( | |
(acc, multipliers) => acc + multipliers._1 * multipliers._2 | |
) |
If had a Ruby linter or Ruby checkstyle program, I would want to configure it to detect the following things:
- Duplicate methods in the same class, module (this produces a warning at runtime if warnings are enabled)
- Parens in methods with no arguments
- Missing parens in methods with arguments (or check that there aren't parens, if you're into that)
- Method indentation is consistent
- Consistent block spacing (
.map{|ea| ea}
vs..map {|ea| ea}
vs..map { |ea| ea }
, etc.) private
,protected
are consistently indented (or outdented)do...end
blocks must be used beyond a certain line length- No semi-colons (possible exceptions for one-line exception classes)
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($){ | |
if (typeof $ === 'undefined') { | |
alert('jQuery is required'); | |
return; | |
} | |
var highlightClass = 'scraper-helper-highlight'; | |
$('#scraper-helper-rule').remove(); | |
var style = '<style id="scraper-helper-rule">.' + highlightClass + ' { background-color: #fcc; }</script>'; | |
$(style).appendTo('head'); |
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
alias branches='for k in `git branch|sed s/^..//`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t"$k";done|sort' |
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
#!/usr/bin/env ruby -KU | |
space_shuttle = <<EOS | |
_ | |
,' '. | |
/ \\ | |
^ | _ | ^ | |
| || / \\ || | | |
| |||.-.||| | | |
| ||| ||| | |
On Sep 22, 2008, at 1:01 AM, Ashkan Soltani wrote:
just saw this go by...
http://sfbay.craigslist.org/eby/bik/850231294.html
On Mon, Sep 22, 2008 at 5:11 PM, Ryan Greenberg wrote:
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
# How to read a file in Ruby | |
file_name = "example.txt" | |
# It's simple. | |
# Open the file in read mode ("r"), read it, and close it. | |
f = File.open(file_name, "r") | |
f.read | |
f.close | |
# Though "r" is the default mode, so you can remove that. |