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
#07/10/16
#https://www.hackerrank.com/challenges/find-a-string
s1 = raw_input()
s2 = raw_input()
tam = len(s2)
c = 0
for i in range(0,len(s1)):
if s1[i] == s2[0]:
#7/15/16
#https://www.hackerrank.com/challenges/text-alignment
ti = int(raw_input()) #an odd number
c = '@'
w = ' '
#Top
for i in range(ti):
@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",
@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,"-"))
#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)
#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
@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
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
import time
#Example of counting days to an event:
from datetime import date
today = date.today()
today
today == date.fromtimestamp(time.time())
@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()