Skip to content

Instantly share code, notes, and snippets.

View technoweenie's full-sized avatar
👾
beep boop

technoweenie

👾
beep boop
View GitHub Profile
def self.encode(uri, character_class=nil, returning=String)
return nil if uri.nil?
if !uri.respond_to?(:to_str)
raise TypeError, "Can't convert #{uri.class} into String."
end
if ![String, ::Addressable::URI].include?(returning)
raise TypeError,
"Expected String or Addressable::URI, got #{returning.inspect}"
end
uri_object = uri.kind_of?(self) ? uri : self.parse(uri.to_str)
@technoweenie
technoweenie / github_oauth_busy_developer_guide.md
Created May 30, 2010 18:34
GitHub OAuth Busy Developer's Guide

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@technoweenie
technoweenie / gist:1072829
Created July 8, 2011 21:12
.netrc file so you can push/pull to https git repos without entering your creds all the time
machine github.com
login technoweenie
password SECRET
machine api.github.com
login technoweenie
password SECRET
Queueing SELECT for next server connection.
Queueing FLUSHDB for next server connection.
Queueing QUIT for next server connection.
Stream connected
Sending offline command: SELECT
send command: *2
$6
SELECT
$2
@technoweenie
technoweenie / minimal-logger.coffee
Created March 9, 2011 20:25
Minimal node.js logger
# logger = require('logger').create()
# logger.info("blah")
# => [2011-3-3T20:24:4.810 info (5021)] blah
# logger.debug("boom")
# =>
# logger.level = Logger.levels.debug
# logger.debug(function() { return "booom" })
# => [2011-3-3T20:24:4.810 error (5021)] booom
class Logger
constructor: (options) ->
@technoweenie
technoweenie / parslet_test.rb
Created January 12, 2011 12:11
quick JSON example parser using parslet
require 'rubygems'
require 'parslet'
require 'pp'
def parse(klass, str)
parser = klass.new
puts "parsing #{str}"
pp parser.parse(str)
puts
rescue Parslet::ParseFailed => err
@technoweenie
technoweenie / keybase.md
Created January 6, 2019 18:35
keybase proof

Keybase proof

I hereby claim:

  • I am technoweenie on github.
  • I am technoweenie (https://keybase.io/technoweenie) on keybase.
  • I have a public key ASDYg1Rh0rCIQPFh7-m5Ip0vINt46_GxKKcpHCF6WN_-Uwo

To claim this, I am signing this object:

package main
import (
"fmt"
"github.com/moovweb/gokogiri"
"io/ioutil"
"net/http"
"net/url"
"time"
)
@technoweenie
technoweenie / pinger.rb
Created June 17, 2011 14:38
ZeroMQ pub/sub demo
require 'zmq'
context = ZMQ::Context.new
pub = context.socket ZMQ::PUB
pub.setsockopt ZMQ::IDENTITY, 'ping-pinger'
pub.bind 'tcp://*:5555'
i=0
loop do
pub.send "ping pinger #{i+=1}" ; sleep 1
end
package main
import (
"fmt"
"sync"
)
func main() {
fmt.Println("WAT")
}