Skip to content

Instantly share code, notes, and snippets.

#SingleInstance Force
#MaxHotkeysPerInterval 99999
#IfWinActive ahk_class DarkSouls2
; AHL script to remove input lag from DarkSouls2 PC, and add hotkeys for
; Guard break / Jump Attack
;
; Current settings (some can be easily changed)
; LMB / RMB = normal attacks
; Shift + LMB / RMB = strong attacks
@nathanic
nathanic / markov.rs
Last active August 29, 2015 14:03
silly markov text generator (baby's first rust program)
extern crate serialize;
extern crate time;
// use std::str;
// use std::rand;
use std::io::{File, BufferedReader};
use std::collections::TreeMap;
use serialize::{json, Encodable, Decodable};
#[deriving(Decodable, Encodable, Show)]
@nathanic
nathanic / number_trivia.clj
Created August 6, 2014 15:27
Number Trivia plugin for Bitsbot
(ns lazybot.plugins.number-trivia
(:use [lazybot registry]
[lazybot.utilities])
(:require [clj-http.client :as client]))
; http://numbersapi.com/
; from API docs:
;;; Just hit http://numbersapi.com/number/type to get a plain text response, where
;;; type is one of trivia, math, date, or year. Defaults to trivia if omitted.
;;; number is
@nathanic
nathanic / dice.clj
Created February 15, 2015 22:49
bitsbot dice plugin
(ns lazybot.plugins.dice
(:use lazybot.registry)
(:use lazybot.utilities)
(:require [clojure.string :as string])
(:require [instaparse.core :as insta])
(:require [clojure.core.match :refer [match]]))
; parser expects input like
; "3d20 + 2d4 + 10"
; and produces a list of structures like
@nathanic
nathanic / gist:1214725
Created September 13, 2011 19:01
jasmine BDD example
describe("Player", function() {
var player;
// hook before each test
beforeEach(function(){
player = new Player();
spyOn(loading,'show'); // intercept and record calls to loading.show
player.play();
});
// actual specifications/tests
@nathanic
nathanic / knight.clj
Created May 10, 2012 14:26
knight's random walk
;; http://www.johndcook.com/blog/2012/05/08/a-knights-random-walk/
;;
;; Start a knight at a corner square of an otherwise-empty chessboard. Move the
;; knight at random by choosing uniformly from the legal knight-moves at each
;; step. What is the mean number of moves until the knight returns to the
;; starting square?
(def MAXPOS 7)
; (pos, move) -> pos
@nathanic
nathanic / ants.py
Created August 2, 2012 16:51
ants sorting woodchips in space
#!/usr/bin/env python
""" This is a simulation of ants moving woodchips around
using the pyscape classes. Hopefully it demonstrates the
construction of central clusters using only decentralized
algorithms followed by autonomous agents.
We begin with a scattering of woodchips across the grid.
Ants randomly walk around, following a simple rule:
if you see a woodchip:
@nathanic
nathanic / reverseStdin.hs
Created August 31, 2012 01:05
Explanatory version of the line-reversing Haskell one-liner
-- a more verbose and explanatory version of this one-liner
-- main = interact $ unlines . map reverse . lines
-- we're going to use some library functions:
-- lines :: String -> [String]
-- unlines :: [String] -> String
-- reverse :: [a] -> [a]
-- reverse works on arbitrary lists, and Strings are [Char].
-- let ... in allows you to bind names to values,
@nathanic
nathanic / quine.hs
Created September 4, 2012 20:34
triple quine in three languages!
nathan@hugin:~/p/haskell/tidbits$ cat quine.hs
q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']
main=q "q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']" "def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'" "def e(x) return 34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q '+e(b)+' '+e(c)+' '+e(a)+' '+10.chr end"
nathan@hugin:~/p/haskell/tidbits$ runghc quine.hs
def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'
q("def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'","def e(x) return 34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q '+e(b)+' '+e(c)+' '+e(a)+' '+10.chr end","q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']")
@nathanic
nathanic / tsalesp.py
Created October 2, 2012 14:10
Simulated Annealing in Python in the early aughties
#!/usr/bin/env python
import random
from math import *
# This is an attempt at solving the travelling salesperson problem
# with simulated annealing. I tried this once in matlab and it sucked.
# a map is a list of tuples, one tuple for each city.
# each tuple represents the (x,y) location of a city on the map.