Skip to content

Instantly share code, notes, and snippets.

View KeithHanson's full-sized avatar

Keith Hanson KeithHanson

View GitHub Profile
@KeithHanson
KeithHanson / output.txt
Last active April 18, 2024 15:02
2D physics simulation of 10 bodies, 5 at rest and 5 in motion, using clingo and ASP
┌─[user@linux-gpu] - [~] - [2024-04-18 09:54:56]
└─[0] <> clingo test.pl --out-ifs=\\n
clingo version 5.4.1
Reading from test.pl
Solving...
Answer: 1
position_x(1,0,0)
position_x(2,0,0)
position_x(3,0,0)
position_x(4,0,0)
@KeithHanson
KeithHanson / probably_dont_do_this.rb
Created June 23, 2020 00:43
Fun with rubyisms in SonicPi
# Welcome to Sonic Pi
bpm = 90
live_loop :reloader do
class Hello
def self.ping(context)
context.sample :elec_ping, amp: 0.3
end
end
sleep 0.1
@KeithHanson
KeithHanson / foodStartup.lua
Created November 29, 2017 09:36
A ComputerCraft Gist
os.loadAPI("tools/json")
trackingData = {}
function resetTrackingData()
trackingData = {}
trackingData.startingChickens = 576
trackingData.currentChickens = 576
trackingData.customers = {}
trackingData.resetTime = os.time()
@KeithHanson
KeithHanson / json.lua
Created November 29, 2017 08:16
A ComputerCraft Gist
------------------------------------------------------------------ utils
local controls = {["\n"]="\\n", ["\r"]="\\r", ["\t"]="\\t", ["\b"]="\\b", ["\f"]="\\f", ["\""]="\\\"", ["\\"]="\\\\"}
local function isArray(t)
local max = 0
for k,v in pairs(t) do
if type(k) ~= "number" then
return false
elseif k > max then
max = k
@KeithHanson
KeithHanson / matrix.lua
Created November 29, 2017 07:59
A ComputerCraft Gist
--(c) 2013 Felix Maxwell
--License: CC BY-SA 3.0
local fps = 8 --Determines how long the system will wait between each update
local maxLifetime = 40 --Max lifetime of each char
local minLifetime = 8 --Min lifetime of each char
local maxSourcesPerTick = 5 --Maximum number of sources created each tick
local sourceWeight = 0 --Affects the chance that no sources will be generated
local greenWeight = 8 --Threshhold out of 10 that determines when characters will switch from lime to green
local grayWeight = 2 --Same as about, but from green to gray
@KeithHanson
KeithHanson / gist.lua
Created November 29, 2017 07:53
A ComputerCraft Gist
-- Load a helper script to decode JSON from github
os.loadAPI("tools/json")
-- This fancy {...} thing means all of
-- the command line arguments passed in
-- gist get url would produce "get" in position 1
args = {...}
-- The command the user is trying to run
-- should be "put" or "get"
@KeithHanson
KeithHanson / startup.lua
Created November 29, 2017 07:36
A ComputerCraft Gist
term.setBackgroundColor(colors.red)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1,1)
print("DEBUG BOOT PROCESS:")
print("This script is used to load other startup scripts")
print("")
@KeithHanson
KeithHanson / passwordStartup.lua
Created November 29, 2017 07:31
A ComputerCraft Gist
userInput = ""
correctPassword = "potato"
function resetScreen(backgroundColor, textColor)
term.setBackgroundColor(backgroundColor)
term.setTextColor(textColor)
term.clear()
term.setCursorPos(1,1)
end
@KeithHanson
KeithHanson / google_hack.twinenginelabs-annotated.html
Last active May 5, 2017 17:11
This HTML file is the original source code, modified only by Twin Engine Labs comment blocks.
<script>
/*************************************************************************
* ANNOTATION BY TWIN ENGINE LABS:
* See blog post here: https://www.linkedin.com/pulse/developers-look-google-docs-phishing-attack-its-keith-hanson
*************************************************************************/
</script>
<html>
<head>
<script type="text/javascript">
function getCookie(name) {
# boring stuff...
shell zsh
defutf8 on
startup_message off
vbell off
term xterm-color
# I use ` instead of ^-a as my screen command. You do have to be careful, though,
# to remember to hit ` twice to enter one (say, for shelling out in config.ru), and
# just pasting something with `'s is bad. You can use the binding set up below (`])