Skip to content

Instantly share code, notes, and snippets.

View wjessop's full-sized avatar
🤖

Will Jessop wjessop

🤖
View GitHub Profile
@wjessop
wjessop / gist:1162741
Created August 22, 2011 15:57
yes/no
ruby-1.9.2-p290 :001 > class Object
ruby-1.9.2-p290 :002?> def yes
ruby-1.9.2-p290 :003?> true
ruby-1.9.2-p290 :004?> end
ruby-1.9.2-p290 :005?>
ruby-1.9.2-p290 :006 > def no
ruby-1.9.2-p290 :007?> false
ruby-1.9.2-p290 :008?> end
ruby-1.9.2-p290 :009?> end
=> nil
test_db=> CREATE TABLE foo (
test_db(> id serial,
test_db(> thing varchar(40) NOT NULL
test_db(> );
NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq" for serial column "foo.id"
CREATE TABLE
test_db=> insert into foo (thing) values ('test');
INSERT 0 1
test_db=> insert into foo (thing) values ('test2');
INSERT 0 1
[1.9.2] ~ $ ruby threads.rb
popping the stack
vals is now [16]
popping the stack
vals is now [1, 16]
popping the stack
vals is now [1, 11, 16]
popping the stack
vals is now [1, 11, 16, 19]
popping the stack
$:.unshift File.join(File.dirname(__FILE__), 'lib')
require 'em-campfire'
EM.run {
adaptor = EM::Campfire.new(:subdomain => "subdomain", :api_key => "foo")
connection.join ["Robot Army", "Monitoring", "Testing"]
connection.on_message do |msg|
# A hash
<?php
$group_url = urlencode("http://tech.dir.groups.yahoo.com/group/OneStopCOBOL");
$api_url = "http://yahoo-group-data.herokuapp.com/api/v1/group/$group_url";
if (ini_get('allow_url_fopen') == '1') {
if ($fp = fopen($api_url, 'r')) {
$content = '';
// keep reading until there's nothing left
while ($line = fread($fp, 1024)) {
require 'open-uri'
require 'cgi'
url = "http://tech.dir.groups.yahoo.com/group/OneStopCOBOL"
json = open("http://yahoo-group-data.herokuapp.com/api/v1/group/#{CGI.escape(url)}").read
json = json.force_encoding("utf-8") if RUBY_VERSION[/1\.9/]
puts json
var http = require('http');
var encoded_url = encodeURIComponent('http://tech.groups.yahoo.com/group/OneStopCOBOL/');
var host = 'yahoo-group-data.herokuapp.com';
var client = http.createClient(80, host);
var request = client.request('GET', '/api/v1/group/' + encoded_url, {'host': host});
request.end();
request.on('response', function (response) {
console.log('STATUS: ' + response.statusCode);
{
"private": false,
"not_found": false,
"age_restricted": false,
"name": "OneStopCOBOL",
"description": "OneStopCOBOL - Official COBOL group",
"post_email": "[email protected]",
"subscribe_email": "[email protected]",
"owner_email": "[email protected]",
"unsubscribe_email": "[email protected]",
defm
UserAgent.parse(request.user_agent)
end
@wjessop
wjessop / hack.sh
Created March 31, 2012 13:43 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#