Skip to content

Instantly share code, notes, and snippets.

@tcyrus
tcyrus / snowflake-id.sql
Last active May 25, 2021 09:20 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE IF NOT EXISTS public.snowflake_id_seq
MINVALUE 0 MAXVALUE 1023
CYCLE;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
-- 41 bits for time in milliseconds
-- (41 years of IDs from epoch)
-- 13 bits for the logical shard ID
-- 10 bits for the global auto-incrementing sequence (modulus 1024).
-- This means we can generate 1024 IDs, per shard, per millisecond
@tcyrus
tcyrus / gist:0261a761f388d70c0ec583306b939ed6
Created September 19, 2020 16:24
GitHub Verification using keys.pub
BEGIN MESSAGE.
cHN7wExcEmylXDi 7suT7bNcw6LiOOz EJfkUwKl2Dz7hRL BlBBqDyzxCoV8fM
wAoqc3gjCt9sEGO 6hFUVNHcv9nTCKq 6Xr2MZHgg4hDMLs RMRua7hdnEiFHgv
D5jAVUVl5RbYTwU j0pURo79upsTgDn 0EKvJyEjsIyLdQo gZRqNvPRqQqRgZ1
iMwiNGUB6dm5vCI WeWrFyJQIIoRXlZ rdBnW21.
END MESSAGE.
@tcyrus
tcyrus / caffe-to-coreml-to-onnx.py
Created May 15, 2020 00:25
Potential way to Create ONNX models for waifu2x
# This should be able to convert the pre-trained models from lltcggie/waifu2x-caffe to ONNX
# Based on the onnx converter script:
# https://github.com/onnx/onnx-docker/blob/master/onnx-ecosystem/converter_scripts/caffe_coreml_onnx.ipynb
import os
import coremltools
import onnxmltools
models_dir = 'waifu2x-caffe/models/'
@tcyrus
tcyrus / motd.conf
Last active June 6, 2019 19:40
nginx config for my MOTD sites (who needs a status page when you can have a dummy page)
server {
listen 80;
listen [::]:80;
server_name paff.tcyr.us;
access_log off;
error_log off;
return 301 https://$host$request_uri;
}
server {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tcyrus
tcyrus / main.js
Last active December 13, 2018 22:16 — forked from risacher/main.js
glue to make blessed (low-level API) work in browserify with xterm.js
const blessed = require("blessed");
window.onload = function () {
const term = new Terminal({
cols: 80,
rows: 24
});
term.open(document.body);
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
@tcyrus
tcyrus / standard_files.yml
Last active December 17, 2019 02:49
An attempt to standardize the Standard Files API (OpenAPI3)
openapi: 3.0.0
info:
version: "1.0.0"
title: "Standard File"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
servers:
- url: https://app.standardnotes.org/
@tcyrus
tcyrus / plugin.py
Created April 26, 2017 17:32
Sigil CleanOPF for Python 3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# target script
import sys
import string
import uuid
import re
if (!Element.prototype.getElementByTagName) {
Element.prototype.getElementByTagName = function(selector) {
return this.getElementsByTagName(selector).item(0);
}
}
if (!HTMLDocument.prototype.getElementByTagName) {
HTMLDocument.prototype.getElementByTagName = function(selector) {
return this.getElementsByTagName(selector).item(0);
}
}
import csv
import urllib.request
with urllib.request.urlopen('http://weather.unisys.com/hurricane/atlantic/tracks.atl') as response:
fileA, fileB, fileC = open('typeA.csv', 'wt'), open('typeB.csv', 'wt'), open('typeC.csv', 'wt')
csvA, csvB, csvC = csv.writer(fileA), csv.writer(fileB), csv.writer(fileC)
csvA.writerow(['Card Number', 'Date', 'Days', 'Storm Number', 'Total Storms', 'Name', 'US Hit', 'Hi US Category'])
csvB.writerow(['Card Number', 'Date',
'Stage - 00Z', 'Latitude - 00Z', 'Longitude - 00Z', 'Wind - 00Z', 'Press - 00Z',
'Stage - 06Z', 'Latitude - 06Z', 'Longitude - 06Z', 'Wind - 06Z', 'Press - 06Z',