Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title>Troop</title>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body>
class User
has_many :friendships
has_many :friends, through: :friendships
end
class Friendship
belongs_to :friend, class: User
belongs_to :friendee, class: User
end
$ dig cachefly.alfredapp.com @8.8.8.8
; <<>> DiG 9.8.3-P1 <<>> cachefly.alfredapp.com @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49360
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;cachefly.alfredapp.com. IN A
aws ec2 describe-account-attributes --region eu-west-1 | jq '.["AccountAttributes"] | reduce .[] as $item ( {}; (. + {"\($item.AttributeName)": $item.AttributeValues[].AttributeValue}))'
override func viewDidLoad() {
self.view.backgroundColor = UIColor.whiteColor()
self.view.setTranslatesAutoresizingMaskIntoConstraints(false)
for clockViewController in self.clockViewControllers {
self.view.addSubview(clockViewController.view)
}
for var i = 0; i < self.clockViewControllers.count; ++i {
@olly
olly / gist:b983f5deb9b0e98b1181
Created May 30, 2014 14:40
Install ruby 2.0.0-p451 on rbenv. Ruby doesn't compile with readline v6.3+, install a lower version with homebrew and point ruby to use it.
RUBY_CONFIGURE_OPTS=--with-readline-dir="/usr/local/Cellar/readline/6.2.4" rbenv install 2.0.0-p451
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
concerning :Authentication do
included do
before_action :authenticate_user!
end
private
def authenticate_user!
# This is an attempt to the following errors:
#
# PG::UnableToSend: SSL error: cert already in hash table=0A
#
# This wraps the OpenID::SimpleSign.store method, from the
# ruby-openid-apps-discovery gem, in a thread. I believe the root cause of this
# error is that in some environment the store gets duplicate certificates added
# to it. This causes OpenSSL errors, which then are raised in the pg gem,
# because it believes something serious has gone wrong.
#
##
## ca-bundle.crt -- Bundle of CA Certificates
## Last Modified: Wed Jun 22 11:33:22 EDT 2005
##
## This is a bundle of X.509 certificates of public
## Certificate Authorities (CA).
##
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIRANAeQJAAAEZSAAAAAQAAAAQwDQYJKoZIhvcNAQEFBQAw
@olly
olly / item.rb
Created November 14, 2013 13:37
class Item
def self.find_each(params = {})
return enum_for(:find_each) unless block_given?
page = nil
while page.nil? || page.current_page < page.total_pages
if page.nil?
page = all params
else
page = all params.merge(page: page.current_page + 1)