Skip to content

Instantly share code, notes, and snippets.

View nornagon's full-sized avatar

Jeremy Rose nornagon

View GitHub Profile
@nornagon
nornagon / app-switching.jsx
Last active June 12, 2017 01:38
Switching between apps based on state in Cycle.js
export function App(sources) {
const appSinks$ = sources.onion.state$
.startWith({name: null})
.map(state => state.name)
// drop repeats to prevent Main() being re-called every time the state changes
.compose(dropRepeats())
.map(name => {
if (name == null) {
return SetName(sources);
} else {
@nornagon
nornagon / 1-intro.md
Last active April 20, 2024 18:48
How to make a Minecraft (1.8) mod

How to make a Minecraft mod

Minecraft mods, especially mods which change the client, are by and large written with Forge. If you visit their website, you'll be greeted abruptly by a mysterious message at the top of an SMF forum, with no clear path towards actually... making a mod. I'm documenting here the steps I went through to get started, in the hopes of helping the next person have an easier time of it.

I'll be using Scala for this guide, but it should be fairly easy to adapt these instructions to any JVM language (e.g. clojure or if you're feeling masochistic, Java). I'm also developing on OS X, so some of the commands will be a little different if you're on Linux or Windows. I'm assuming you have some proficiency with your operating system, so I won't go into details about how to adapt those commands to your system.

Background

Minecraft doesn't have an official mod API (despite early [promises](http://notch.t

@nornagon
nornagon / README.md
Last active October 10, 2023 16:44
My disaster of a piece of software for making Medium auto-publish drafts older than 60 minutes

Pile of hacks to work around the fact that Medium's API doesn't give access to drafts. Hijacks Chrome's cookies to pretend to be you.

Usage:

  1. Put disaster.py somewhere.
  2. Edit net.nornagon.writedamnyou.plist so the second string in ProgramArguments points to where you put disaster.py.
  3. Put the net.nornagon.writedamnyou.plist file in ~/Library/LaunchAgents
  4. Run launchctl load ~/Library/LaunchAgents/net.nornagon.writedamnyou.plist

Probably it'll ask you for access to your keychain, since that's needed to decrypt Chrome's cookie store.

(defn sliding
([^long n] (sliding n 1))
([^long n ^long step]
(fn [rf]
(let [a (java.util.ArrayDeque. n)]
(fn
([] (rf))
([result]
(let [result (if (.isEmpty a)
result
@nornagon
nornagon / bug.json
Created September 29, 2014 04:57
boilerplate bug
{"71,23":"thinsolid","72,23":"thinsolid","73,23":"thinsolid","71,24":"shuttle","72,24":"shuttle","73,24":"thinsolid","71,25":"nothing","72,25":"shuttle","73,25":"thinsolid","74,25":"positive","75,25":"negative","76,25":"thinsolid","81,25":"thinsolid","82,25":"negative","83,25":"positive","72,26":"shuttle","73,26":"thinsolid","74,26":"thinsolid","75,26":"nothing","76,26":"nothing","77,26":"nothing","78,26":"nothing","79,26":"shuttle","80,26":"nothing","81,26":"nothing","82,26":"nothing","83,26":"thinsolid","70,27":"thinsolid","71,27":"shuttle","72,27":"shuttle","73,27":"thinsolid","70,28":"thinsolid","71,28":"nothing","72,28":"shuttle","73,28":"thinsolid","70,29":"thinsolid","72,29":"shuttle","73,29":"thinsolid","70,30":"thinsolid","71,30":"negative","72,30":"thinshuttle","73,30":"thinsolid","71,31":"positive","72,31":"shuttle","73,31":"thinsolid","72,32":"nothing","33,22":"thinsolid","45,24":"thinsolid","53,22":"thinsolid","33,26":"thinsolid","37,26":"thinsolid","37,22":"thinsolid","37,18":"thinsolid","33,18"
@nornagon
nornagon / orbitals.jl
Created September 29, 2014 01:02
Hydrogen orbitals in Julia
# Cribbed from http://commons.wikimedia.org/wiki/User:Geek3/hydrogen
function LegendreP(l, m, x)
m = abs(m)
a = 1
if m > 0
fac = 1
c = (1 + x) * (1 - x)
for i = 1:m
a *= c * fac / (fac + 1)
@nornagon
nornagon / Serializer.scala
Last active August 29, 2015 13:59
Serializer for squants.Quantity
object Serialization {
object UnitSerialization {
val unitForSymbol = Map(
"millisecond" -> Milliseconds,
"celsius" -> Celsius,
"kelvin" -> Kelvin,
"meter" -> Meters,
"nanometer" -> Nanometers,
"second" -> Seconds,
"minute" -> Minutes,
@nornagon
nornagon / corrupt.rb
Last active August 29, 2015 13:57
Corrupt random bits in a string
str = "Zalgo, he comes! He rises from the deep, he consumes us"
str.split(//).map { |char|
char.ord.to_s(2).split(//).map { |bit|
if rand < 0.01 then ["0","1"][(rand*2).floor] else bit end
}.join.to_i(2).chr
}.join
# => "Zalgo, he comes! He rises bRom the deep, `e conwumes us"
@nornagon
nornagon / keybase.md
Created March 17, 2014 05:45
keybase.md

Keybase proof

I hereby claim:

  • I am nornagon on github.
  • I am nornagon (https://keybase.io/nornagon) on keybase.
  • I have a public key whose fingerprint is 50BB 3434 E762 B0A9 F932 D08E 802A 9C12 D805 6B7C

To claim this, I am signing this object:

tag = (name, text, attrs) ->
parts = (name ? 'div').split /(?=[.#])/
tagName = "div"
classes = []
id = undefined
for p in parts when p.length
switch p[0]
when '#' then id = p.substr 1 if p.length > 1
when '.' then classes.push p.substr 1 if p.length > 1
else tagName = p