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
# Silly little program to calculate my grades in Coursera's
# Programming for Everybody (Python)
__author__ = 'clamytoe'
from bs4 import BeautifulSoup
# global variable to hold all of the grades
class_grades = dict()
def parse_quiz():
@clamytoe
clamytoe / net_ops.py
Last active August 29, 2015 14:26
Little utility that I cooked up to convert numbers between binary, hex, and decimal. It also converts MAC address > to binary > to decimal.
__author__ = 'muribe'
"""
Little utility that I cooked up to convert numbers between binary, hex, and decimal.
If a MAC address in the following format is entered:
00-11-8a-2d-ff-ff
It returns the following binary:
@clamytoe
clamytoe / Week1-01.ipynb
Last active August 29, 2015 14:27
HKUSTx: COMP107x Introduction to Mobile Application Development using Android
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@clamytoe
clamytoe / download_images.py
Created August 21, 2015 15:20
While developing my memory game for a Python class, I was in need of some nice icon images. I scraped the image tags from http://snwh.org/paper/icons/ and saved them as paper_icons.html. I then wrote this script to download them...
import urllib2
fname = 'paper_icons.html'
handle = open(fname, 'r')
images = list()
count = 0
for line in handle:
line = line.rstrip()
tags = line.split()
@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)())
# linkedin Python Community
# Python the Hard Way, Lesson 20
# Sample code
from sys import argv
def print_all(f):
print(f.read())
@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
@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 / 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 / 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.
"""