Skip to content

Instantly share code, notes, and snippets.

@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] ||= {}
#lang racket
(define (list-sum l k)
(if (null? l)
(k 0)
(list-sum (cdr l)
(lambda (s) (k (+ s (car l)))))))
± $ 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'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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
#!/usr/bin/python -O
"""
Copies file/folders over scp. Caches password/passphrases.
"""
import getpass
import pexpect
import sys
from optparse import OptionParser
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 () {
int get_max_range(int a[], int n, int *start, int *end)
{
int temp_sum = 0, sum = 0, found = -1;
int i, j;
for (i = 0; i < n - 1; i++) {
temp_sum = a[i];
*start = i;
for (j = i;j < n; j++) {
temp_sum = a[j];
int missing(int a[], int n) {
double num = n + 1;
double ideal_sum = (num * (num + 1)) / 2;
int sum = 0;
int i;
for (i = 0; i < n; i++) {
sum += a[i];
}
int duplicate(int a[], int n)
{
int sum = 0, num = n - 1;
doulbe ideal_sum = (num * (num + 1)) / 2;
int i;
for (i = 0; i < n; i++) {
sum += a[i];
}
class Person
{
private String name;
public Person(String name) {
this.name = name;
}
public Person() {
}