Skip to content

Instantly share code, notes, and snippets.

Avatar

Vencislav Atanasov user890104

View GitHub Profile
@user890104
user890104 / convert.php
Created Feb 13, 2019
Arduino MIDI nodejs stepper motor
View convert.php
<?php
if (
empty($_SERVER['argc']) || empty($_SERVER['argv']) ||
!is_int($_SERVER['argc']) || !is_array($_SERVER['argv']) ||
3 !== $_SERVER['argc'] || 3 !== count($_SERVER['argv'])
)
{
echo 'usage: ', $_SERVER['argv'][0], ' <input> <output>', "\n";
exit;
}
View MultiCurl.php
<?php
namespace User890104;
class MultiCurl {
private $multi_handle;
private $handles = [];
public function __construct() {
$multi_handle = curl_multi_init();
@user890104
user890104 / net.sh
Created Dec 10, 2018
Fix network on lxd
View net.sh
for cnt in $(lxc list --format csv --columns n)
do
GATEWAY_NUM=$(lxc exec $cnt -- bash -c 'route -n -A inet6 | grep -F "::/0" | grep -Fv "!n" | wc -l')
if [ $GATEWAY_NUM -eq 0 ]
then
echo restart network on $cnt
lxc exec $cnt -- netplan apply
fi
done
@user890104
user890104 / cert-production.sh
Created Jul 31, 2018
Certbot / Letsencrypt Wildcard DNS with nsupdate hook
View cert-production.sh
# This will issue a production (valid and trusted) certificate
certbot certonly --agree-tos --manual --preferred-challenge=dns --manual-auth-hook=./hook.sh --register-unsafely-without-email --manual-public-ip-logging-ok -d '*.example.com' -d 'example.com' --server https://acme-v02.api.letsencrypt.org/directory
@user890104
user890104 / spectre.c
Created Jul 31, 2018
Spectre example code
View spectre.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@user890104
user890104 / sw.js
Last active Jul 21, 2018
Service worker with cache
View sw.js
const cacheId = 'cache-v1';
function fetchAndCache(request, cache) {
return fetch(request).then(function(response) {
return cache.put(request, response.clone()).then(function() {
return response;
});
});
}
View poor_man_s_lxd_ftp_backup.sh
#!/bin/bash
log_dt() {
date '+%d.%m.%y %H:%M:%S'
}
DAY_OF_WEEK=$(date +%u)
if [ $DAY_OF_WEEK -eq 1 ]
then
View foodpanda-courier-tracking.js
// run in console
// enable popups for website first
if (!('lastLat' in window)) {
window.lastLat = 0;
}
if (!('lastLon' in window)) {
window.lastLon = 0;
}
setInterval(function() {
$.getJSON(location.href.replace('/tracking', '/status')).then(function(data){
View router-functions.sh
#!/bin/sh
ip_flip() {
if [ $1 -eq 4 ]
then
FIRST=$(echo $TUNNEL_IP | cut -d . -f 1-3).
LAST=$(echo $TUNNEL_IP | cut -d . -f 4)
fi
if [ $1 -eq 6 ]
View patch-shairport.sh
#!/bin/bash
set -e
BIN_NAME=shairport-sync
BIN_SRC=/usr/bin
BINARY="${BIN_SRC}/${BIN_NAME}"
PATCH_DIR=/tmp/shairport-patch
PATCH_BIN="${PATCH_DIR}/${BIN_NAME}"
PATCH_NAME="${PATCH_DIR}/string"