Skip to content

Instantly share code, notes, and snippets.

View DavidJRobertson's full-sized avatar

David Robertson DavidJRobertson

View GitHub Profile
@DavidJRobertson
DavidJRobertson / stealify.js
Last active January 30, 2018 10:53
Stealify: pinch Spotify music! Run using node.js.
// Stealify
//
// A wee HTTP proxy to steal MP3 files from https://play.spotify.com
// By David Robertson
console.log("Stealify started! Instructions:");
console.log("1. Set http://localhost:8080 as your HTTP proxy");
console.log("2. Go to http://play.spotify.com in your browser and start playing music");
console.log("3. Wonder at all the stolen music appearing in this directory! Woo!");
console.log("Remember to reverse the HTTP proxy settings when you're done :P\n");
function separateLines (input, chars) {
var lines = [];
while (input.length > chars) {
var text = input.substr(0, chars);
var i = text.lastIndexOf(" ");
if (i == -1) {
i = chars - 1;
}
@DavidJRobertson
DavidJRobertson / FixAdventureMainClass.java
Created July 13, 2013 22:01
FixAdventure: bukkit plugin that prevents all block breaking/placement while in adventure mode.
package me.davidr.fixadventure;
import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.Listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
@DavidJRobertson
DavidJRobertson / cgol.rb
Last active August 29, 2015 13:58
Simple implementation of Conway's Game of Life
#! /usr/bin/env ruby
module LiveCell
def self.to_s
'o'
end
def self.next_generation(neighbours)
case neighbours.count(LiveCell)
when 2..3 then LiveCell
import Canvas
import string
import re
def pos_cmd(state, x, y):
state['pos'] = [int(x), int(y)]
def move_cmd(state, x, y):
pos = state['pos']
;-----------------------------------------------------------------------
; Sigma16 Program BarChart
;
; CS1Q Systems Exercise 1
; David Robertson 2133246R TU02/LB02
; 18 February 2015
;-----------------------------------------------------------------------
; Status Report
# David Robertson
# CS1P Lab Exam 2
import string, operator
def get_books(filename='books.txt'):
books_file = open(filename, 'r')
books_file_lines = books_file.readlines()
books_file.close()
@DavidJRobertson
DavidJRobertson / rtfm.h
Created October 20, 2016 15:42
GCC- error if not using c99
#if __STDC_VERSION__ < 199001L
#error DEAR MARKER: This program must be compiled in C99 mode - see instructions in report (-std=c99)
#endif
'NATASHA'S (TASHOLOGY) MYSQL SAVING SYSTEM!
'CHANGE THIS TO YOUR SETTINGS
Dim conn As String = "Server=epsilon.davidr.me;Database=tashdb;Uid=tashdb;Pwd=nLEYmTSYEQZzN483;"
Dim connect As MySqlConnection
Try
'Create the connector
connect = New MySqlConnection(conn)
'Open the database
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")