Skip to content

Instantly share code, notes, and snippets.

View svalleru's full-sized avatar

Shan Valleru svalleru

View GitHub Profile
@svalleru
svalleru / gist:3838536
Created October 5, 2012 07:23
Installing Bootstrap for Ruby on Rails Project
# Installs bootstrap gem
Step:1 (Install bootstrap on your machine)
$ sudo gem install twitter-bootstrap-rails
Successfully installed twitter-bootstrap-rails-2.1.3
1 gem installed
Installing ri documentation for twitter-bootstrap-rails-2.1.3...
Installing RDoc documentation for twitter-bootstrap-rails-2.1.3...
@svalleru
svalleru / gist:3838540
Created October 5, 2012 07:24
Installing Bootstrap for Ruby on Rails Project
# Installs bootstrap gem
Step:1 (Install bootstrap on your machine)
$ sudo gem install twitter-bootstrap-rails
Successfully installed twitter-bootstrap-rails-2.1.3
1 gem installed
Installing ri documentation for twitter-bootstrap-rails-2.1.3...
Installing RDoc documentation for twitter-bootstrap-rails-2.1.3...
@svalleru
svalleru / gist:3838541
Last active June 23, 2016 00:08
Installing Bootstrap for Ruby on Rails Project
# Installs bootstrap gem
Step:1 (Install bootstrap on your machine)
$ sudo gem install twitter-bootstrap-rails
Successfully installed twitter-bootstrap-rails-2.1.3
1 gem installed
Installing ri documentation for twitter-bootstrap-rails-2.1.3...
Installing RDoc documentation for twitter-bootstrap-rails-2.1.3...
@svalleru
svalleru / InfiniteRoundRobin.py
Last active October 16, 2015 19:40
InfiniteRoundRobin
targets = ['serverA', 'serverB', 'serverC', 'serverD', 'serverE', 'serverF']
index = 0
while True:
print targets[index]
index = (index + 1) % len(targets)
@svalleru
svalleru / RingBuffer.py
Last active October 16, 2015 19:40
RingBuffer
class RingBuffer:
def __init__(self, size):
self.data = [None for i in xrange(size)]
def append(self, x):
self.data.pop(0)
self.data.append(x)
def get(self):
return self.data
@svalleru
svalleru / RecursiveFactorial.py
Last active October 16, 2015 19:40
RecursiveFactorial
#recursion technique is always fascinating!
def factorial(n):
return 1 if (n < 1) else n * factorial(n-1)
factorial(5)
#Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the
#multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz"
for i in xrange(1, 101):
if i % 15 == 0: #L.C.M of 3 & 5
print "FizzBuzz"
elif i % 3 == 0:
print "Fizz"
elif i % 5 == 0:
print "Buzz"
@svalleru
svalleru / PalindromeCheck.py
Last active October 16, 2015 19:39
PalindromeCheck
# Check if a string is palindrome or not
# Ignore all non-letter characters in the string and check should be case-insensitive
#"a"
#"ABba"
#"..a..a"
#"A man, a plan, a canal, Panama!"
#"amanaplanacanalpanama"
#"amanap"..
@svalleru
svalleru / SentenceCheck.py
Last active October 16, 2015 19:39
SentenceCheck
#Given a dictionary and a string, check if the string forms a proper sentence
'''
thisisasentence -> True
thisisnotasantance -> False
'''
dictionary = set([
'this',
'is',
'a',
'i',
@svalleru
svalleru / BinarySum
Created May 18, 2015 21:36
BinarySum
# Given two input binary strings, calculate their sum
s1 = '1'
s2 = '1101'
s1l = list(s1)[::-1]
s2l = list(s2)[::-1]
# Padding
if len(s1l) < len(s2l):
s1l = s1l + ['0'] * (len(s2l) - len(s1l))
elif len(s2l) < len(s1l):