Skip to content

Instantly share code, notes, and snippets.

Caio Chassot kch

Block or report user

Report or block kch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kch / Rewind 30 Seconds.rb
Created May 2, 2010
Rewind currently playing track 30 seconds in iTunes
View Rewind 30 Seconds.rb
#!/usr/bin/env ruby1.9
# encoding: UTF-8
require 'appscript'
include Appscript
itunes = app("iTunes")
pos = itunes.player_position.get
pos = pos > 30 ? pos - 30 : pos / 2
itunes.player_position.set pos
kch / plist-to-yaml.rb
Created Aug 4, 2010
converts plist files to really pretty, aligned yaml files with mostly literal utf8 strings
View plist-to-yaml.rb
# encoding: UTF-8
require 'yaml'
require "base64"
require 'rexml/document'
class PList < BasicObject
def self.process_element_named(name, &block); ELEMENT_PROCESSORS[name.to_s] = block; end
def self.process_element(elt) ; ELEMENT_PROCESSORS[][elt]; end
kch /
Created Jan 5, 2010
git get name of current branch
# Previous versions of this gist brought to you by major OCD.
# I now leave you with my pick.
git branch | ack -o '(?<=^\* ).*'
kch / yaml-to-plist.rb
Created Aug 4, 2010
Writes ruby object structures to plists. When called directly, takes a YAML file.
View yaml-to-plist.rb
#!/usr/bin/env ruby
# encoding: UTF-8
require 'yaml'
require 'rexml/document'
class PlistWriter
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0"></plist>]
kch / ftff-events.rb
Created Aug 3, 2010
mac: watch home dir via fsevents and set encoding attr and reveal extension for txt and rb files
View ftff-events.rb
# encoding: UTF-8
require 'rubygems'
require 'fsevent'
require 'shellwords'
class Time
def age_in_seconds(now =
now - self
kch / infix-functions.swift
Last active Jul 17, 2016
Use any binary function as infix operator in Swift
View infix-functions.swift
infix operator « { precedence 131 associativity left }
func «<A,B,C>(a:A, f:(A,B) -> C) -> B -> C { return { f(a,$0) } }
infix operator » { precedence 131 associativity left }
func »<B,C>(f:(B) -> C, b:B) -> C { return f(b) }
infix operator < { precedence 131 associativity left }
func <<A,B,C>(a:A, f:(A,B) -> C) -> B -> C { return { f(a,$0) } }
infix operator > { precedence 131 associativity left }
kch / wgt.rb
Created May 12, 2016
sort wgt bands by time, append location
View wgt.rb
#!/usr/bin/env ruby
s = =~ /Freitag, 13. Mai 2016.*?(?=\n\n)/m && $&
s.gsub! /^(\d\d)\.(\d\d)\u00A0Uhr\n/, "\\1:\\2h -- "
days = []
s.lines.each do |l|
case l
when /^\d\d:\d\dh -- Einlaß/ then :pass
when /Mai 2016$/ then days << [l, []]
when /^\d\d:\d\dh -- / then days.last[1] << l.sub(/\Z/, " -- @ #{$x}")

Keybase proof

I hereby claim:

  • I am kch on github.
  • I am kch ( on keybase.
  • I have a public key whose fingerprint is 896A A376 3566 F68D 066B 5BEF EAF6 44A0 0B63 A2DE

To claim this, I am signing this object:


Pedro's Amazing Guide To Rooftop Bars

Very few people respect the art of rooftop drinking these days.

The problem faced by Rooftop bars is that their customers often believe they're being respectful because they're wearing a suit or a fancy dress.

Niclekback wears suits

Nevermind all the people that COMPLETELY FUCKED UP MUSIC AS WE KNOW IT while dressing well. We're still associating fancy dressing with respect.

kch / safari.rb
Created May 31, 2013
Enable private browsing mode, open a new page in Safari for the given URL.
View safari.rb
#!/usr/bin/env ruby
($stderr.puts("$0", File.basename($0))); exit 1) if ARGV.length != 1
require 'appscript'
safari_app ="Safari")
safari_process ='System Events').processes['Safari']
You can’t perform that action at this time.