Skip to content

Instantly share code, notes, and snippets.

@metastable
metastable / QueryStringBuilder.cs
Last active January 27, 2021 03:53
PHP QueryStringBuilder in C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@metastable
metastable / sysctl.conf
Created December 4, 2020 10:16 — forked from kgriffs/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
#
# See also: https://gist.github.com/kgriffs/4027835
#
# Assumes a beefy machine with lots of network bandwidth
@metastable
metastable / register.js
Created November 3, 2020 06:08 — forked from thangman22/register.js
Workbox for Wordpress
async function addToCache(urls) {
const pageCache = await window.caches.open('page-cache');
await pageCache.addAll(urls);
}
// Check that service workers are registered
if ('serviceWorker' in navigator) {
// Use the window load event to keep the page load performant
window.addEventListener('load', () => {
addToCache(['/hello-world/', '/main-page/']);
@metastable
metastable / snowflake-id.sql
Created September 6, 2020 01:07 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@metastable
metastable / humhub-bootstrap.sh
Created March 5, 2020 20:54
setup script for humbug
#!/usr/bin/sh bash
#amzn linux2 humhub
export HOST_NAME=xxxxxxxx.staging.kiwamu.work
export HUMHUB_VERSION=1.4.3
export HUMHUB_DB_NAME='humhub'
export HUMHUB_DB_USER='humhub'
export HUMHUB_DB_PASSWORD='secret_password'
@metastable
metastable / wordpress-bootstrap.sh
Last active March 5, 2020 21:04
wordpress setup
#!/usr/bin/env bash
# wordpress Amazon Linux2
export OS_USER='ec2-user'
#export OS_PASSWORD=''
export TITLE='xxxxxxxx'
export URL='https://xxxxxxxx.staging.kiwamu.work'
export CN='*.xxxxxxxx.staging.kiwamu.work'
export ADMIN_USER='wpmaster'
export ADMIN_PASSWORD='secret_password'
export ADMIN_EMAIL='root@localhost.localdomain'
@metastable
metastable / mastdon-bootstrap.sh
Last active March 11, 2021 14:19
mastodon on AmazonLinux2
#!/usr/bin/env bash
echo "mastodon.example.com" | sudo tee /etc/hostname > /dev/null
sudo localectl set-locale LANG=en_US.UTF-8
sudo timedatectl set-timezone Asia/Tokyo
sudo tee /etc/sysctl.d/ipv4-tuning.conf << EOF
# Drop it so lack of FIN times out quicker
net.ipv4.tcp_fin_timeout = 30
# reuse TIME-WAIT sockets
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
@metastable
metastable / format-azure-vm-drive-d.ps1
Created February 28, 2019 09:26
Azure VM Drive D Format Script (SAMPLE)
#!/usr/bin/env powershell -File
# * Make sure you run this script from a Powershel Admin Prompt!
# * Make sure Powershell Execution Policy is bypassed to run these scripts:
# * YOU MAY HAVE TO RUN THIS COMMAND PRIOR TO RUNNING THIS SCRIPT!
Set-ExecutionPolicy Bypass -Scope Process -Force
wmic computersystem set AutomaticManagedPagefile=False
wmic pagefileset delete
Stop-Service -Name ShellHWDetection
@metastable
metastable / SqliteStorage.cs
Created November 26, 2018 06:52
BotBuider v4 SQLite Storage
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder;
using Microsoft.Data.Sqlite;
using Newtonsoft.Json;