Skip to content

Instantly share code, notes, and snippets.

View Terrance's full-sized avatar
🚒
​The world is quiet here.

Terrance Terrance

🚒
​The world is quiet here.
View GitHub Profile
@Terrance
Terrance / DB.php
Created September 30, 2014 15:11
A simplified PHP wrapper for accessing a MySQL database, including debugging using Debug.php.
<?
include "Debug.php";
class DB {
private static $conn = null;
private static $prefix = "";
public static function connect($host="localhost", $user="root", $pass=null, $db=null) {
DB::$conn = mysqli_connect($host, $user, $pass, $db);
}
public static function setPrefix($newPrefix="") {
DB::$prefix = ($newPrefix ? $newPrefix : "");
@Terrance
Terrance / Debug.php
Created September 30, 2014 14:12
A lightweight PHP include to post and view debugging messages for a session. Call `Debug::start()` then `Debug::post("message", [0-3])`. View output by appending `?d` to the URL.
<?
class Debug {
const log = 0;
const success = 1;
const warning = 2;
const error = 3;
private static $init = false;
public static function start() {
session_start();
if (!$_SESSION["debug"]) {
@Terrance
Terrance / cert.sh
Last active September 22, 2017 19:58
A bash script to ease (re)generation of OpenSSL certificates.
#!/usr/bin/env sh
NEWROOT=0
GENROOTKEY=0
NEWCERT=0
GENCERTKEY=0
DAYS=3653
PFX=0
MERGE=0
@Terrance
Terrance / keybase.md
Created August 17, 2014 17:16
Keybase verification.

Keybase proof

I hereby claim:

  • I am OllieTerrance on github.
  • I am terrance (https://keybase.io/terrance) on keybase.
  • I have a public key whose fingerprint is A78E 9C1E 9514 4560 7BF0 77C8 645A 86C9 6168 F957

To claim this, I am signing this object:

@Terrance
Terrance / SteamMarketBuyNow.js
Created June 21, 2014 10:18
A snippet (using Prototype.js as available on the page) to instantly buy the top item in a Steam market listing. Can be used as a bookmarket.
$$(".item_market_action_button.item_market_action_button_green")[0].click();
$$("#market_buynow_dialog_accept_ssa")[0].checked = true;
$$("#market_buynow_dialog_purchase")[0].click();
@Terrance
Terrance / Wikipedia.css
Created May 21, 2014 15:38
CSS for Wikipedia (usable in e.g. Stylish) to hide the top and side bars in a thinner viewport, thus making more room for the actual article.
@media (max-width: 768px) {
div#content {
margin-left: 0;
border: none;
}
#mw-page-base, #mw-head-base, #mw-head, #mw-panel {
display: none;
}
}
@Terrance
Terrance / ActLogPubLikes.js
Last active January 24, 2016 09:07
A JavaScript snippet for removing likes on public statuses on Facebook. Operates on the mobile site (https://m.facebook.com/<you>/allactivity?log_filter=likes) by searching for lines with a "Public" tag. You need to expand times to search first.
// for all public tags
$(".sx_c87e68").each(function(i, e) {
// navigate up to the root of the item
var r = $(e).parent().parent().parent().parent().parent().next();
var id = r.parent().attr("id");
// open the dropdown
r.find("i").click();
// find the corresponding menu
$(".accelerate").find("a").each(function(j, l) {
if ($(l).data("store").domID == id) {
@Terrance
Terrance / IngressDualMap.user.js
Last active August 6, 2024 07:07
An IITC plugin that exports portals currently in view as a CSV list for use with Ingress Dual Map.
// ==UserScript==
// @id iitc-plugin-ingressdualmap-exporter@OllieTerrance
// @name IITC plugin: Ingress Dual Map Exporter
// @category Keys
// @version 0.0.0.1
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @description Exports portals currently in view as a CSV list for use with Ingress Dual Map.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@Terrance
Terrance / DateTimeView.java
Created September 28, 2013 10:17
An Android class that converts a text field and two buttons into a custom date/time picker field with set and clear buttons.
import java.util.Calendar;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.view.View;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
@Terrance
Terrance / SteamMarket.py
Created September 15, 2013 14:08
A small shell for checking Steam Market prices. Commands are `watch <url>` (add item to watch), `clear` (remove all watches), `get` (get prices), `quit`.
import json, re, shlex, urllib.request
watch = []
def getPrice(item):
listings = json.loads(urllib.request.urlopen(makeUrl(item)).read().decode("utf-8"))["listinginfo"]
lowest = None
for id, obj in list(listings.items()):
try:
price = obj["converted_price"]