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 Nasa | |
| attr_accessor :valid_command | |
| attr_accessor :left_command | |
| attr_accessor :right_command | |
| attr_accessor :move_command | |
| attr_accessor :valid_direction | |
| attr_accessor :north_direction | |
| attr_accessor :south_direction |
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
| module ActiveAdmin | |
| module Views | |
| class Header < Component | |
| def build(namespace, menu) | |
| super(:id => "header") | |
| @namespace = namespace | |
| @menu = menu | |
| build_custom_nav_bar |
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
| __author__ = 'naim' | |
| #http://projecteuler.net/problem=1 | |
| def generateSum(rangeVal): | |
| sum = 0 | |
| for no in range(1, int(rangeVal)): | |
| if (no % 3 == 0) | (no % 5 == 0): | |
| sum += no | |
| return sum |
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
| __author__ = 'naim' | |
| class Stack: | |
| def __init__(self): | |
| self.items = [] | |
| def push(self, item): | |
| self.items.append(item) |
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
| __author__ = 'naim' | |
| class Queue: | |
| def __init__(self): | |
| self.items = [] | |
| def enqueue(self, item): | |
| self.items.insert(0, item) |
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
| __author__ = 'naim' | |
| def func_outer(outer_arg): | |
| print 'outer' | |
| def func_inner(inner_arg): | |
| print 'inner' | |
| return inner_arg + outer_arg | |
| return func_inner |
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
| __author__ = 'naim' | |
| def func1(): | |
| return 1 | |
| def func2(): | |
| return 2 | |
| my_funcs = {'a': func1, 'b' : func2 } |
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
| __author__ = 'naim' | |
| def iteration(): | |
| count = [0] # caution of scoping variable when it is immutable like count = 0, it will local scope for | |
| # iteration() so that used mutable data type like list | |
| def increment_value(): | |
| count[0] += 1 | |
| return count[0] | |
| return increment_value |
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
| __author__ = 'naim' | |
| class MyClass: | |
| def __init__(self): | |
| self.x = 1 | |
| self.my_hash = {'fname': ('n', 'a', 'i', 'm'), 'lname': 'rajib'} | |
| def getVal(self): | |
| return self.x |
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
| __author__ = 'naim' | |
| squares = [] | |
| squares.append(lambda n: n*n) # list have only one element and it's index is 0 and content is lambda! | |
| print squares[0](2) |
OlderNewer