Skip to content

Instantly share code, notes, and snippets.

View dol's full-sized avatar

Dominic dol

View GitHub Profile
@dol
dol / chunked_encoding.lua
Created December 19, 2022 23:00
Chunked encoding in Lua
function chunked_encoding(socket, data)
local chunk_size = 1024
-- Iterate over the data in chunks of chunk_size
for i = 1, #data, chunk_size do
local chunk = data:sub(i, i + chunk_size - 1)
-- Calculate the length of the chunk in hexadecimal format
local length = string.format("%X\r\n", #chunk)
@dol
dol / get_script_path.sh
Created December 6, 2019 11:14
Get the path to the script
#!/usr/bin/env bash
function ostype() {
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
FROM httpd
RUN apt-get update && apt-get install -y \
wget \
automake \
build-essential \
ssl-cert \
&& rm -rf /var/lib/apt/lists/*
RUN make-ssl-cert generate-default-snakeoil
@dol
dol / cert.php
Created July 24, 2017 13:11
Create CSR with subjectAlternativeName and check and copy them to a signed certificate
<?php
require_once __DIR__ . '/vendor/autoload.php';
use X509\CertificationRequest\CertificationRequest;
use X509\CertificationRequest\Attribute\ExtensionRequestValue;
use X509\Certificate\Extension\SubjectAlternativeNameExtension;
use X509\GeneralName\DNSName;
use CryptoUtil\PEM\PEM;
@dol
dol / index.html
Created March 14, 2016 00:08
NW issue with 'new Image' on 0.12
<!DOCTYPE html>
<html>
<head>
<title>Hello Node Webkit</title>
</head>
<body>
<div id="my"></div>
<script>
var ctx = document.getElementById('my');
var image = new Image();
@dol
dol / csr.php
Last active August 13, 2020 08:20
PHP CSR with subjectAltName
<?php
$keyConfig = [
'private_key_type' => OPENSSL_KEYTYPE_RSA,
'private_key_bits' => 2048,
];
$key = openssl_pkey_new($keyConfig);
$sanDomains = [
'mydomain.tld',
@dol
dol / curl_ipv6.php
Created November 11, 2014 16:25
Curl + AWS IPv6 lookup test
<?php
# Requires PHP 5.5
$ch = curl_init("https://sqs.eu-central-1.amazonaws.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
if($errno = curl_errno($ch)) {
#!/usr/bin/make -f
#export DH_VERBOSE=1
CFLAGS ?= $(shell dpkg-buildflags --get CFLAGS)
LDFLAGS ?= $(shell dpkg-buildflags --get LDFLAGS)
WITH_SPDY := $(shell printf "Source: nginx\nBuild-Depends: libssl-dev (>= 1.0.1)\n" | \
dpkg-checkbuilddeps - >/dev/null 2>&1 && \
echo "--with-http_spdy_module")
%:
@dol
dol / cd_a_file.sh
Last active August 29, 2015 14:06
cd a file fix
# Never cd a file and get the warning it's no a directory
# Important to unset the variable for ZSH prompt
function cd() {
FORWARD_ARGS=()
for ARG in "$@"
do
case "$ARG" in
-L) FORWARD_ARGS+=("-L")
;;
-P) FORWARD_ARGS+=("-P")
@dol
dol / bug.php
Last active August 29, 2015 14:06
<?php
$content = <<<'EOF'
Line 1
Line 2
Line 3
Line 4
EOF;
$tmpCsvFile = new SplTempFileObject();