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 / 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 / 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 / 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 / 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 / start_stop.py
Created April 27, 2017 12:45
Script that I use to start/stop processes at work.
#!/usr/bin/env python3.6
from sys import argv, exit
def start_stop(process):
"""Starts/Stops a process
It stops the process that is passed to it by killing it's process ID. If no
process ID is found, then the process is started.
"""
@clamytoe
clamytoe / getSerials.sh
Last active April 26, 2017 02:11
Script to get the serial number from the host and the monitor of our Unix machines at work.
#!/bin/bash
XORG=${1:-/var/log/Xorg.0.log}
HOSTNAME=`hostname -s`
SYSSERIAL=`sudo /usr/sbin/dmidecode -s system-serial-number`
#SHORTSERIAL=${SYSSERIAL%% *}
/usr/bin/awk -F": " '
BEGIN {
sys="'${HOSTNAME}'";
sysserial="'${SYSSERIAL}'";
@clamytoe
clamytoe / urldecode.py
Last active April 27, 2017 12:49
Removes escaped characters from any quoted string that's passed to it through the command line and prints out its different components.
#!/usr/bin/env python3
import sys
from os import system
from urllib.parse import unquote
def decode(url):
"""Decodes url encoded string"""
return unquote(url)
@clamytoe
clamytoe / fix_brightness.sh
Last active July 20, 2017 12:38
Hack I wrote to fix the brightness on my Linux Mint machine.
#!/bin/bash
me=`whoami`
max=`cat /sys/class/backlight/radeon_bl0/max_brightness`
sudo chown ${me}:${me} /sys/class/backlight/radeon_bl0/brightness
sudo chmod o+x /sys/class/backlight/radeon_bl0/brightness
ls -al /sys/class/backlight/radeon_bl0/brightness
echo ${max} > /sys/class/backlight/radeon_bl0/brightness
sudo chmod 444 /sys/class/backlight/radeon_bl0/brightness
sudo chown root:root /sys/class/backlight/radeon_bl0/brightness
# linkedin Python Community
# Python the Hard Way, Lesson 20
# Sample code
from sys import argv
def print_all(f):
print(f.read())
@clamytoe
clamytoe / Revealer.js
Created July 16, 2016 21:55
Bookmarklet code to reveal passwords on a web page.
javascript:void((function()%7Bvar%20a,b;b=%22%3C%22+%22html%3E%5Cn%3Cbody%3EPasswords%20in%20this%20page:%3Cp%3E%5Cn%22;(function(c)%7Bvar%20d,e,f,g,h;for(d=0;d%3Cc.length;d++)%7Btry%7Barguments.callee(c.frames[d]);%7Dcatch(i)%7B%7D%7De=c.document.forms;for(f=0;f%3Ce.length;f++)%7Bg=e[f];for(h=0;h%3Cg.length;h++)%7Bif(g[h].type.toLowerCase()==%22password%22)b+=g[h].value+%22%3Cbr%3E%5Cn%22;%7D%7D%7D)(top);b+=%22%3C/body%3E%5Cn%3C/html%3E%5Cn%22;a=window.open(%22%22,%22%22,%22width=200,height=300%22).document;a.open();a.write(b);a.close();%7D)())