Skip to content

Instantly share code, notes, and snippets.

@mahemoff
mahemoff / gist:8885615
Last active August 29, 2015 13:56
Dbpedia Ruby
# Using https://github.com/farbenmeer/dbpedia
# http://stackoverflow.com/questions/13033841/dbpedia-country-profile-query
# See also http://stackoverflow.com/questions/15610033/query-cities-and-their-country-from-dbpedia
# List of countries, including defunct countries
Dbpedia.sparql.query('select ?country where { ?country rdf:type dbpedia-owl:Country }')
# List of modern countries
select ?country where { ?country <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Member_states_of_the_United_Nations>; <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Country> } order by ?country
@mahemoff
mahemoff / gist:8918750
Created February 10, 2014 16:15
Pro tip
"Project Default Service Account" is what Google Plus calls default OAuth providers. As the developer, change it in the console under "Consent screen".
@mahemoff
mahemoff / gist:8973559
Created February 13, 2014 11:31
Reference data in Linode API
# Setup
require 'pp'
require 'linode'
l = Linode.new api_key: 'my-api-key' # Get that from https://manager.linode.com/profile/index
a = l.avail
# Let's Rock It ...
2.1.0 :011 > pp a.datacenters
@mahemoff
mahemoff / linode
Created February 13, 2014 21:07
Ansible Linode module - changes to remove Linode ID name prefix, and to add private IP support.
# api.linode_update(LinodeId=linode_id, Label='%s_%s' % (linode_id, name))
api.linode_update(LinodeId=linode_id, Label='%s' % (name))
api.linode_ip_addprivate(LinodeId=linode_id)
@mahemoff
mahemoff / ask-wikipedia.rb
Last active August 29, 2015 13:56 — forked from emad-elsaid/ask-wikipedia.rb
Refactor processing, make script standalone with initial env, add command-line argument
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
language = 'en'
article = ARGV[0] ||
begin
print 'What do you need to know? : '
URI::encode gets.chomp
@mahemoff
mahemoff / gist:9214688
Created February 25, 2014 18:20
callbacks stacktrace
/Users/ruby/.rvm/gems/ruby-2.1.0/bundler/gems/rails-25a05723792b/activesupport/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `_compile_filter' for class `ActiveSupport::Callbacks::Callback' (NameError)
from /home/project/.rvm/gems/ruby-2.1.0/bundler/gems/rails-25a05723792b/activesupport/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method_chain'
from /home/project/demo/config/initializers/log_callbacks.rb:3:in `included'
from /home/project/demo/config/initializers/log_callbacks.rb:37:in `include'
from /home/project/demo/config/initializers/log_callbacks.rb:37:in `<top (required)>'
from /home/project/.rvm/gems/ruby-2.1.0/bundler/gems/rails-25a05723792b/activesupport/lib/active_support/dependencies.rb:241:in `load'
from /home/project/.rvm/gems/ruby-2.1.0/bundler/gems/rails-25a05723792b/activesupport/lib/active_support/dependencies.rb:241:in `block in load'
from /home/project/.rvm/gems/ruby-2.1.0/bundler/gems/rails-25a05723792b/activesupport/lib/active
@mahemoff
mahemoff / unicorn
Last active August 29, 2015 13:57 — forked from ethier/gist:7190310
Update the upgrade function - it captures the old PID before it's overwritten by the upgrade (ie USR2 signal), then kills it once the upgrade has succeeded
#!/bin/sh
# forked from https://gist.github.com/ethier/7190310
# via http://uncorruptedstate.com/blog/2013/10/27/zero-downtime-deployment-with-rails-and-unicorn/
### Unicorn variables ###
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/web/current
UNICORN=$APP_ROOT/bin/unicorn
TMP_PATH=$APP_ROOT/tmp
PID_PATH=$APP_ROOT/tmp/pids
@mahemoff
mahemoff / gist:9684727
Created March 21, 2014 12:04
Common Ansible ssh error
FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
In my experience, this is almost because I forgot add the user. Add "-u username" to the ansible command-line call.
@mahemoff
mahemoff / Github mail
Created March 26, 2014 08:35
Odd situation involving private legacy fork of public repo
Upcoming changes to your fork mahemoff/yeoman
GitHub support@github.com
12:50 AM (7 hours ago)
Dear mahemoff,
During recent maintenance we discovered that your private fork mahemoff/yeoman's parent repository yeoman/yeoman is public. We no longer allow the creation of private forks from public repositories, so we need to make some changes to your fork.
To protect your code's privacy we don't automatically make a fork public to match the parent repository. Instead, mahemoff/yeoman will be unforked in three days and become a new private repository under your account.
<a href="https://player.fm/featured/accounting">Accounting</a>
<br>
<a href="https://player.fm/featured/acoustic">Acoustic</a>
<br>
<a href="https://player.fm/featured/adventist">Adventist</a>
<br>
<a href="https://player.fm/featured/after-life">After Life</a>
<br>
<a href="https://player.fm/featured/agile">Agile</a>
<br>