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
| s = "james" | |
| subs = (1..s.size).inject([ ]) { |a, l| a.push(*s.split("").each_cons(l)) } | |
| p subs |
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 -w | |
| require "enumerator" | |
| require "pstore" | |
| prefs = PStore.new( | |
| File.expand_path("~/Library/Preferences/com.macromates.textmate.add_whit") | |
| ) | |
| scope = ENV["TM_PROJECT_DIRECTORY"] || ENV["TM_FILEPATH"] || :global | |
| used = prefs.transaction(true) { prefs[scope] || 0 } |
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 TNT | |
| class Timer | |
| def initialize | |
| @time_left = 42 | |
| end | |
| def time_left | |
| @time_left -= 1 | |
| end | |
| 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
| (defun jeg2s-duplicate-line-or-region () | |
| "Duplicate the current region, or line, and leave it selected." | |
| (interactive) | |
| (unless (region-active-p) | |
| (unless (bolp) | |
| (beginning-of-line)) | |
| (set-mark-command nil) | |
| (next-line)) | |
| (kill-region (region-beginning) (region-end)) | |
| (yank) |
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
| (defun jeg2s-yank-and-select () | |
| "This is a test command for how to create a selection." | |
| (interactive) | |
| (kill-new "selected") | |
| (yank) | |
| ;; what can I replace to following with to activate the selection | |
| (exchange-point-and-mark)) | |
| (global-set-key (kbd "C-c y") 'jeg2s-yank-and-select) |
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
| (defun jeg2s-yank-and-select () | |
| "This is a test command for how to create a selection." | |
| (interactive) | |
| (kill-new "selected") | |
| (yank) | |
| ;; the following works, but I would like to be able to do it without a macro | |
| (kmacro-exec-ring-item (quote ("" 0 "%d")) nil)) | |
| (global-set-key (kbd "C-c y") 'jeg2s-yank-and-select) |
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
| ;; Vim's o and O | |
| (defun jeg2s-newline-below (skip-eol) | |
| "Insert a new line below the current line and indent it." | |
| (interactive "P") | |
| (unless (or (eolp) skip-eol) | |
| (end-of-line)) | |
| (newline-and-indent)) | |
| (global-set-key (kbd "C-c o") 'jeg2s-newline-below) | |
| (defun jeg2s-newline-above () | |
| "Insert a new line above the current line and indent it." |
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
| Building native extensions. This could take a while... | |
| ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError) | |
| ERROR: Failed to build gem native extension. | |
| /Users/james/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb | |
| creating Makefile | |
| CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -Os -pipe -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion -Wshorten-64-to-32 -Wglobal-constructors -pedantic' /usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -mdynamic-no-pic -std=gnu99 -dead_strip -framework CoreServices -o '/Users/james/.rvm/gems/ruby-1.9.2-p136@aep/gems/rb-fsevent-0.4.3.1/bin/fsevent_watch' fsevent/fsevent_watch.c | |
| fseve |
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
| require "rest_client" | |
| require "twitter" | |
| URL = "http://www.oge.com/residential-customers/products-and-services/" + | |
| "Positive-Energy-Smart-Grid/Pages/PriceSignal.aspx" | |
| DATE_RE = Time.now.strftime("%A,\\s+%B\\s+%d,\\s+%Y") | |
| unless ARGV.size == 4 | |
| abort "USAGE: #{$PROGRAM_NAME} CONSUMER_KEY CONSUMER_SECRET " + | |
| "OAUTH_TOKEN OAUTH_TOKEN_SECRET" |
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
| fizz = [nil, nil, "Fizz"].cycle | |
| buzz = [nil, nil, nil, nil, "Buzz"].cycle | |
| numbers = 1..100 | |
| numbers.zip(fizz, buzz) do |n, f, b| | |
| fizzbuzz = [f, b].join | |
| puts(fizzbuzz.empty? ? n : fizzbuzz) | |
| end |