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
<div class="form-group" ng-class="{ 'has-error' : productForm.product_name.$invalid && productForm.product_name.$dirty }"> | |
<label class="col-sm-2 control-label">Name</label> | |
<div class="col-sm-10"> | |
<input type="text" name="product_name" ng-model="product.name" class="form-control" placeholder="Product Name Here" required ng-minlength=5 ng-maxlength=60> | |
<div class="error" ng-show="productForm.product_name.$dirty && productForm.product_name.$invalid"> | |
<p class="help-block" ng-show="productForm.product_name.$error.required">Please input a product name</p> | |
<p class="help-block" ng-show="productForm.product_name.$error.minlength">The product name is required to be at least 5 characters</p> | |
<p class="help-block" ng-show="productForm.product_name.$error.maxlength">The product name cannot be longer than 60 characters</p> | |
</div> | |
</div> |
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
from __future__ import absolute_import, print_function | |
from tweepy.streaming import StreamListener | |
from tweepy import OAuthHandler | |
from tweepy import Stream | |
import json | |
import sys,os,time | |
print(sys.version) |
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
<!DOCTYPE html> | |
<html ng-app="ecommerceApp"> | |
<head lang="en"> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>E-commerce System</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> | |
<style> |
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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>MyAppName</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> | |
<style> |
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
require('mocha-generators').install(); | |
var Nightmare = require('nightmare'); | |
var nightmare = Nightmare({ show: true }) | |
nightmare | |
.goto('http://yahoo.com') | |
.type('input[title="Search"]', 'github nightmare') | |
.click('#UHSearchWeb') | |
.wait('#main') | |
.evaluate(function () { |
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
from ..location import Location | |
from nose2.tools.params import params | |
from datetime import datetime | |
# def test_temperature_of_a_new_location_class_should_be_None(): | |
# location = Location("PEN") | |
# assert location.temperature is None | |
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
def fibonacci(n): | |
assert(n >= 0), 'n must be >= 0' | |
return n if n in (0, 1) else fibonacci(n-1) + fibonacci(n-2) | |
if __name__ == '__main__': | |
from timeit import Timer | |
t = Timer('fibonacci(8)', 'from __main__ import fibonacci') | |
print(t.timeit()) |
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 Adapter: | |
def __init__(self, obj, adapted_methods): | |
self.obj = obj | |
self.__dict__.update(adapted_methods) | |
def __str__(self): | |
return str(self.obj) |
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
if __name__ == "__main__": | |
stock_watcher = Observable() | |
american_observer = AmericanStockMarket() | |
stock_watcher.register(american_observer) | |
stock_watcher.publish('KLSE Market Update', price='+0.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
def validate_age(name): | |
try: | |
age = raw_input('Welcome {}. How old are you? '.format(name)) | |
age = int(age) | |
except ValueError as err: | |
print("Age {} is invalid, please try again...".format(age)) | |
return (False, age) | |
return (True, age) |