UPDATE a fork of this gist has been used as a starting point for a community-maintained "awesome" list: machine-learning-with-ruby Please look here for the most up-to-date info!
- liblinear-ruby: Ruby interface to LIBLINEAR using SWIG
#!/usr/bin/env ruby | |
#------------------------------------------------------------------------------- | |
# Toggle Camelcase _ | |
#------------------------------------------------------------------------------- | |
# Jason Sims <jason@symmetriq.com> | |
#------------------------------------------------------------------------------- | |
# | |
# Toggles between camelcase and underscores | |
# e.g. doTheThing <-> do_the_thing |
#!/usr/bin/env ruby | |
#------------------------------------------------------------------------------- | |
# Toggle Quotes | |
#------------------------------------------------------------------------------- | |
# Jason Sims <jason@symmetriq.com> | |
#------------------------------------------------------------------------------- | |
# | |
# Toggle between single and double quotes. Within the selected text, every | |
# double quote will become a single quote and vice-versa. |
#!/usr/bin/env ruby | |
#------------------------------------------------------------------------------- | |
# Toggle Parentheses | |
#------------------------------------------------------------------------------- | |
# Jason Sims <jason@symmetriq.com> | |
#------------------------------------------------------------------------------- | |
# | |
# For languages with optional parentheses, such as Ruby and CoffeeScript. | |
# |
extension String { | |
var composedCount : Int { | |
var count = 0 | |
enumerateSubstringsInRange(startIndex..<endIndex, options: .ByComposedCharacterSequences) {_ in count++} | |
return count | |
} | |
} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
-- PostgreSQL 9.2 beta (for the new JSON datatype) | |
-- You can actually use an earlier version and a TEXT type too | |
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
-- Inspired by | |
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html | |
-- http://ssql-pgaustin.herokuapp.com/#1 | |
-- JSON Types need to be mapped into corresponding PG types | |
-- |
tell application "BBEdit" to set theFile to file of document 1 | |
tell application "Finder" to set theFolder to (container of file theFile) as alias | |
set theUnixPath to POSIX path of theFolder | |
set output to return & "cd '" & theUnixPath & "'; pwd" | |
tell application "BBEdit" | |
set uws to Unix worksheet window | |
tell uws | |
select insertion point after last character | |
set selection to output |
// make sure we're using the right db; this is the same as "use aggdb;" in shell | |
db = db.getSiblingDB("aggdb"); | |
// simple projection | |
var p1 = db.runCommand( | |
{ aggregate : "article", pipeline : [ | |
{ $project : { | |
tags : 1, | |
pageViews : 1 | |
}} |
escaped = CGI.unescape(query) | |
return escaped if escaped.valid_encoding? | |
%w[EUC-JP Shift_JIS].each do |encoding| | |
s = escaped.force_encoding(encoding) | |
return s.encode("UTF-8") if s.valid_encoding? | |
end | |
escaped |