Skip to content

Instantly share code, notes, and snippets.

@dereckson
dereckson / idlerpg-check.tcl
Created February 27, 2024 02:37
Check if you're online on Idle RPG
#!/usr/bin/env tclsh8.6
# -------------------------------------------------------------
# IdleRPG client
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Description: Allow to query XML API from IdleRPG
# License: BSD-2-Clause
# Usage: idlerpg-check <player name>
# -------------------------------------------------------------
@dereckson
dereckson / reindent.sh
Created June 5, 2023 23:32
Allow to reindent a file, inline
#!/bin/sh
# -------------------------------------------------------------
# Reindent a file from x to y spaces
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: BSD-2-Clause
# Example: reindent 2 4 HelloWorld.vue
# -------------------------------------------------------------
@dereckson
dereckson / 01-parse-arguments-with-clap.rs
Last active January 5, 2023 02:02
Parse arguments in Rust with clap crate
use clap::Parser;
#[derive(Parser,Default,Debug)]
#[clap(author="Nasqueron project", version, about="Import FANTOIR database into PostgreSQL")]
struct Arguments {
/// Create table if it doesn't exist
#[arg(short = 'c')]
create_table: bool,
/// Truncate table if it already exists, allowing the overwrite mode.
@dereckson
dereckson / has_IEC_559.c
Created September 17, 2021 15:50
__STDC_IEC_559__ detection
int main(void) {
#if defined (__STDC_IEC_559__)
return 0;
#else
return 1;
#endif
}
#!/bin/sh
if [ $# -ne 0 ]
then
>&2 echo "Usage: $(basename "$0")"
exit 1
fi
REPO_PATH=$(git rev-parse --show-toplevel)
REPO_RETCODE=$?
@dereckson
dereckson / step1.js
Last active October 1, 2020 01:57
Regenerate DockerHubBuildTriggers.json
triggers = {};
(function () {
var s = document.createElement('script');
s.setAttribute('src', 'https://code.jquery.com/jquery-3.5.1.min.js');
document.body.appendChild(s);
}());
// Pause as we need jQuery object to be available, and so we need to let time to the browser to load the script
@dereckson
dereckson / salt-runas-freebsd.patch
Last active September 5, 2021 08:12
Allow cmd.* to work on FreeBSD with runas
--- modules/cmdmod.py.orig 2021-07-30 19:55:37.000000000 +0000
+++ modules/cmdmod.py 2021-09-05 07:59:54.531476000 +0000
@@ -69,9 +69,7 @@
log = logging.getLogger(__name__)
-DEFAULT_SHELL = salt.grains.extra.shell()["shell"]
-
# Overwriting the cmd python module makes debugging modules with pdb a bit
@dereckson
dereckson / app.rs
Created September 5, 2018 19:51
Example to run a Rocket server to serve some routes through Limiting Factor.
use limiting_factor::kernel::DefaultApplication;
use requests::*;
pub fn run () {
let routes = routes![
status,
favicon,
users::register,
users::get_player,
];
@dereckson
dereckson / product.php
Created March 19, 2018 11:51
How to perform 14 * 10^-15?
<?php
use Brick\Math\BigDecimal;
require 'vendor/autoload.php';
$left = BigDecimal::of(14);
$right = BigDecimal::one()->toScale(15)->dividedBy(BigDecimal::ten()->power(15));
$product = $left->multipliedBy($right);
@dereckson
dereckson / app.js
Created March 20, 2017 23:11
Code to parse a JSON document, decorate with relevant links and print a server log
"use strict";
/* -------------------------------------------------------------
Nasqueron infrastructure
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Project: Nasqueron
Author: Sébastien Santoro aka Dereckson
Dependencies: jQuery
Filename: app.js
Licence: CC-BY 4.0, MIT, BSD-2-Clause (multi-licensing)