Skip to content

Instantly share code, notes, and snippets.

View FGasper's full-sized avatar

Felipe Gasper FGasper

View GitHub Profile
@FGasper
FGasper / bootstrap-tls.md
Last active June 16, 2022 14:15
Bootstrapping TLS in various programming languages
Language TLS Library Root Store
Julia embedded mbedTLS static
node.js OpenSSL OpenSSL
Python OpenSSL OpenSSL
PHP OpenSSL OpenSSL
Go native static search paths
// To compile:
// cc -I./include mbedtls_test.c library/libmbedtls.a library/libmbedx509.a library/libmbedcrypto.a
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "mbedtls/net_sockets.h"
#include "mbedtls/ssl.h"
#include "mbedtls/entropy.h"
import zmq
ctx = zmq.Context()
pub = ctx.socket(zmq.PUB)
pub.bind("ipc://.zmq")
sub = ctx.socket(zmq.SUB)
sub.connect("ipc://.zmq")
sub.subscribe("")
pub.send_string("hi")
sub.recv_string()
@FGasper
FGasper / Promiser.pm
Last active September 17, 2019 12:51
Demonstration of promises-based wrapper around Net::Curl
# The base class; an implementation will extend this to support whatever event mechanism, e.g., epoll.
package Net::Curl::Promiser;
use strict;
use warnings;
use Promise::ES6 ();
use Net::Curl::Multi ();
@FGasper
FGasper / openrpc-uapi.json
Created June 12, 2019 02:37
OpenRPC demo of a UAPI call
{
"openrpc": "1.0.0-rc1",
"info": {
"title": "cPanel OpenRPC demo",
"version": "0.0.1-rc1"
},
"servers": [
{
"name": "cPanel encrypted",
"url": "http://{domain}:2083/{base_path}"
#!/usr/bin/env perl
use strict;
use warnings;
use v5.20;
use feature qw(signatures);
no warnings qw(experimental::signatures);
require Dumbbench; # use() causes breakage w/ perlcc.
BROADCAST_PORT = 65000
SDA, SCL = 3, 4
i2c.setup(0, SDA, SCL, i2c.SLOW) -- call i2c.setup() only once
bme280.setup()
function get_iso_time()
tm = rtctime.epoch2cal(rtctime.get())
timestr = string.format("%04d-%02d-%02dT%02d:%02d:%02dZ", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])
-- https://nodemcu.readthedocs.io/en/master/en/upload/
-- load credentials, 'SSID' and 'PASSWORD' declared and initialize in there
dofile("credentials.lua")
STARTED_BROADCAST=false
STARTED_RESTART_LISTENER=false
function startup()
if file.open("init.lua") == nil then
strace perl -Mautodie -MSocket -e'my $ip = `/bin/hostname -i`; chomp $ip; socket my $s, Socket::AF_INET, Socket::SOCK_STREAM, 0; my $addr = Socket::pack_sockaddr_in(0, Socket::inet_aton($ip) ); bind( $s, $addr ); getsockname($s); sleep'
@FGasper
FGasper / wscat.pl
Last active February 16, 2017 07:02
wscat (WebSocket netcat) implemented in Perl
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use Digest::SHA ();
use IO::Select ();
use IO::Socket::INET ();
use MIME::Base64 ();