Skip to content

Instantly share code, notes, and snippets.

# Usage: Either sshcat host:file or sshcat host file
# handy as a drop-in replacement for normal cat in piped oneliners, etc.
sshcat() {
if [[ "$1" == *:* ]]; then
ssh "${1%:*}" "cat ${1##*:}";
else
ssh "$1" "cat $2";
fi
}
@Alloyed
Alloyed / result.sh-session
Last active August 29, 2015 14:02
memory usage
$ nodejs --version && lua -v && luajit -v
v0.10.28
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
$ nodejs --expose-gc test.js && lua test.lua && luajit test.lua
----
nodejs
----
1804856
@Alloyed
Alloyed / dwarfify.lua
Created December 7, 2014 00:22
Automatically gives dwarves nicknames
-- Automatically gives dwarves nicknames
local NICK_MAXLEN = 40
function get_dorfs()
local used_names = {}
local new_dorfs = {}
for _, u in ipairs(df.global.world.units.active) do
if dfhack.units.isCitizen(u) then
if u.name.nickname ~= "" then
used_names[u.name.nickname] = true
@Alloyed
Alloyed / aseprite.thumbnailer
Created February 19, 2016 05:32
Aseprite Thumbnailer
[Thumbnailer Entry]
TryExec=aseprite
Exec=sh -c "aseprite -b %i --scale 4 --save-as %o.gif && mv %o.gif %o"
MimeType=application/x-wine-extension-ase;application/x-extension-ase
local gold = true
this_is.gold = false
this_is = {
gold = true
}
call(gold)
path,  err = nfd.open(filter, init) -- lets you pick a single file
paths, err = nfd.openMany(filter, init) -- lets you pick multiple files
path,  err = nfd.save(filter, init) -- lets you save to a single file

where:

  • filter (string, optional): A weird DSL for filetypes you probably shouldn't emulate. it supports type subgroups (so like jpg files are "jpg,jpeg" and so on) but doesn't let you name them. defaults to all files.
  • init (string, optional): The initial path the file chooser should suggest. Normally this is a directory, but for save() you can suggest an initial filename like "/my/path/untitled.file". defaults to the working directory.
--- A log function that's compatible with lua's standard print function.
-- usage: print("hi", table, entity, 3.4) -- output: hi <table:0xdeadbeef> <userdata:0xeeeeeeee> 3.4
local function print(...)
local str, sep = "", ""
for i=1, select('#', ...) do
str = str .. sep .. tostring(select(i, ...))
sep = '\t'
end
return Isaac.DebugString(str)
end
#!/usr/bin/python3
"""Reads from argument the log file name. And displays it in real time.
The default log name is log.txt (which is correct if the script is launched
from the afterbirth folder itself)
It will read each line one after the other on an infinit loop.
If the file gets updated (ie: a line is added) it will display it and
lower the reading cooldown.
If nothing happen on the reading loop, it increase the reading cooldown.
--- Parseimg, v0.1
--
-- A library for turning love2d ImageData into high-level datastructures.
--
-- MIT License
--
-- Copyright (c) 2017 Kyle McLamb <alloyed@tfwno.gf>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
// itch api
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
struct ItchUser {
username: String,
display_name: String,
id: u32,
}
#[derive(Serialize, Deserialize, Debug)]