Skip to content

Instantly share code, notes, and snippets.

import java.util.regex.Pattern
def convert(in: String, delimiter: String) = in.split(Pattern.quote(delimiter)).toList.map(str => str.head.toUpper+str.tail).mkString(delimiter)
def convert(in: String):String = convert(in, "\n")
// Test with delimiter & without
println(convert("bli\nbla\nblu"))
println(convert("bli$bla$blu", "$"))
#!/usr/bin/env ruby
#coding: utf-8
def convertor(string, delimiter='\n')
string.split(delimiter).each{ |c| c.capitalize! }.join(delimiter)
end
# Will remove capital letter in the rest of the string. Didn't found a simple way to keep them.
@schatteleyn
schatteleyn / manager.rb
Created March 8, 2012 22:02 — forked from davidcornu/manager.rb
Convenient command line methods
/usr/bin/ruby /Users/schatteleyn/manager.rb $1 $2 $3 $4 $5
@schatteleyn
schatteleyn / music.rb
Created March 30, 2012 20:29 — forked from davidcornu/music.rb
Music Dubstep
bassline = Thread.new do
`yes "wub" | xargs say`
end
lead = Thread.new do
`say -v cellos Doo da doo da dum dee dee doodly doo dum dum dum doo da doo da doo da doo da doo da doo da doo`
end
bassline.join
lead.join
@schatteleyn
schatteleyn / hack.sh
Last active October 2, 2015 15:08 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@schatteleyn
schatteleyn / rine.rb
Created July 26, 2012 09:31
Quatrine de Midisix
require 'time'
t = Time.now
h = t.hour
m = t.min
a = 1
d = h - 9
if d >= 0
@schatteleyn
schatteleyn / range.js
Created October 8, 2012 09:08
Js Range
/*
Naive implementation of a range in Javascript. I needed that for a project, and coming from Ruby, I was disappointed to find there wasn't that.
So I implemented one.
b => beginning value of the range
e = ending value of the range
i => include or not the last value (.. or ... in Ruby)
*/
var array = new Array;
@schatteleyn
schatteleyn / gist:3930583
Created October 22, 2012 09:23
Stack Trace Error
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:364: warning: already initialized constant Revision
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:365: warning: already initialized constant HTTPVersion
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:369: warning: already initialized constant HAVE_ZLIB
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:677: warning: already initialized constant SSL_ATTRIBUTES
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1416: warning: already initialized constant HTTPSession
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:2109: warning: already initialized constant METHOD
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:2110: warning: already initialized constant REQUEST_HAS_BODY
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:2111: warning: already initialized constant RESPONSE_HAS_BODY
/Users/username/.rvm/rub
@schatteleyn
schatteleyn / lineup.rb
Created December 6, 2012 13:19
Do an easy line-up
require 'trollop'
opts = Trollop.options do
banner <<-EOS
This programs help you to do a running order. Use it like this:
ruby lineup.rb -b Band "Best Band Ever" -t 30 75 -e 21 25 -s 20
Band
Set: 21:25 - 21:55
@schatteleyn
schatteleyn / synch.rb
Last active December 10, 2015 19:18
Script to find and copy the movies from a computer to an external hard drive
computer = #path to movies directory
hd = #path to movies directory
def get_movies(path_comp, path_hd)
# Return ana rray with only the new movies. I exclude the directory Series in the search
return `ls #{path_comp} | grep -v Series`.split(/\n/) - `ls #{path_hd} | grep -v Series`.split(/\n/)
end
new_movies_list = get_movies(computer, hd)