Skip to content

Instantly share code, notes, and snippets.

@tdeck
tdeck / title.bashrc
Created September 19, 2016 17:25
Title
function title() {
echo -n -e "\033]0;$1\007"
}
@tdeck
tdeck / upload.go
Created August 24, 2016 21:20
Square Connect item image upload in Golang
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@tdeck
tdeck / webstac_login.py
Last active August 3, 2016 04:50
Script to demonstrate logging into WebSTAC using Python Mechanize
import mechanize
import getpass
# Get through the "Log in" button
br = mechanize.Browser()
br.open("https://acadinfo.wustl.edu/WebSTAC_init.asp")
br.select_form(name="form0")
br.submit()
# Get past the onload redirect page
@tdeck
tdeck / preserver
Last active August 24, 2016 21:32
LifePreserver - Script to limit players' time on a minecraft server
#! /usr/bin/env python
# LifePreserver - Time limiting script for Minecraft servers
import sys
from subprocess import Popen, PIPE
from collections import Counter
from datetime import datetime
from pytz import timezone
from time import sleep
START_HOUR = 9
<?php
function uploadItemImage($url, $access_token, $image_file) {
$headers = ["Authorization: Bearer $access_token"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['image_data' => "@$image_file;type=image/jpeg"]);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@tdeck
tdeck / uploader.cs
Last active April 20, 2019 15:31
Example showing how to upload item images to the Square Connect API in C#
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.IO;
using System;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
static class ImageUploader
{
@tdeck
tdeck / gist:58bd5c1f86a27b212811
Created December 1, 2014 21:42
Brainfuck interpreter in bash
#! /bin/bash
# Brainfuck - Troy Deck
#############
# Constants #
#############
CELLS=500
###########
# Globals #