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
| import datetime | |
| import pytz | |
| tday = datetime.date.today() | |
| bday = datime.date(2017,8,17) | |
| #Example1 | |
| #Time until my bday | |
| till_bday = bday - tday #timedelta object | |
| print(till_bday) |
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
| docker-machine create --driver amazonec2 --amazonec2-instance-type "t2.micro" --amazonec2-region "us-east-1" --amazonec2-security-group "myNetwork" --amazonec2-subnet-id "subnet-006b5859" --amazonec2-vpc-id "vpc-9611cef2" docker-test | |
| docker-machine ls | |
| docker-machine env docker-test | |
| # Run this command to configure your shell: | |
| # eval $(docker-machine env docker-test) |
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 BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
| class WebserverHandler(BaseHTTPRequestHandler): | |
| def do_GET(self): | |
| try: | |
| if self.path.endswith('/hello'): | |
| self.send_response(200) | |
| self.send_header('Content-type', 'text/html') | |
| self.end_headers() |
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
| import time | |
| #Example of counting days to an event: | |
| from datetime import date | |
| today = date.today() | |
| today | |
| today == date.fromtimestamp(time.time()) |
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
| CRUD Review | |
| Operations with SQLAlchemy | |
| In this lesson, we performed all of our CRUD operations with SQLAlchemy on an SQLite database. Before we perform any operations, we must first import the necessary libraries, connect to our restaurantMenu.db, and create a session to interface with the database: | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker | |
| from database_setup import Base, Restaurant, MenuItem |
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
| 5.times {puts 'bizz buzz'} | |
| beez by | |
| beez by | |
| beez by | |
| beez by | |
| beez by | |
| => 5 | |
| 5.times do |
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
| #08/3/16 | |
| #https://www.hackerrank.com/challenges/collections-counter | |
| from collections import Counter | |
| n = int(raw_input()) | |
| l = map(int,raw_input().split()) | |
| c = int(raw_input()) | |
| s = 0 |
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
| #8/1/16 | |
| #https://www.hackerrank.com/challenges/itertools-permutations | |
| from itertools import permutations | |
| s = raw_input().split() | |
| l = (permutations(sorted(s[0]),int(s[1]))) | |
| for i in l: | |
| print ''.join(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
| #08/1/16 | |
| #https://www.hackerrank.com/challenges/designer-door-mat | |
| N, M = map(int,input().split()) # More than 6 lines of code will result in 0 score. Blank lines are not counted. | |
| for i in range(1,N,2): | |
| print ((i*".|.").center(M,"-")) | |
| print ("WELCOME".center(M,"-")) | |
| for i in range(N-2,-1,-2): | |
| print ((i*".|.").center(M,"-")) |
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
| { | |
| "AWSTemplateFormatVersion" : "2010-09-09", | |
| "Description" : "Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen | |
| based on the region in which the stack is run. This example creates an EC2 security group for the instance | |
| to give you SSH access.", | |
| "Parameters" : { | |
| "KeyName": { | |
| "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", |