Skip to content

Instantly share code, notes, and snippets.

@keepitsimple
keepitsimple / rancher-redeploy.sh
Last active October 3, 2019 12:57
Request rancher via API to redeploy pod
pod_upgrade_body=$(curl -u "token-[use your token here]" \
-s 'https://rancher.mydomain.com/v3/project/c-zqpm5:p-h884r/workloads/deployment:development:api' \
-X GET \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Cache-Control: no-cache' 2>&1 | sed "s/\"cattle\.io\/timestamp\"\:\"[0-9T:Z-]*\"/\"cattle\.io\/timestamp\":\"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"/g")
curl -u "token-[use your token here]" \
-s 'https://rancher.mydomain.com/v3/project/c-zqpm5:p-h884r/workloads/deployment:development:api' \
@keepitsimple
keepitsimple / run_postgraphile.sh
Created May 15, 2019 06:54
Run postgraphile locally without installation with "simplify" plugin
npx postgraphile --append-plugins /usr/lib/node_modules/@graphile-contrib/pg-simplify-inflector -c postgres://postgres:@localhost:8432/screenhub -s presentations --export-schema-graphql schema.graphql --watch
@keepitsimple
keepitsimple / gist:66faace10ddcfdd7ab7fb1d5fcc6a08d
Created April 28, 2019 19:27
Copy files via netcat & tar locally
From here: https://superuser.com/questions/326211/best-way-to-transfer-files-over-a-lan-between-two-linux-computers
My personal favorite for cases where security doesn't matter is netcat + tar:
To send a directory, cd to inside the directory whose contents you want to send on the computer doing the sending and do:
tar -cz . | nc -q 10 -l -p 45454
On the computer receiving the contents, cd to where you want the contents to appear and do:
@keepitsimple
keepitsimple / Dockerfile
Created April 23, 2019 12:12
Sqitch version 0.9999 for Postgresql
FROM debian:stable-slim AS sqitch-build
# Install system dependencies.
WORKDIR /work
ARG VERSION=0.9999
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 \
&& apt-get -qq update \
&& apt-get -qq install build-essential perl curl \
unixodbc-dev libpq-dev \
&& curl -LO https://www.cpan.org/authors/id/D/DW/DWHEELER/App-Sqitch-$VERSION.tar.gz \
@keepitsimple
keepitsimple / comment-nonpriv-users
Created December 20, 2018 13:41
Local script for Evercast
#!/usr/bin/env bash
sed -i 's/https:\/\/storage.googleapis.com\/kubernetes-release\/release\/v1.10.0\/bin\/linux\/amd64\//\t/' api/Dockerfile
sed -i 's/debug_level = 5/debug_level = 2/' janus/janus/etc/janus/janus.cfg
sed -i '/^RUN chown/ s/^#*/#/' api/Dockerfile
sed -i '/^USER node/ s/^#*/#/' api/Dockerfile
sed -i '/^USER node/ s/^#*/#/' frontend/Dockerfile
sed -i '/^RUN addgroup lowpriv/ s/^#*/#/' websocket-server/Dockerfile
sed -i '/ && adduser/ s/^#*/#/' websocket-server/Dockerfile
sed -i '/ && chown/ s/^#*/#/' websocket-server/Dockerfile
sed -i '/^USER lowpriv/ s/^#*/#/' websocket-server/Dockerfile
@keepitsimple
keepitsimple / gist:b2a3a61d89d4ac4a8e99e8426e346476
Created October 2, 2018 14:32
Allow insecure SSL certificates for localhost
chrome://flags/#allow-insecure-localhost
@keepitsimple
keepitsimple / daemon.json
Created August 13, 2018 16:08
docker config file optimal configuration for Linux 4.x
# from here: https://sandro-keil.de/blog/2017/01/23/docker-daemon-tuning-and-json-file-configuration/
{
"storage-driver": "overlay2",
"graph": "/var/lib/docker",
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "2"
},
@keepitsimple
keepitsimple / ip4.js
Last active August 8, 2018 14:40
JavaScript the best RegEx for IPv4 validation with test examples
const ip4RegEx = /^(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(\.(?!$)|$)){4}$/
/*
//valid
127.0.0.1
192.168.1.1
192.168.1.255
255.255.255.255
0.0.0.0
1.1.1.1
@keepitsimple
keepitsimple / tutorial.md
Created August 7, 2018 11:45 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@keepitsimple
keepitsimple / async_tor_proxy_sample.py
Last active March 18, 2025 15:06
aiohttp + aiosocks: async tor proxy example
import asyncio
import aiohttp
import aiosocks
from aiosocks.connector import ProxyConnector, ProxyClientRequest
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://icanhazip.com/') as resp: