This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| targets = ['serverA', 'serverB', 'serverC', 'serverD', 'serverE', 'serverF'] | |
| index = 0 | |
| while True: | |
| print targets[index] | |
| index = (index + 1) % len(targets) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #recursion technique is always fascinating! | |
| def factorial(n): | |
| return 1 if (n < 1) else n * factorial(n-1) | |
| factorial(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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".. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Given a dictionary and a string, check if the string forms a proper sentence | |
| ''' | |
| thisisasentence -> True | |
| thisisnotasantance -> False | |
| ''' | |
| dictionary = set([ | |
| 'this', | |
| 'is', | |
| 'a', | |
| 'i', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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): |
OlderNewer