Skip to content

Instantly share code, notes, and snippets.

View clamytoe's full-sized avatar
💭
Striving to learn something new each day.

Martin Uribe clamytoe

💭
Striving to learn something new each day.
View GitHub Profile
@clamytoe
clamytoe / hashit.py
Created April 29, 2017 00:31
Decorator samples, hashit for hashing passwords and boxit for drawing a box around some text. Created for PyBites Code Challenge 14.
from getpass import getpass
from functools import wraps
from os import system
from passlib.hash import pbkdf2_sha512
def hashit(func):
"""Decorator to securely hash passwords"""
@wraps(func) # preserves function meta data
@clamytoe
clamytoe / pyautotest.sh
Created April 29, 2017 09:48
Creates a python3 virtual environment and install any dependencies if the requirements.txt is found in the directory from which it is being executed.
#!/usr/bin/env bash
# it won't stay in the virtual env so you will
# have to activate the environment by hand:
#
# source venv/bin/activate
python3 -m venv venv
source venv/bin/activate
if [ -f "requirements.txt" ]; then
@clamytoe
clamytoe / steam.py
Last active May 16, 2017 23:41
steam.py
import os
import requests
from bs4 import BeautifulSoup
URL = "http://store.steampowered.com/feeds/newreleases.xml"
FILE = 'newreleases.xml'
USE_LOCAL = False
def read_file():
@clamytoe
clamytoe / PyBites.py
Last active June 4, 2017 18:02
PyBites.py
"""Written on iPhone with the Pythonista 3 app
As a joke for the PyBites guys, I don't see why it wouldn't work anywhere else though. They always
start off their newsletter annoucements with:
from @PyBites import newsletter
So I turned it into actual code that pulls their feed and opens their latest newsletter in a browser :)
"""
import os
@clamytoe
clamytoe / memModules.sh
Created September 13, 2017 12:27
One liner script to display the memory module(s) information of your system.
#!/bin/bash
sudo dmidecode | awk '/^Memory\ Device$/,/Size/{if ($0~/Size/)print}'
@clamytoe
clamytoe / ip_address.sh
Created September 13, 2017 12:42
Script to quickly check your active IP addresses.
#!/bin/bash
echo $(ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{print $1}')
@clamytoe
clamytoe / secret.py
Created October 19, 2017 03:00
secret.py
# secret message code challenge
# https://dev.to/rpalo/secret-message-7do
from string import ascii_lowercase
from long_string import code
ALPHA = ascii_lowercase + '_'
def count(letters):
counts = {}
@clamytoe
clamytoe / get_pid.sh
Created December 2, 2017 17:03
Scripts that I use to keep my Slack bot running if it gets disconnected.
#!/bin/bash
ps awxx | grep $1 | grep -v get_pid | grep -v grep | awk '{print $1}'
@clamytoe
clamytoe / fizzbuzz.py
Last active December 9, 2017 01:15
FizzBuzz challenge built with TDD...
def check_value(value):
"""
Validates the value that was passed into the program.
:param value: A positive integer is the only valid value
:return: int or an exception is raised
"""
if isinstance(value, bool):
raise ValueError
elif isinstance(value, str):
@clamytoe
clamytoe / hangman.py
Created January 26, 2018 11:26
hangman.py
from os import system, name
from time import sleep
from console import clear
# art from https://codereview.stackexchange.com/questions/101968/hangman-with-ascii
ascii_art = ("""
_________
|/
|