These are field notes gathered during installation of website search facility for the ElasticSearch website.
You may re-use it to put a similar system in place.
The following assumes:
require 'json' | |
require 'httparty' | |
class Github | |
include HTTParty | |
base_uri 'http://github.com/api/v2/json' | |
# @param [String] username GitHub username | |
# @param [String] password Password or API token | |
def initialize(username, password) |
These are field notes gathered during installation of website search facility for the ElasticSearch website.
You may re-use it to put a similar system in place.
The following assumes:
# Run me with: | |
# | |
# $ nginx -p /path/to/this/file/ -c nginx.conf | |
# | |
# All requests are then routed to authenticated user's index, so | |
# | |
# GET http://user:password@localhost:8080/_search?q=* | |
# | |
# is rewritten to: | |
# |
// ==UserScript== | |
// @name Emulate `unsafeWindow` in browsers that don’t support it. | |
// ==/UserScript== | |
// http://mths.be/unsafewindow | |
window.unsafeWindow || ( | |
unsafeWindow = (function() { | |
var el = document.createElement('p'); | |
el.setAttribute('onclick', 'return window;'); | |
return el.onclick(); |
class Hash | |
def map_values(&block) | |
merge(self) { |k, v| block.call(v) } | |
end | |
end | |
puts ({:a => 1, :b => 2}.map_values { |x| x * 2}) | |
# => {:a=>2, :b=>4} |
# include this in your shell profile | |
function rake { | |
if [ -e "Gemfile" ] | |
then | |
bundle exec rake $@ | |
else | |
`which rake` $@ | |
fi | |
} |
source "https://rubygems.org" | |
gem 'sprockets' | |
gem 'sprockets-sass' | |
gem 'sass' | |
gem 'compass' | |
gem 'bootstrap-sass' | |
gem 'handlebars_assets' | |
gem 'coffee-script' |
# Committing changes to a repo via the Github API is not entirely trivial. | |
# The five-step process is outlined here: | |
# http://developer.github.com/v3/git/ | |
# | |
# Matt Swanson wrote a blog post translating the above steps into actual API calls: | |
# http://swanson.github.com/blog/2011/07/23/digging-around-the-github-api-take-2.html | |
# | |
# I was not able to find sample code for actually doing this in Ruby, | |
# either via the HTTP API or any of the gems that wrap the API. | |
# So in the hopes it will help others, here is a simple function to |
Since this is on Hacker News and reddit...
_t
in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".char *
s.type * name
, however, is entirely intentional.