Skip to content

Instantly share code, notes, and snippets.

View bicepjai's full-sized avatar

Jayaram Prabhu Durairaj bicepjai

View GitHub Profile
@bicepjai
bicepjai / kmp.py
Created April 8, 2012 06:25
knuth morris pratt algorithm
#! /usr/bin/env python
# Description: Knuth-Morris-Pratt algorithm
__author__ = 'Jay <bicepjai@gmail.com>'
def prefix_table(p):
m = len(p)
pi = [0] * m
k = 0
@bicepjai
bicepjai / gist:1646075
Created January 20, 2012 08:08
link_to :method delete css :class issue
<%= link_to "delete me", :confirm => "Are you sure?", :method => 'delete', :class => "btn danger" %>
<%= link_to "edit me", edit_user_path,:confirm => "Are you sure?", :class => "btn info" %>
getting rendered as
<a href="/users/1?class=btn+danger&confirm=Are+you+sure%3F&method=delete">delete me</a>
<a href="/users/1/edit" class="btn info" data-confirm="Are you sure?">edit me</a>
using twitter bootstrap, class "btn danger" is not getting applied.
@bicepjai
bicepjai / gist:1630939
Created January 18, 2012 04:19
redirect_to rspec test error
class UsersController < ApplicationController
def new
@user = User.new
@title = "Sign up"
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to login_url, :notice => "Signed up!"
@bicepjai
bicepjai / bothaiyanaar.py
Created December 7, 2011 09:09
bothaiyanaar theorem
#! /usr/bin/python
import math
def pytha(a,b):
return math.sqrt(pow(a,2) + pow(b,2))
def botha(a,b):
return (float(a) - float(a/8) + float(b/2))