Skip to content

Instantly share code, notes, and snippets.

@Ruin0x11
Ruin0x11 / scrape.rb
Created September 20, 2019 02:16
Scrape Reaktor User Library
require 'mechanize'
require 'nokogiri'
require 'json'
require 'pp'
class String
def between marker
self[/#{Regexp.escape(marker)}(.*?)#{Regexp.escape(marker)}/m, 1]
end
end
@Ruin0x11
Ruin0x11 / csharp-mode-hacks.el
Last active February 25, 2019 20:46
Hack for csharp-mode for string interpolation
;; A hack for csharp-mode to highlight string interpolation expressions like $"{foo} {bar}". Adapted from ruby-mode.
(c-lang-defconst c-basic-matchers-after
csharp `(
;; ...
,`(csharp-match-expression-expansion
0 font-lock-variable-name-face t)
))
# usage: ruby compare.rb first.json second.json
# gnuplot is required.
# produce output.json by running:
# make clean
# make bench
# bin/ElonaFoobar --output json > output.json
require "json"
class Comparison
local Chara = Elona.require("Chara")
local Event = Elona.require("Event")
local Iter = Elona.require("Iter")
local Map = Elona.require("Map")
local function setup()
local player_pos = Chara.player().position
for pos in Iter.rectangle_iter(player_pos.x - 1, player_pos.y - 1,
player_pos.x + 1, player_pos.y + 1) do
if not (pos.x == player_pos.x and pos.y == player_pos.y) then
local Event = Elona.require("Event")
local Enums = Elona.require("Enums")
local Item = Elona.require("Item")
local Chara = Elona.require("Chara")
local GUI = Elona.require("GUI")
local table = Elona.require("table")
local potions = {736, 711, 706, 626, 577, 566, 559, 519, 433, 432,
429, 382, 379, 376, 375, 372, 370, 368, 364, 287, 286, 285, 262, 76,
75, 74, 72, 71, 70, 69, 68, 30, 29, 28, 27}
@Ruin0x11
Ruin0x11 / organize_samples.rb
Created October 1, 2017 18:10
Organize sound samples quickly
# Requires mpv.
require "optparse"
require "find"
require "pathname"
require "ostruct"
require "fileutils"
require "io/console"
def is_num?(str)
@Ruin0x11
Ruin0x11 / hlua_userdata.rs
Last active September 6, 2017 10:06
Reading back lua userdata by copy with hlua
#[macro_use] extern crate hlua;
mod point;
use std::fmt::{self, Display};
use hlua::Lua;
use point::Point;
@Ruin0x11
Ruin0x11 / .config
Created March 9, 2017 03:41
crux config
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.9.6 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
@Ruin0x11
Ruin0x11 / mpv-jisho.lua
Created December 12, 2016 01:56
Lookup current subtitle text in Jisho.org
function lookup_jisho()
local text = mp.get_property("sub-text")
if text == "" then
return
end
mp.set_property("pause", "yes")
os.execute("open \"http://jisho.org/search/" .. text .. "\"")
end
mp.add_key_binding("Ctrl+j", "lookup_jisho", lookup_jisho)
@Ruin0x11
Ruin0x11 / mpv-gif.lua
Last active March 26, 2024 01:01
Create animated GIFs using mpv
-- Create animated GIFs with mpv
-- Requires ffmpeg.
-- Adapted from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
-- Usage: "g" to set start frame, "G" to set end frame, "Ctrl+g" to create.
local msg = require 'mp.msg'
-- Set this to the filters to pass into ffmpeg's -vf option.
-- filters="fps=24,scale=320:-1:flags=lanczos"
filters="fps=15,scale=540:-1:flags=lanczos"