Skip to content

Instantly share code, notes, and snippets.

@iamjarvo
iamjarvo / ruby_skype_api_example.rb
Created June 7, 2012 14:54 — forked from ebisawa/ruby_skype_api_example.rb
Skype API example in Ruby
require 'dbus'
MYNAME = 'com.example.skype_api_client'
class SkypeAPI
def initialize(name = MYNAME)
bus = DBus.session_bus
service = bus.service("com.Skype.API")
objs = service.object("/com/Skype")
objs.introspect

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
if [[ $BUILD_STATUS == "success" ]]
then
export STATUS="success"
else
export STATUS="failure"
fi
curl "https://api.github.com/repos/justincampbell/my_repo/statuses/$GIT_COMMIT?access_token=abc123" \
-H "Content-Type: application/json" \
-X POST \
def stupid_return(arg)
arg == 3 ? 'stupid' : arg
end
[*1..5].each { |i| puts stupid_return(i) }
#=> 1 2 stupid 3 4 5
@iamjarvo
iamjarvo / sql.rb
Created April 5, 2013 18:51 — forked from radar/sql.rb
before do
ActiveSupport::Notifications.subscribe('sql.active_record') do |name, starts_at, ends_at, id, payload|
if /stock_items/.match(payload[:sql]) && /INSERT/.match(payload[:sql])
puts caller.delete_if { |p| !p.include?("/Users/ryan/Sites/gems/spree") }.join("\n")
puts "*" * 100
end
end
end

Zsh Tab Completion for Golang

This is pretty specific to my setup but the idea can be adapted to work with pretty much anything.

Go has a flag package which makes parsing command line arguments really easy.

package main

Rails i18n framework for your meta tags

Here is a convenient method for page titles and other meta tags.

One common solution is to use "yield" and some kind of helpers that would call content_for (like in this Railscasts).

The problem is that for Search Engines Optimization, you should change all your meta tags for every page to avoid duplicate content, and call your helpers on every page...

This workaround uses the i18n framework and tries to find the good tags depending on the page you are, so you don't have to call any helper by default.

#!/bin/bash
# Print the usage statement and exit if no options are provided. Otherwise, set
# the required variables.
#
if [ $# -lt 1 ]
then
echo "Usage:"
echo "app console Start the console application"
echo "app test Run the test suite"
@iamjarvo
iamjarvo / Rakefile
Created October 27, 2013 18:53 — forked from scottwb/Rakefile
SSH_USER = 'root'
SSH_HOST = 'www.example.com'
SSH_DIR = '/var/www/html/www.example.com'
desc "Build the website from source"
task :build do
puts "## Building website"
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end