Skip to content

Instantly share code, notes, and snippets.

View satishv's full-sized avatar

satish viswanatham satishv

  • Second Genome
  • San Francisco, CA
  • X @satish_
View GitHub Profile
require 'rubygems'
require 'eventmachine'
require 'evma_httpserver'
require 'cgi'
class Room < EM::Channel
end
$room = Room.new
$welcome_html = DATA.read
@pklaus
pklaus / analyseBreakinAttempts.sh
Last active September 20, 2022 10:32
A script that analyses the log files /var/log/auth.log* for illegal break-in attempts and writes all output to $logdir – Check http://blog.philippklaus.de/2010/02/analyse-illegal-ssh-login-attempts/
#!/bin/bash
# This script analyses the log files /var/log/auth.log* for
# illegal break-in attempts and writes all output to $logdir.
# <http://blog.philippklaus.de/2010/02/analyse-illegal-ssh-login-attempts/#comment-12211>
# inspired by <http://goo.gl/QMOhiU>
# and <http://filipivianna.blogspot.com/2009/10/checking-authlog-for-ssh-brute-force.html>
logbasedir=~/logs
@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:
@nazt
nazt / query.share.fb.js
Created January 19, 2011 16:26
query.share.fb.js
var qp1 = "select share_count from link_stat where url = '{0}'";
var q1 = FB.Data.query(qp1, 'http://www.together.in.th');
q1.wait(function(rows) {
console.log(rows);
FB.Array.forEach(rows, function(post) {
console.log(post,post.page_id, post.type );
});
})
@mcollina
mcollina / improve_delayed_jobs_index.rb
Created February 5, 2011 10:50
A migration to improve Delayed Job performance when runned with Delayed::Worker.destroy_failed_jobs = false.
class ImproveDelayedJobsIndex < ActiveRecord::Migration
def self.up
remove_index :delayed_jobs, :name => "delayed_jobs_priority"
add_index :delayed_jobs, [:failed_at, :priority, :run_at], :name => 'delayed_jobs_priority'
end
def self.down
remove_index :delayed_jobs, :name => "delayed_jobs_priority"
add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
end
@nilcolor
nilcolor / Node.js CORS
Created February 8, 2011 15:28
Node.js cross-origin POST. You should response for OPTIONS request first. Something like this.
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
gem 'koala'
gem 'resque'
@rakasaka
rakasaka / gist:1169341
Created August 24, 2011 21:45
Unsupervised topic modeling in Ruby using LDA
require 'lda-ruby'
corpus = Lda::Corpus.new
corpus.add_document(Lda::TextDocument.new(corpus, "a lion is a wild feline animal", []))
corpus.add_document(Lda::TextDocument.new(corpus, "a dog is a friendly animal", []))
corpus.add_document(Lda::TextDocument.new(corpus, "a cat is a feline animal", []))
lda = Lda::Lda.new(corpus)
lda.verbose = false
lda.num_topics = (2)
lda.em('random')
@nov
nov / fb_graph_logging.rb
Created September 2, 2011 03:42
FbGraph Logging
FbGraph.debug do
# all API requests by fb_graph gem will be logged within this block
FbGraph::User.new('matake').fetch
end
FbGraph::User.me('access_token').fetch # This won't be logged
FbGraph.debug! # all API requests by fb_graph gem will be logged after this line
FbGraph::Page.new('FbGraph').fetch
@phaze9
phaze9 / 01_functional_vs_OO.js
Created November 11, 2011 17:04
JavaScript Masterclass Homework
// Exercise 1 - OO || !OO
// Define a data structure for cars (make and color), and a function
// that logs a string like "I'm a red Mercedes" to the console.
// Make two versions: a functional version, and a object-oriented version.
var logCar = function(car) {
console.log("I'm a " + car.color + ' ' + car.make);
}
logCar({ color: 'blue', make: 'BMW' });