Skip to content

Instantly share code, notes, and snippets.

View arnabc's full-sized avatar

Arnab Chakraborty arnabc

View GitHub Profile
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> CSS Border Radius madness </title>
<style>
.round {
margin: 100px;
width: 250px;
height: 100px;
@arnabc
arnabc / HTML5 Resources
Created November 18, 2010 06:25
List of HTML5 websites
http://www.html5rocks.com
http://slides.html5rocks.com
http://html5doctor.com
http://caniuse.com
http://html5reset.org
http://html5boilerplate.com
http://diveintohtml5.org
http://code.google.com/chrome/chromeframe/
@arnabc
arnabc / rails-auto-csrf-jquery.js
Created April 13, 2011 06:49
Rails authenticity token fix for non-idempotent XHR requests
// rails needs the authenticy_token param in non-idempotent request to protect from CSRF
var
// authenticity token name
AUTH_TOKEN_NAME = $( 'meta[name=csrf-param]' ).attr( 'content' ),
// authenticity token value
AUTH_TOKEN_VALUE = $( 'meta[name=csrf-token]' ).attr( 'content' );
// for each and every Ajax post request automatically append the 'authenticity_token' param
$( document ).ajaxSend( function ( event, xhr, settings ) {
// rails does not need the authenticity_token for GET requests
@arnabc
arnabc / gitosis-repo-creation
Created April 19, 2011 07:51
Gitosis repo creation ( it assumes that you have a working gitosis repository in a central server and have the permission to create new repositories)
~$ mkdir your_repo_name
~$ cd your_repo_name
~$ git init
~$ git remote add origin git@YOUR_SERVER_HOSTNAME:your_repo_name.git
# do some work, git add and commit files
~$ git add .
~$ git commit -m 'Your Message'
# push the new repo to central repository ( gitosis )
@arnabc
arnabc / gist:1026730
Created June 15, 2011 08:54
A pretty simple URL parser for Browser
// A Simple URL Parser, works in Browser only AFAIK, Please test before you use :-)
var Uri = ( function () {
var keys = ['host', 'hostname', 'protocol', 'pathname', 'search', 'hash', 'port'];
return {
// Method parses URI string and returns an object with parts name e.g. host, protocol
// @param {String} uri
parse: function ( uri ) {
@arnabc
arnabc / character_reference.rb
Created May 2, 2012 18:57 — forked from norman/character_reference.rb
HTML entities? We don't need no stinkin' HTML entities.
# coding: utf-8
#
# Encode any codepoint outside the ASCII printable range to an HTML character
# reference (http://bit.ly/KNupLT).
def encode(string)
string.each_codepoint.inject("") do |buffer, cp|
cp = "&#x#{cp.to_s(16)};" unless cp >= 0x20 && cp <= 0x7E
buffer << cp
end
end
@arnabc
arnabc / juggernaut_channels.rb
Created June 26, 2012 07:26 — forked from maccman/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@arnabc
arnabc / compress_requests.rb
Created September 22, 2012 16:18 — forked from relistan/compress_requests.rb
Rack Middleware to automatically unzip gzipped/deflated POST data
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
@arnabc
arnabc / cap_notify.rb
Created November 10, 2012 11:26 — forked from johnthethird/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
@arnabc
arnabc / cap_notify.rb
Created November 10, 2012 11:27 — forked from johnthethird/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.