Skip to content

Instantly share code, notes, and snippets.

var tcp = require("tcp");
var server = tcp.createServer(function (socket) {
var client;
socket.addListener("connect", function () {
client = tcp.createConnection(22);
client.addListener("receive", function (data) {
socket.send(data);
});
client.addListener("eof", function () {
#!/usr/bin/python -O
"""
Copies file/folders over scp. Caches password/passphrases.
"""
import getpass
import pexpect
import sys
from optparse import OptionParser
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function Send_to_Screen(text)
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
call Screen_Vars()
end
let s:foo_text = substitute(a:text, '\n\s*\n\+', '\n', 'g') . "\n"
echo system("screen -S " . g:screen_sessionname . " -p " . g:screen_windowname . " -X stuff '" . substitute(s:foo_text, "'", "'\\\\''", 'g') . "'")
endfunction
± $ rails s 100 on-line
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/rahul/projects/fat_free_crm/lib/fat_free_crm.rb:42:in `<top (required)>': uninitialized constant Rails::Plugin::Loader (NameError)
from /home/rahul/projects/fat_free_crm/config/initializers/fat_free_crm.rb:1:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/railties-3.0.3/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
from /var/lib/gems/1.9.1/gems/railties-3.0.3/lib/rails/engine.rb:200:in `each'
#lang racket
(define (list-sum l k)
(if (null? l)
(k 0)
(list-sum (cdr l)
(lambda (s) (k (+ s (car l)))))))
@rahulkmr
rahulkmr / gmail_oauth.rb
Created May 14, 2011 01:02
Example - oauth for gmail.
require "sinatra"
require 'json'
require "oauth"
require "oauth/consumer"
require 'gmail_xoauth'
enable :sessions
before do
session[:oauth] ||= {}
user=> (source output-stream)
(defn ^OutputStream output-stream
"Attempts to coerce its argument into an open java.io.OutputStream.
Default implementations always return a java.io.BufferedOutputStream.
Default implementations are defined for OutputStream, File, URI, URL,
Socket, and String arguments.
If the argument is a String, it tries to resolve it first as a URI, then
as a local file name. URIs with a 'file' protocol are converted to
https://plus.google.com/_/notifications/emlink?emrecipient=110980919682495338132&emid=CMjztYPM3KkCFQx97AodHlxyGA&path=%2Fwelcome%3Fgpinv%3DAGXbFGxRQi9hP6iVrph0RQI3p0sp7UaxptyD4JGxhl293nTm5jRDbJuTQGzZjpPnz_Rs8MZJDWegy2OwWkhMQ4IF7Sk4eNVPDWbkQAL7mNkK9cpmiHKKFjw%26hl%3Den_US
https://plus.google.com/_/notifications/emlink?emrecipient=110980919682495338132&emid=CLiQyP_L3KkCFcK17AodRzRKGA&path=%2Fwelcome%3Fgpinv%3DAGXbFGxmaqZZV0ORRozZDf54-2dmPa-lB4xdQ46J4UfrSCnR64biZKLtwfeL2VIzS04Dxa67NeLcp8aaiAIj8LnavLkCZXH0GXCuh0xmmN7OpsgIKkEITWA%26hl%3Den_US
https://plus.google.com/_/notifications/emlink?emrecipient=110980919682495338132&emid=CNi0pu7L3KkCFUS_7Aod2RpqGA&path=%2Fwelcome%3Fgpinv%3DAGXbFGxvrJoIrDz4x57z2gceG1EaTvVgmWU-dbFUC7UjZhR73Jq5w9TwRDPwbOokAZ5sJeXVkkMtty96x860j2TyXP0aHaDK3RCwKbla9Ji-ihBsKnO-BVU%26hl%3Den_US
https://plus.google.com/_/notifications/emlink?emrecipient=110980919682495338132&emid=COj2qZjM3KkCFWe97AodWsulGA&path=%2Fwelcome%3Fgpinv%3DAGXbFGwxW0wLj-T5ILxFLTzKW_xdqkliLiFn5-l9VnGoRq9whW5g7A7GvoIZCLuyz9
@rahulkmr
rahulkmr / gist:1072975
Created July 8, 2011 22:25
Multipart form encoding.
import mimetypes
def encode_multipart_formdata(fields=None, files=None):
"""
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return (content_type, body) ready for httplib.HTTP instance
"""
if not (fields or files):
return None, None
@rahulkmr
rahulkmr / brainfuck.rb
Created September 9, 2011 11:54 — forked from ingramj/brainfuck.rb
A Brainfuck interpreter written in Ruby.
#!/usr/bin/env ruby
class BrainFuck
def initialize
@ops = create_ops
@tape = Array.new(1024,0)
@tp = 0
@code = []
@cp = 0
end