Skip to content

Instantly share code, notes, and snippets.

View siasur's full-sized avatar

Siasur siasur

  • Germany
View GitHub Profile
@siasur
siasur / ssh.gs
Created January 9, 2024 19:16
GrayHack, better ssh command tool
//Usages: ssh (user@)ip(:port) -p pass
// * ssh -p pass (user@)ip(:port)
// * ssh -h|-H|-?
//Notice: Do NOT replace your default ssh tool with this script if you make use of Map.exe
// Copyright notice: I've written it, you use it however you like, giving credits would be nice, but I don't require it.
// If you do improve it, I would love to know about it. But that too is not required.
usageHint = "<b>Usage: "+program_path.split("/")[-1]+" <i>(user@)</i>[ip]<i>(:port) (-p pass)</i></b>"
if params.len != 1 and params.len != 3 then exit("<color=#f00>"+usageHint+"</color>")
@siasur
siasur / string_splice.lua
Created May 29, 2020 01:43
Lua Splice strings
-- Copyright (c) 2020 Siasur
--[[
This lua function allows you to splice a string (value) into another string (base) at a given location (position) without changing its length.
I created this function for a now scrapped project but as I spent a long time figuring out how to do it I decided to make it a public gist.
If you need this functionality in your script you are free to use this code as it is.
]]
@siasur
siasur / update.sh
Created April 18, 2019 21:18
Update script for Factorio (I got this from somewhere online)
#!/bin/bash
python update_factorio.py --apply-to factorio/bin/x64/factorio -x -D
chmod +x factorio/bin/x64/factorio
@siasur
siasur / start.sh
Last active August 22, 2019 18:57
Factorio Server stuff
#!/bin/bash
if [ -f .factorio-lock ]; then
echo "Factorio Server is already running."
exit 1
else
touch .factorio-lock
fi
screen -Dm -S factorio ./watchdog & echo $! > .factorio-lock
@siasur
siasur / Scaffolding.cs
Created April 16, 2019 19:57
Grundgerüst für ein SE Script...
public void Main(string argument)
{
var groups = new List<IMyBlockGroup>();
GridTerminalSystem.GetBlockGroups(groups, selector => selector.Name.EndsWith("#Battery"));
foreach (var g in groups)
{
List<IMyReactor> reactors = new List<IMyReactor>();
g.GetBlocksOfType(reactors);
function math.clamp(val, min, max)
local step = math.max(val, min)
return math.min(step, max)
end
local roles = {
{ name = "Traitor", pct = 0.25, max = 6, minply = 0},
{ name = "Detective", pct = 0.17, max = 4, minply = 8},
{ name = "Jackal", pct = 1, max = 1, minply = 6}
}
public class MessageQueue<T> {
private static final int MAX_SIZE = 255;
private T[] messages;
private int lastReadIndex;
private int lastInsertIndex;
private int adjustIndex(int index) {
if (index >= MAX_SIZE) {
@siasur
siasur / HEX2Color.lua
Created April 27, 2016 08:42
Hex2Color Converter - Convert (extended) hexadecimal colors to its RGBA counterpart
-- Hex2Color Converter
-- Copyright (c) 2016 Mischa Behrend <https://github.com/siasur>
--[[
Dieses kleine Codesnippet konvertiert (erweiterte) Hexadezimalfarben in ihre entsprechenden RGBA Werte.
Erweitert bedeutet, dass die Hexadezimalwerte (vom Standard abweichend) um eine weitere Stelle für den
Alphakanal ergänzt werden dürfen. Die führende Raute kann bei bedarf weggelassen werden.
This little codesnippet will convert (extended) hexadecimal colors to its RGBA counterpart. Extended
means that you can (different to the default) append a fourth value for the alpha channel.
public class TsBotBootstrapper {
public static final TS3Config config;
public static TS3Query query;
public static TS3Api api;
public static TS3Listener listener;
public static void main(String[] args) {
config = new Ts3Config();
config.setHost("127.0.0.1");
@siasur
siasur / Russische Bauernmultiplikation.lua
Created November 5, 2015 08:58
Die Russische Bauernmultiplikation (auch Ägyptisches Multiplizieren, Abessinische Bauernregel oder Verdopplungs-Halbierungs-Methode genannt) ist ein einfaches Verfahren zur Multiplikation zweier natürlicher Zahlen.
local function Mul( --[[number]] _x, --[[number]] _y )
local result = 0
while ( _x >= 1 ) do
if ( _x%2 ~= 0 ) then
result = result + _y
end
_x = math.floor( _x / 2 )
_y = _y * 2
end
return result