Skip to content

Instantly share code, notes, and snippets.

'use strict'
const { resolve, extname } = require('path')
const http = require('http')
const fs = require('fs')
const PORT = process.env.PORT || 8080
const PUBLIC_PATH = 'public/' // place it directory, where you execute node
const MIME_TYPES = {
@kraftwerk28
kraftwerk28 / sync_vscode_settings.py
Created December 23, 2019 08:54
Script used to sync VSCode settings with gist
from os import getenv, path
import requests
from pprint import pprint
import json
from termcolor import colored
USERNAME = 'username'
TOKEN = 'your_github_app_token'
GHAPI = 'https://api.github.com'
GIST_ID = 'gist_id'
@kraftwerk28
kraftwerk28 / .gitignore
Last active May 30, 2020 13:59
Jordan-Gauss method
data/
test*/
iter*/
*.txt
__pycache__/
@kraftwerk28
kraftwerk28 / main.py
Created June 1, 2020 14:42
Keybr hack
#!/usr/bin/env python
# Run $('.TextInput-fragment').textContent in browser console
# Then run this script and copy-paste text from browser console to terminal.
# Script will Alt+Tab to browser so make sure it won't go to the wrong window.
import os
import time
import pyautogui as pag
import random
@kraftwerk28
kraftwerk28 / make_cert.sh
Last active July 5, 2020 13:42
Self-signed cert for local development w/ SSL. You will be able to use https://localhost:1234 instead of http, in simple words.
#!/usr/bin/env sh
tmp=${1:-ca-tmp}
mkdir -p $tmp
DEF_ROOT_NAME=RootCA
DEF_SRV_NAME=localhost
DEF_TERM=365
read -p "Name of root cert ($DEF_ROOT_NAME): " root
read -p "Name of server cert ($DEF_SRV_NAME): " srv
read -p "Certificates term in days ($DEF_TERM): " term

w/o quotes:

docker build -t ${APP_TAG} ${REPO_URL}#${BUILD_BRANCH} -f ${APP_DF_PATH}

w/ quotes:

docker build -t ${APP_TAG} "${REPO_URL}#${BUILD_BRANCH}" -f ${APP_DF_PATH}
#!/usr/bin/env sh
TOKEN="api-token"
master=${1:-"master"}
APIURL="https://api.github.com"
OWNER=$(git config --get user.name)
REPO=$(basename $(git rev-parse --show-toplevel))
git checkout -b master
git push origin master
curl -s -X PATCH "$APIURL/repos/$OWNER/$REPO" \
-d "{\"default_branch\":\"master\"}" \
#!/usr/bin/env sh
filepath=${1}
signature=${2:-"signature.txt"}
privkey=${3:-"private_key.pem"}
pubkey=${4:-"public_key.pem"}
binsgn="${signature}.bin"
openssl genrsa -out $privkey 2048
openssl rsa -in $privkey -pubout -out $pubkey
openssl dgst -sign $privkey \
use regex::Regex;
use rmpv::{decode::read_value, encode::write_value, Value};
use std::{net::TcpStream, path::PathBuf, sync::atomic};
macro_rules! rmp_vec {
() => (Value::Array(Vec::new()));
($($x:expr),+$(,)*) => (Value::from([$(Value::from($x)),+].to_vec()));
}
struct Client {
{-# LANGUAGE LambdaCase #-}
import Data.Char ( isDigit
, isSpace
)
data Op = Add | Sub | Mul | Div deriving (Eq, Show)
data Item a
= Value a