Skip to content

Instantly share code, notes, and snippets.

@renfredxh
renfredxh / parser.py
Created August 18, 2013 18:44
Scrape and print a site's HTML with python 3
from urllib.request import urlopen
from bs4 import BeautifulSoup
webpage = urlopen('https://www.google.com')
soup = BeautifulSoup(webpage)
print(soup.prettify())
@renfredxh
renfredxh / soupURL.py
Last active December 21, 2015 15:59 — forked from simonw/gist:104413
Turn a BeautifulSoup form in to url encoded fields and default values - useful for screen scraping forms and then resubmitting them
from urllib.parse import urlencode
def extract_form_fields(self, soup):
"Turn a BeautifulSoup form into url encoded fields and default values"
fields = ""
for input in soup.findAll('input'):
# ignore submit/image with no name attribute
if input['type'] in ('submit', 'image') and not input.has_attr('name'):
continue
@renfredxh
renfredxh / remind.py
Last active February 8, 2022 16:21
Set reminders via OSX terminal
#!/usr/local/bin/python3
# Make a new reminder via terminal script
# args: remind <title> <date> <time>
# example: remind clean 12/10/2012 10:00:00PM
import subprocess
import sys
from datetime import datetime, timedelta
# A apple script that creates a new reminder given a name date and time
OSASCRIPT = ('<<END\n'
@renfredxh
renfredxh / vforward.rb
Created July 9, 2014 15:25
Forward multiple ports from localhost to Vagrant
#!/usr/bin/env ruby
# Description: Forwards one or more ports from your localhost to a Vagrant VM
# via ssh. Useful for viewing multiple dev applications in Vagrant at once.
#
# Installation:
# $ mv vforward.rb /usr/bin/vforward
# $ chmod +x /usr/bin/vforward
#
# Usage: vforward [ports ...]
@renfredxh
renfredxh / 404.html
Created July 31, 2014 00:53
Matrix 404
<html>
<head>
<title>404</title>
<style>
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
@renfredxh
renfredxh / Dockerfile
Last active August 29, 2015 14:04
SRCTweb Dockerfile
############################################################
# Dockerfile to build SRCTweb flask application
# Based on Ubuntu
############################################################
# Instructions:
#
# Build: sudo docker build -t srctweb .
# Run: sudo docker run -p 8000:80 -i -t -d srctweb
#
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@renfredxh
renfredxh / Dockerfile
Created August 11, 2014 04:46
What's Open Docker file
############################################################
# Dockerfile to build What's Open Django App
############################################################
# Instructions:
#
# Note: You need to edit the empty string on the line that
# says "ENV SECRET_KEY" to be a secure random value.
#
# Any initialized data that needs to be imported should be
@renfredxh
renfredxh / watch.sh
Created September 13, 2014 04:36
Watch directory and evaluate command
#!/bin/bash
path="../grails-app"
command="grails compile"
chsum1=""
echo "Watching ${path} for changes"
while [[ true ]]
do
chsum2=`find ${path} -type f -exec md5sum {} \;`
@renfredxh
renfredxh / keybase.md
Last active August 29, 2015 14:07
Keybase Verification

Keybase proof

I hereby claim:

  • I am renfredxh on github.
  • I am renfredxh (https://keybase.io/renfredxh) on keybase.
  • I have a public key whose fingerprint is C33E B29E 79D7 B679 C3AC 9EB4 4896 719E C9F7 6CF3

To claim this, I am signing this object: