Skip to content

Instantly share code, notes, and snippets.

@dereckson
dereckson / has_IEC_559.c
Created Sep 17, 2021
__STDC_IEC_559__ detection
View has_IEC_559.c
int main(void) {
#if defined (__STDC_IEC_559__)
return 0;
#else
return 1;
#endif
}
View git-get-default-branch.sh
#!/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 Oct 1, 2020
Regenerate DockerHubBuildTriggers.json
View step1.js
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 Sep 5, 2021
Allow cmd.* to work on FreeBSD with runas
View salt-runas-freebsd.patch
--- 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 Sep 5, 2018
Example to run a Rocket server to serve some routes through Limiting Factor.
View app.rs
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 Mar 19, 2018
How to perform 14 * 10^-15?
View product.php
<?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 Mar 20, 2017
Code to parse a JSON document, decorate with relevant links and print a server log
View app.js
"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)
View gist:e4d184599de177f8a57539df59ae0889
Verifying that +dereckson is my blockchain ID. https://onename.com/dereckson
@dereckson
dereckson / proof.md
Last active Nov 20, 2016
Keybase proof
View proof.md

Keybase proof [36/90]

I hereby claim:

  • I am dereckson on github.
  • I am dereckson (https://keybase.io/dereckson) on keybase.
  • I have a public key whose fingerprint is 1E16 E1A7 0417 6257 76FA 944D 34A4 3097 536F 1E8D

To claim this, I am signing this object:

@dereckson
dereckson / Makefile
Last active Aug 29, 2015
Use of usleep to idle a thread and avoid full CPU core use.
View Makefile
all: idle-on idle-off
idle-on:
${CC} -DIDLE idle_test.c -o idle-on
idle-off:
${CC} idle_test.c -o idle-off
clean:
rm -f *.o idle-on idle-off