Skip to content

Instantly share code, notes, and snippets.

View technoweenie's full-sized avatar
👾
beep boop

technoweenie

👾
beep boop
View GitHub Profile
@technoweenie
technoweenie / gist:5101109
Last active January 7, 2016 16:56
API Existential Crisis

API Existential Crisis

One bit of feedback we've heard from some heavy users of the API is that they want to access user and repository data by ID, and not name.

GET /users/technoweenie
GET /repos/technoweenie/faraday

If you're tracking user or repository data, using a URL with a unique and unchanging ID means the application won't break if the user or repository is

package main
import (
"fmt"
"github.com/moovweb/gokogiri"
"io/ioutil"
"net/http"
"net/url"
"time"
)
@technoweenie
technoweenie / changelog.md
Last active December 10, 2015 09:29
Faraday v0.9.0 Changelog

(incomplete)

https://github.com/technoweenie/faraday/compare/v0.8.4...master

  • Added Apache HTTPClient adapter. (@hakanensari)
  • Added Instrumentation middleware, which supports ActiveSupport::Notifications. (@mislav)
  • Fix EM::Synchrony options (@hakanensari)
  • Add Typhoeus bind options (@ezkl)
  • Excon fixes (@archfear)
  • Net/HTTP handles unreachable network exceptions (@ossareh)
# lets say we change /repos/* to /repositories
# hardcoded urls
pull_response = RestCall.get("/repos/bob/rails8/pulls") # 301
pull_response = RestCall.get("/repositories/bob/rails8/pulls")
issue_response = RestCall.get("/repos/bob/rails8/issues/#{response.first['issue']}") # 301
issue_response = RestCall.get("/repositories/bob/rails8/issues/#{response.first['issue']}")
# hypermedia
pull_response = RestCall.get("/repos/bob/rails8/pulls") # 301
@technoweenie
technoweenie / gist:2568117
Created May 1, 2012 14:04
Python Master/Worker forking with ZeroMQ instead of unix signals.
# Don't use this.
import zmq
import os
class Worker:
def __init__(self):
print "parent: %d, pid: %d" % (os.getppid(), os.getpid())
self.pid = os.getppid()
self.context = zmq.Context()
self.sub = self.context.socket(zmq.SUB)
@technoweenie
technoweenie / gist:2155760
Created March 22, 2012 04:03
track meta data with resque jobs, like when it was queued.
module Resque
def push_with_meta(queue, item)
if item.respond_to?(:[]=)
item[:meta] = {:queued_at => Time.now.to_f}
end
push_without_meta(queue, item)
end
class Job
# Returns a Hash of the meta data related to this Job.
@technoweenie
technoweenie / pom.xml
Created March 15, 2012 04:58 — forked from codahale/pom.xml
the finished pom.xml after going through the DropWizard tutorial
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.helloworld</groupId>
<artifactId>hello-world</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
@technoweenie
technoweenie / heartbeat.rb
Created February 21, 2012 01:59
heartbeat actor w/ celluloid
require 'rbczmq'
require 'fileutils'
require 'celluloid'
class Heartbeat
include Celluloid
def self.start(id = nil, options = nil)
new(ZMQ::Context.new, id, options)
end
@technoweenie
technoweenie / .gitignore
Created February 20, 2012 04:55
quick kestrel zeromq port attempt
node_modules
@technoweenie
technoweenie / dump_cotweet.rb
Created February 3, 2012 00:09
export cotweet sent timeline
require 'json'
require 'fileutils'
require 'faraday'
email, pass, dir = ARGV
if !(email && pass)
puts "Pass your CoTweet email/password:"
puts
puts " $ ruby #{$0} email@example.com sekretpassword [/path/to/dump]"