Skip to content

Instantly share code, notes, and snippets.

View Kimtaro's full-sized avatar

Kim Ahlström Kimtaro

View GitHub Profile
@symmetriq
symmetriq / Toggle CamelCase _.rb
Last active November 13, 2017 01:47
BBEdit: Toggle CamelCase _
#!/usr/bin/env ruby
#-------------------------------------------------------------------------------
# Toggle Camelcase _
#-------------------------------------------------------------------------------
# Jason Sims <jason@symmetriq.com>
#-------------------------------------------------------------------------------
#
# Toggles between camelcase and underscores
# e.g. doTheThing <-> do_the_thing
@symmetriq
symmetriq / Toggle Quotes.rb
Last active November 13, 2017 01:51
BBEdit: Toggle Quotes
#!/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.
@symmetriq
symmetriq / Toggle Parentheses.rb
Last active November 13, 2017 01:49
BBEdit: Toggle Parentheses
#!/usr/bin/env ruby
#-------------------------------------------------------------------------------
# Toggle Parentheses
#-------------------------------------------------------------------------------
# Jason Sims <jason@symmetriq.com>
#-------------------------------------------------------------------------------
#
# For languages with optional parentheses, such as Ruby and CoffeeScript.
#
@erica
erica / gist:999dabc1a2d176bce3ec
Last active February 11, 2017 01:40
Composed character count
extension String {
var composedCount : Int {
var count = 0
enumerateSubstringsInRange(startIndex..<endIndex, options: .ByComposedCharacterSequences) {_ in count++}
return count
}
}
@gbuesing
gbuesing / ml-ruby.md
Last active February 28, 2024 15:13
Resources for Machine Learning in Ruby

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!

Resources for Machine Learning in Ruby

Gems

@staltz
staltz / introrx.md
Last active May 10, 2024 12:08
The introduction to Reactive Programming you've been missing
@tobyhede
tobyhede / postsql.sql
Created May 17, 2012 03:08
PostgreSQL as JSON Document Store
-- 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
--
@rwilcox
rwilcox / open_here_in_shell_worksheet.applescript
Created March 13, 2012 12:42
BBEdit Script to Open Here In Shell Worksheet
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
@cwestin
cwestin / aggregation.js
Created November 28, 2011 19:12
Mongo shell script and sample documents used for my aggregation talks 12/2011
// 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
}}
@pwim
pwim / gist:1188099
Created September 2, 2011 07:34
Trying different encodings under Ruby 1.9
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