Skip to content

Instantly share code, notes, and snippets.

View wtn's full-sized avatar

William T. Nelson wtn

  • United States
View GitHub Profile
require 'rubygems'
require 'httparty'
class NFLStream
attr_accessor :current_scores
include HTTParty
format :json
base_uri "http://www.nfl.com"
@iboard
iboard / workaround_mongo_associations.rb
Created February 12, 2011 10:55
Workaround for mongo-id-associations
class Author
include Mongoid::Document
include Mongoid::Timestamps
...
references_and_referenced_in_many :institutes
after_save :update_institutes #WORKAROUND
...
private
...

The server.rb file slowly feeds data to the socket, and both clients will yield data as it's available. UneventfulMachine steals the API of EventMachine.

anonymous
anonymous / gist:40a7472abe264884768f
Created August 14, 2014 01:02
KanKen DS3 question extract
// タンポポの{綿毛}が風にふかれて飛ぶ。
// わたげ
// 植物のくきは上の方へのびる{性質}がある。
// せいしつ
// 手あらいをよくして伝染<せん>病を{防}ぐ。
// ふせ
// 父は{常}に「腹<はら>八分目」を心がけている。
// つね
// 母は{雑用}が多くてこまっているようだ。
// ざつよう
@thom-nic
thom-nic / chunked_transfer_decoder.rb
Last active February 5, 2020 15:23
Rack middleware to decode chunked transfer HTTP request
#require 'rack/request'
# Rack middleware to decode a `Transfer-Encoding: chunked` HTTP request.
#
# USAGE NOTE:
#
# Some HTTP servers (Webrick and Unicorn/Rabinbows/Zbatery) already decode the
# chunked stream, but they leave the 'Transfer-Encoding' header and don't bother
# to add a 'Content-Length' header, which causes rails ActionDispatch::Request
# to not parse the whole request body.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@kazpsp
kazpsp / passwords_controller.rb
Created August 14, 2012 16:40 — forked from guilleiguaran/passwords_controller.rb
StrongParameters with Devise
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
@jotto
jotto / how_to_make_quickbooks_qbo.txt
Created November 3, 2010 19:56
QUICKBOOKS OL-222
Quickbooks OL-222 error help
Quickbooks QBO files are based on the OFX spec.
Instead of reading the spec, here are the actual real
world rules since Intuit doesn't appear to care about documentation or helping.
This is particularly useful if you want to avoid the "OL-222" error when
trying to import your own QBO files.
<STMTTRN>
@murbanski
murbanski / api_clients_controller_spec.rb
Last active February 27, 2024 19:53
RSpec 3.1 and Rails 4 HTTP Digest Auth testing
# spec/controllers/api_clients_controller_spec.rb
RSpec.describe APIClientsController, type: :controller do
let(:api_client) { mock_model(APIClient) }
context "when HTTP Digest auth credentials are invalid" do
before do
authenticate_with_http_digest("invalid_login", "invalid_password") do
get :index
end
end
@MichaelCurrin
MichaelCurrin / README.md
Last active March 6, 2024 10:19
Twitter GraphQL sample

Twitter GraphQL sample

Example of using a GraphQL service to explore the Twitter API

A great way to explore the Twitter API and returned data, without worrying about authorization or local setup. Just add a query in the explorer and hit run.

About

The GraphQL Hub website has an interactive GraphiQL service which allows access to Gitub, Twitter, Giphy and other APIs in the browser without authorization.