Skip to content

Instantly share code, notes, and snippets.

View sysr-q's full-sized avatar
💾
Hacking the planet.

Chris sysr-q

💾
Hacking the planet.
  • Auckland, New Zealand
  • 18:57 (UTC +12:00)
View GitHub Profile
@sysr-q
sysr-q / all_the_small_things.md
Last active October 12, 2015 10:08
For all the little things I forget to do.

This is for all of the little things I forget to do even though I shouldn't.

Make firefox default x-www-browser

  • Unpack firefox in /opt
  • # update-alternatives --install /usr/bin/x-www-browser x-www-browser /opt/firefox/firefox 100

Resize the damn root LVM

  • Boot into a LiveCD
@sysr-q
sysr-q / gist:4528632
Last active December 11, 2015 02:09
Explanation of some Python stuff for a guy on a forum.

THIS IS FOR YOU, Aura.

So, you said you want a file like this?

1-1234-60
2-23456-70
3-345678-80

These are your level, exp, whatever respectively.

@sysr-q
sysr-q / gist:4620588
Created January 24, 2013 11:53
Clone of MySQL Boy's installation guide for Python-MySQLdb.

MySQLdb is a Python wrapper around _mysql written by Andy Dustman. This wrapper makes it possible to interact with a MySQL Server performing all sorts of DDL and DML statements. I began my Python journey recently and stumbled at the installation of the MySQLdb module install. I was keen not to jump at an apt/yum installation as we have servers that have no outbound connections I decided I wanted to build the module from source.

You can download the MySQLdb files from SourceForge (70kb)

When downloaded you need to prep before your system is ready to build the file. Here are some prerequisites that will make life easier for you. I performed this particular install using an Ubuntu 10.04 64bit OS.

Before you start ensure you have the following installed (MySQL isn't actually required but for local Python development it's nice to have a database server to develop against!)

  • MySQL Server. I used the MySQL Community Server Version 5.1.49
  • gcc - The GNU Compiler
@sysr-q
sysr-q / simple_json_status.py
Last active December 17, 2015 00:49
This just queries the bloocoin server periodically and returns JSON info.
from flask import Flask, jsonify
import threading
import socket
import time
app = Flask(__name__)
_timer = 60 * 5
_timeout = 3
@sysr-q
sysr-q / python_ruiners.md
Last active December 17, 2015 07:39
What better thing to do with Python projects than ruin them for other people?

Python Ruiners

Here are some quick and easy ways to ruin Python scripts with only a few lines. Note, not all of them are Pythonic!

Of course, they only work if people are bad and use if this == True, or if this is True.

--

@sysr-q
sysr-q / whatever.py
Created June 15, 2013 09:53
Generate on-the-fly QR codes, and send them out via Flask.
# -*- coding: utf-8 -*-
from flask import Flask, send_file
import qrcode
from StringIO import StringIO
app = Flask(__name__)
@app.route("/qr/<path:url>")
@app.route("/qr")
def qr_route(url="http://dongcorp.org"):
@sysr-q
sysr-q / gist:5882877
Created June 28, 2013 06:33
Horrible, I know. Don't judge me.
import struct, socket, csv
def ip_to_decimal(ip):
return struct.unpack("!I", socket.inet_aton(ip))[0]
def read_list(ip_csv="/tmp/IpToCountry.csv"):
""" Read the entire IpToCountry CSV file into life.
:param ip_csv: the file we're reading from
@sysr-q
sysr-q / gist:5887248
Last active December 19, 2015 02:59
;; require'd [digest] and [base64-clj.core :as base64]
; This excessively large string is an SSH RSA key.
; You're meant to base64 decode then hash the result to get a key fingerprint.
(def k "AAAAB3NzaC1yc2EAAAADAQABAAABAQDt6wSbWhx/lQ1kqzqy4ET7ogSZqZngcDzaYiS8/ZWKgamkt4o9+2RebcysJT2DX/8t0Mif3jovSsUjW+6dCLY8rO0+fGMctwWL4HqAlHFgWY6xA2M4/ZLYvlm53WUKt02ygFeO9M4Fj9w9MoTRhQjS52Z6PA5OE0ppjjupvLWUp3wu23usUUWQucye50mTPBE4tZAbnh+H3w7FXTHOROsNTSuNbDYQ8pPqHy66hbJ5t2Dz5/3yTpL6mzc4rFHJPt5O8Wxlur4kzNSYlhPYsbrDoZF4lpxjdrkrE4qGxJUk48Hufr/VJ+3cafLumk7DsdVNnDeAO8lgpgXh2Hvr9ZYl")
(digest/md5 (base64/decode k)) ; => 8befc4d6d025ea89bd5603ea2bf7ecdd
; My question is this: in any other language, the above gives an output of:
; 287893e77d820df340d92b833e942128
; I've tested (independently and together) both the md5 and base64 functions, to verify that they're not cocking up the output and spewing out random crap, but they're giving valid info
@sysr-q
sysr-q / shrinky-dinky.clj
Created June 29, 2013 01:31
Random junk I throw together in Clojure.
(def in "5d41402abc4b2a76b9719d911017c592")
(def res "5d:41:40:2a:bc:4b:2a:76:b9:71:9d:91:10:17:c5:92")
; python => ':'.join(a+b for a,b in zip(a[::2], a[1::2]))
; (clojure.string/join ":" (map (fn [x] (clojure.string/join "" x)) (partition 2 s)))
(defn md5 [x] x)
(defn hash-to-fingerprint [k]
(defn shrink [x] (clojure.string/join "" x))
(clojure.string/join ":"
(map shrink (partition 2 (md5 k)))))
(= (hash-to-fingerprint s) res)
@sysr-q
sysr-q / blah.css
Created September 14, 2013 09:40
Get rid of that stupid "seen" chat 'feature' of Facebook.
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("facebook.com") {
div.seen {
visibility: hidden !important;
}
div._510g {
height: 12px;
}
}