Skip to content

Instantly share code, notes, and snippets.

@ncr
ncr / flash_socket_policy_server.js
Created December 22, 2009 11:53
A minimal Flash Socket Policy Server
// A minimal Flash Socket Policy server for node.js.
require("tcp").createServer(function (c) {
c.addListener("receive", function () {
c.send('<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>');
c.close();
});
}).listen(843);
/*
Author: Jacek Becela (http://github.com/ncr)
License: MIT
$("img").sqrop() // square crop with side length equal to shorter side of image
$("img").sqrop(200) // square crop with 200px side length, image scaled accordingly
Inspiration: http://www.seifi.org/css/creating-thumbnails-using-the-css-clip-property.html
*/
Old way:
$ git checkout -b preandpost_fork_hooks scotttam/preandpost_fork_hooks
Branch preandpost_fork_hooks set up to track remote branch preandpost_fork_hooks from scotttam.
Switched to a new branch 'preandpost_fork_hooks'
New way:
$ git checkout preandpost_fork_hooks
Branch preandpost_fork_hooks set up to track remote branch preandpost_fork_hooks from scotttam.
#!/usr/bin/env ruby
require 'rubygems'
require 'aws/s3'
S3_CREDENTIALS = File.expand_path(File.join('~', '.s3', 'auth.yml'))
APP = 'darkblog'
BUCKET = 's3.blog.darkhax.com'
def bundle
# see http://github.com/intridea/oauth2
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
class ConnectionLogger < Faraday::Middleware
def call(env)
env[:response].on_complete do |env|
puts "RESULT: #{env[:status]}\n#{env[:body]}"
# this code snippet was inspired by
# http://www.igvita.com/2010/04/15/non-blocking-activerecord-rails/
require 'fiber' # needed to use Fiber.current
require 'rubygems'
require 'mysqlplus'
require 'eventmachine'
require 'em-mysqlplus'
def query(sql)
# Net::HTTPResponse streaming for use in Rack apps with Fibers!
def read_body # Net::HTTPResponse#read_body
yield "foo"; yield "bar"; yield "baz"
end
class R # A Rack Streaming response
def initialize
@f = Fiber.new do
read_body do |chunk| # Net::HTTPResponse#read_body

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:

I wrote my first program 25 years ago.

embed: hello.bas

@ncr
ncr / config.yml
Created June 5, 2010 13:39
Blogist Meta
title: Jacek Becela is Blogist
layout: 427820
index:
- 426631