Skip to content

Instantly share code, notes, and snippets.

View libert-xyz's full-sized avatar
🗽
/dev/urandom

Libert Schmidt libert-xyz

🗽
/dev/urandom
View GitHub Profile
@libert-xyz
libert-xyz / dateAndtime.py
Created November 26, 2016 15:22
Date and Time manipulation in python
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)
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)
@libert-xyz
libert-xyz / webServer.py
Created September 22, 2016 14:18
small web server using python standard library
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()
import time
#Example of counting days to an event:
from datetime import date
today = date.today()
today
today == date.fromtimestamp(time.time())
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
@libert-xyz
libert-xyz / array_ex.rb
Created August 13, 2016 00:41
Ruby arrays
5.times {puts 'bizz buzz'}
beez by
beez by
beez by
beez by
beez by
=> 5
5.times do
#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
#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)
@libert-xyz
libert-xyz / designerDoor.py
Created August 1, 2016 16:32
A single line containing the space separated values of N and M.
#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,"-"))
@libert-xyz
libert-xyz / ec2simple.json
Created July 27, 2016 04:05
simple ec2 with a security group
{
"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",