Skip to content

Instantly share code, notes, and snippets.

View edpaget's full-sized avatar

Edward Paget edpaget

  • Chicago, IL
View GitHub Profile
@edpaget
edpaget / gist:4152331
Created November 27, 2012 04:14 — forked from arfon/gist:4152089
Rickshaw example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Spotty plots</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.shutterstock.com/rickshaw/vendor/d3.v2.js"></script>
<script src="http://code.shutterstock.com/rickshaw/rickshaw.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.css">
</script>
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.hadoop.conf.Configuration
import org.bson.BSONObject
import org.bson.BasicBSONObject
object ClassificationCount {
def main(args: Array[String]) {
val sc = new SparkContext("local", "ClassificationCount")
@edpaget
edpaget / subquery_bug_test.rb
Created January 8, 2015 22:50
Rails 4.2 Subquery Bug
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
WITH RECURSIVE rand(ids, id, done) AS (
SELECT ARRAY[]::int[], sub.id, 0 FROM (SELECT t.id FROM test t WHERE t.name = 'asdf' AND t.id = ceiling(random() * 8)::integer) AS sub
UNION ALL
SELECT (n.ids || n.id), sub.id, done+1 FROM rand n, (SELECT t.id FROM test t WHERE t.name = 'asdf' AND t.id = ceiling(random() * 8)::integer) AS sub WHERE NOT done = 5
)
SELECT n.* FROM rand n;
SELECT t.* FROM test t, rand n WHERE t.id = ANY(n.ids) LIMIT 20;
# Checklist for Tomorrow
[ ] Add zooniverse.org & www.zooniverse.org to maintenance page CF distribution
[ ] Add redirect from zooniverse.org/password/reset to zooniverse.org/#/reset-password
[ ] Add redirect from zooniverse.org/projects/current to zooniverse.org/#/users
[ ] Build Ouroboros AMI with PR https://github.com/zooniverse/Ouroboros/pulls/198
[ ] Build Login AMI with PR https://github.com/zooniverse/Login/pulls/1
[ ] Tweet that Zooniverse will be down for maintenance for 30 minutes to 1 hour
[ ] Redirect zooniverse.org & www.zooniverse.org to maintenance.zooniverse.org
[ ] Migrate users that have changed since Tuesday

Checklist for Tomorrow

  • Add zooniverse.org & www.zooniverse.org to maintenance page CF distribution
  • Add redirect from zooniverse.org/password/reset to zooniverse.org/#/reset-password
  • Add redirect from zooniverse.org/projects/current to zooniverse.org/#/users
  • Add redirect from zooniverse.org/signup to zooniverse.org/#/accounts/register
  • Add redirect from zooniverse.org/api/events to panotpes.zooniverse.org/api/events
  • Reset sign_in_count
  • Build Ouroboros AMI with PR https://github.com/zooniverse/Ouroboros/pull/198
  • Build Login AMI with PR https://github.com/zooniverse/Login/pull/1
@edpaget
edpaget / postgresql_reconnect.rb
Created June 30, 2015 17:41
Postgresql Reconnect Error
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@edpaget
edpaget / classification_dups.py
Last active August 29, 2015 14:27
Remove duplicate classifications
classification_dict = dict()
for classification in classifications:
key = str(classification.user_id) + str(classification.subject_ids[0])
if not key in classification_dict:
classification_dict[key] = classification
(defui ChildComponent
static om/IQuery
(query [this]
[:id :type :name]))
(defui ParentComponent
static om/IQuery
(query [this]
[{[:things _] [{:another-key (om/get-query ChildComponent)}]}]))