Skip to content

Instantly share code, notes, and snippets.

View richhollis's full-sized avatar

Richard Hollis richhollis

View GitHub Profile
@richhollis
richhollis / credits
Created February 22, 2012 12:33
Patched jquery-ui-1.8.16.js for twitter bootstrap 2.0 input autocomplete / typeahead
Credit to the original posters on Stack Overflow that proposed the fix - thanks!
http://stackoverflow.com/questions/9232748/twitter-bootstrap-typeahead-ajax-example
http://stackoverflow.com/users/1205428/bmoers
http://stackoverflow.com/users/379593/el-developer
@richhollis
richhollis / gist:4019391
Created November 5, 2012 18:15
Gist for search issue with sferik / twitter
Twitter::Error::Forbidden: Missing or invalid url parameter
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/twitter-4.1.2/lib/twitter/response/raise_error.rb:21:in `on_complete'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/faraday-0.8.4/lib/faraday/response.rb:9:in `block in call'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/faraday-0.8.4/lib/faraday/response.rb:63:in `on_complete'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/faraday-0.8.4/lib/faraday/response.rb:8:in `call'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/faraday-0.8.4/lib/faraday/request/url_encoded.rb:14:in `call'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:13:in `call'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/twitter-4.1.2/lib/twitter/request/multipart_with_file.rb:21:in `call'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/faraday-0.8.4/lib/faraday/connection.rb:226:in `run_request'
from /home/rich/.rvm/gems/ruby-1.9.2-p320/gems/twitter-4.1.2/lib/twitter/client.rb:71:in
-----BEGIN CERTIFICATE-----
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApyaWNo
aG9sbGlzMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
b20wHhcNMTMwNDAyMTEzODA0WhcNMTQwNDAyMTEzODA0WjBBMRMwEQYDVQQDDApy
aWNoaG9sbGlzMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9lueRqZlS9BWQ
KM2Vt8Ajc7goi4mivw+QfuQTbkk3quGuF/ZFrQuyh/N+GXKJmIt/GPoDphVUOBGo
nDMd10NAIdQzHsOzElTAZi85KonMJ8KUG3JTqnomNFjKtxdVSTyi4COSpSemT6Y1
WglANxXyG2PtUOypsMjdDmDrZ0zx0N/+Ovg5lGh862f6rDQDk1EGsdUAa1E7cGGu
FCIBimJ5t/YX86g0+XedXcMeu8neb7zjIb0TaH5p5N/+hRwWh155kt8EsP9Grz7t
# controllers/api/api_controller.rb
class Api::ApiController < ApplicationController
respond_to :json
before_filter :ensure_user
rescue_from ::ApiException do |exception|
logger.info "ApiException #{exception.inspect}"
render :json => { :errors => { :error => exception.message} }.to_json, :status => 400
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
tables = [] # or ActiveRecord::Base.connection.tables
collation = "utf8_unicode_ci"
char_set = "utf8"
db = "your_database_name"
# write out
puts "USE #{db};"
puts "ALTER DATABASE #{db} CHARACTER SET #{char_set} COLLATE #{collation};"
tables.each do |t|
puts "ALTER TABLE #{t} CHARACTER SET #{char_set} COLLATE #{collation};" # changes for new records
puts "ALTER TABLE #{t} CONVERT TO CHARACTER SET #{char_set} COLLATE #{collation};" # migrates old records
@richhollis
richhollis / gist:7548877
Last active December 28, 2015 19:18
Crash course in Clojure - Week 1 Homework
(require 'crash-course-clojure.spotify)
(use 'crash-course-clojure.spotify)
(def tracks
(love :tracks)
)
(def tracks-sorted
(sort (fn [x y] (> (count(x :name)) (count(y :name)))) tracks)
)
@richhollis
richhollis / gist:7563637
Last active December 28, 2015 21:19
Clojure GitHub API Homework
(ns crash-course-github
(:require [clj-http.client :as http]
[cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]]))
(use 'crash-course-github)
(defn query-github
"Run an arbitrary query against Github API."
[query]
@richhollis
richhollis / gist:7614183
Created November 23, 2013 12:39
Clojure Week 3 Homework - Poker hand
(defn deck []
(for [suit [:clubs :hearts :spades :diamonds]
pip (range 2 15)]
{:suit suit
:pip pip}))
(defn hand-frequencies [hand]
(frequencies (map :pip (hand))))
(defn n-of-a-kind?
<!DOCTYPE html>
<html>
<head>
<title>test-vticker</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://sdepold.github.io/jquery-rss/src/jquery.rss.js"></script>
<script src="http://richhollis.github.com/vticker/downloads/jquery.vticker.min.js?v=1.14"></script>
<script>
$(function() {