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
require 'rubygame' | |
include Rubygame | |
include Rubygame::EventTriggers | |
# Factory method to create KeyReleaseTriggers easily. | |
def released( key ) | |
return KeyReleaseTrigger.new( key ) | |
end | |
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
#!/bin/env ruby | |
# A sample script to demonstrate Ruby-SDL-FFI (as of June 21, 2009). | |
# NOTE: Ruby-SDL-FFI API is still in flux. | |
require 'ruby-sdl-ffi' | |
path = ARGV[0] | |
if path.nil? |
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
#!/bin/env ruby | |
# One way of making an object start and stop moving gradually: | |
# make user input affect acceleration, not velocity. | |
require "rubygame" | |
# Include these modules so we can type "Surface" instead of |
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
#!/bin/sh | |
# | |
# A very simple shell script to "cherry pick" a range of commits in Git. | |
# I might add more features later, like validation. | |
# | |
# Credit goes to Alex Riesen: | |
# http://www.nabble.com/cherry-pick---since---td10105685.html | |
# | |
# This script is released to the public domain. You can do whatever you want with it. |
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
;; | |
;; Emacs smart tabs functionality | |
;; Intelligently indent with tabs, align with spaces! | |
;; | |
;; Note: Indenting only uses tabs when indent-tabs-mode is non-nil, | |
;; otherwise it uses spaces as usual. | |
;; | |
;; To use: save as smarttabs.el in your .emacs.d directory, and add | |
;; "(require 'smarttabs)" to your .emacs file. | |
;; |
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
#!/bin/bash | |
# | |
# A simple command to untar any tarball. | |
# | |
# For times when you don't care whether it was compressed | |
# with bzip2 or gzip, you just want to untar it already! | |
# | |
# Usage: untar [-v|--verbose] file | |
# |
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
Return a hash of directory contents, recursively. | |
Given a directory structure like this: | |
a/ | |
|-- b.txt | |
`-- c/ | |
|-- d.txt | |
`-- e/ |
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
%r<this is a valid regexp>e.to_s | |
# That's right. | |
%r(this one is valid, but...() | |
it actually closes right here:)i.inspect | |
# Tricky. | |
%r[this is valid too]x.clone | |
# Correct. |
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/ruby | |
# Plot random pixels. | |
require 'rubygame' | |
include Rubygame | |
Width = 640 | |
Height = 400 |
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
window.onload = -> | |
paper = Raphael 0, 0, 320, 200 | |
circle = paper.circle 50, 40, 10 | |
circle.attr "fill", "#f00" | |
circle.node.onclick = -> alert "Stop poking me!" | |
window.onkeypress = (ev) -> | |
ev = window.event || ev | |
switch ev.keyCode | |
when 37 then circle.attr( "cx", circle.attr("cx") - 5 ) | |
when 38 then circle.attr( "cy", circle.attr("cy") - 5 ) |
OlderNewer