Skip to content

Instantly share code, notes, and snippets.

@alpha123
alpha123 / Scenario.js
Last active December 16, 2015 02:49
Scenario 2.1, extended to support diagonal movement.
/* Scenario 2008-2009 Bruce Pascoe
Version 2.1
Scenario is an advanced cutscene engine for Sphere which allows you to
coordinate complex cutscenes via forks and synchronization.
*/
function Scenario ()
{
this.FadeMask = CreateColor(0,0,0,0);
this.FocusStack = [];
@alpha123
alpha123 / colorscheme.rb
Created November 7, 2013 22:29
Ruby script to switch colorschemes for the i3 window manager.
#!/usr/bin/env ruby
require 'yaml'
# colorscheme_dir is the directory where all the YAML color scheme files are stored,
# current_colorscheme is the path to a symlink to a file in that directory.
$colorscheme_dir = "#{ENV['HOME']}/colorschemes"
$current_colorscheme = "#{ENV['HOME']}/.colorscheme"
$i3_config = "#{ENV['HOME']}/.i3/config"
$i3_config_marker_start = "### Autogenerated by ~/scripts/colorscheme ###"
@alpha123
alpha123 / gist:8028402
Last active December 31, 2015 18:39
"Dependently-typed" JS thing
// Syntax note: optionally whitespace-sensitive, \ is an alias for function,
// and -> at the end of a function means return the last value.
// Haskell-style (operator), which is implicit if an operator is the only
// argument to a function.
// The return value of a type function is compared to the value put in,
// and if they are === it type checks.
function Int(n) -> Math.floor(n)
function add(a: Int, b: Int) -> a + b
@alpha123
alpha123 / gist:8044003
Created December 19, 2013 18:35
Metaprogramming in Io!
add := method(a, b, a + b)
getSlot("add") message setName("b")
getSlot("add") message next setName("-")
getSlot("add") message next argAt(0) setName("a")
# `add` now looks like
# method(a, b, b - a)
# Now I can't seem to get this part to work:
@alpha123
alpha123 / mal_grab.pl
Last active April 16, 2016 00:19
MAL Downloader
#!/usr/bin/env perl
use v5.16; # given/when
use strict;
use warnings;
use Getopt::Long::Descriptive;
use LWP::Simple;
use Mojo::DOM;
use Data::Dumper;
use Text::CSV::Slurp;
@alpha123
alpha123 / utility.hpp
Last active August 1, 2016 04:27
Magic C preprocessor stuff
#pragma once
#include <memory>
#include <utility>
/**
* 𝕬𝖇𝖆𝖓𝖉𝖔𝖓 𝖆𝖑𝖑 𝖍𝖔𝖕𝖊, 𝖞𝖊 𝖜𝖍𝖔 𝖊𝖓𝖙𝖊𝖗 𝖍𝖊𝖗𝖊
*
*
* You have been WARNED
@alpha123
alpha123 / wolfram30.hpp
Created August 8, 2016 05:32
Guts of a random number generator based on cellular automata
#pragma once
#include <inttypes.h>
#include <limits.h>
namespace w30 {
typedef uint64_t state;
typedef uint32_t uint;
@alpha123
alpha123 / ipa.rb
Created June 30, 2017 05:17
Ruby IPA parser
# encoding: utf-8
require 'rubygems'
gem 'ruby-enum'
gem 'unicode'
require 'ruby-enum'
require 'unicode'
module IPA
import { CourseHelpers } from '../CourseData';
import { Strategy, Aptitude } from '../HorseTypes';
import { Region } from '../Region';
import { Rule30CARng } from '../Random';
import { RaceSolver, SkillType, SkillRarity } from '../RaceSolver';
const base = {
speed: 1400,
stamina: 800,
power: 1000,
/**
* Use the PEXT instruction and perfect hash functions to store small integer maps
* inside a uint64_t (or smaller).
*
* Compile with `-Wno-multichar -mbmi2 -mlzcnt` (or -march=native on any recent x86 CPU).
*
* Modify `tbl` below to change the map.
*
* If it takes a long time and doesn't find a solution, fiddle with the hash function (`h`).
*