Skip to content

Instantly share code, notes, and snippets.

View cowlicks's full-sized avatar
💭
SEE TRANSLATION

cowlicks

💭
SEE TRANSLATION
View GitHub Profile
@cowlicks
cowlicks / git-split.sh
Last active July 23, 2019 18:14
split a git commit per file
#!/bin/bash
# to split all commits since origin/master run:
# git rebase --interactive --exec git-split.sh origin/master
set -e
LF=$'\n'
SHA=$(git rev-parse --short HEAD)
MSG=$(git show -s --format=%B HEAD)
set -f; IFS=$'\n'
@cowlicks
cowlicks / debug_python.py
Created June 27, 2019 22:32
verbose python logging for debugging
import logging
logging.basicConfig(format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d:%H:%M:%S',
level=logging.DEBUG)
logger = logging.getLogger(__name__)
@cowlicks
cowlicks / apollo_ws_subscription_graphql_auth.js
Last active May 16, 2020 03:19
Dynamic auth tokens for Websockets with Graphql Subscriptions
const subscriptionMiddleware = {
applyMiddleware: function(options, next) {
// Get the current context
const context = options.getContext().graphqlContext;
// set it on the `options` which will be passed to the websocket with Apollo
// Server it becomes: `ApolloServer({contetx: ({payload}) => (returns options)
options.authorization = context.authorization;
next()
},
};
@cowlicks
cowlicks / aquacointelpro.py
Last active April 8, 2019 17:26
Get the ph and orp value from an aquacointelpro 1. It prints the data as json to stdout
#!/usr/bin/env python
'''
This scripts needs the `pyserial` python package installed to run (`pip install pyserial`).
Usage:
>>> Aqua().get_ph_orp()
{'ph': 6.82, 'orp': 116.0}
'''
import serial
@cowlicks
cowlicks / git_aliases.md
Created January 25, 2019 19:28
git aliases
# An alias for: git add --patch && git commit
# It would be nice if there was an interactive way to bypass git hooks if they block the commit
git config --global alias.pac '!f(){ git add --patch && git commit; }; f'
@cowlicks
cowlicks / Dockerfile
Last active September 11, 2023 19:23
Safely share your SSH access while building a Dockerfile using socat to forward ssh-agent's SSH_AUTH_SOCK
FROM python:3-stretch
COPY . /app
WORKDIR /app
RUN mkdir -p /tmp
# install socat and ssh to talk to the host ssh-agent
RUN apt-get update && apt-get install git socat openssh-client \
# create variable called SSH_AUTH_SOCK, ssh will use this automatically
@cowlicks
cowlicks / stream.sh
Created September 30, 2018 05:13
Script to stream a ".webm" file to twitch.
INRES="1920x1080" # input resolution
OUTRES="1920x1080" # output resolution
FPS="15" # target FPS
GOP="30" # i-frame interval, should be double of FPS,
GOPMIN="15" # min i-frame interval, should be equal to fps,
THREADS="2" # max 6
CBR="1000k" # constant bitrate (should be between 1000k - 3000k)
QUALITY="ultrafast" # one of the many FFMPEG preset
AUDIO_RATE="44100"
STREAM_KEY="" # use the terminal command Streaming streamkeyhere to stream your video to twitch or justin
@cowlicks
cowlicks / tojson.py
Created September 26, 2018 20:43
create a json file from an exported keepassx text file
import json
file_name = 'VERY_SECRET.txt' # input filename
out_file_name = 'VERY_SECRET.json' # output filename
data_line_start = ('Title:', 'Username:', 'Url:', 'Password:', 'Comment:')
def make_part(title, username, url, password, comment):
'''
whatever.split(':') split the line into Whatever and data
This file has been truncated, but you can view the full file.
PLOVR_MODULE_INFO={"common-async":["base"],"pubs":["common-async"],"notes":["common-async"],"stats":["common-async"],"payments":["common-async"],"posters":["common-async"],"home-screens":["common-async"],"misc-screens":["common-async"],"hightower":["common-async"],"power-readers":["common-async"],"base":[]};
PLOVR_MODULE_URIS={"common-async":"fingerprint:common-async","pubs":"fingerprint:pubs","notes":"fingerprint:notes","stats":"fingerprint:stats","payments":"fingerprint:payments","posters":"fingerprint:posters","home-screens":"fingerprint:home-screens","misc-screens":"fingerprint:misc-screens","hightower":"fingerprint:hightower","power-readers":"fingerprint:power-readers","base":"fingerprint:base"};
PLOVR_MODULE_USE_DEBUG_MODE=false;
var _mdm={};(function(z){
'use strict';var ea,fa,aaa,ia,ha,daa,ma,faa,gaa,Ga,Oa,Na,oaa,paa,hb,qaa,raa,jb,saa,taa,Db,uaa,vaa,waa,xaa,Mb,Nb,Ob,Pb,Qb,yaa,ac,bc,gc,zaa,hc,ic,Baa,Aaa,lc,Caa,Dc,Daa,Ec,Qc,Tc,Xc,Yc,fd,Eaa,Lc,Faa,ed,$c,ad,id,Gaa,hd,pd,rd,yd,Fd,nd,qd,Id,qe,Jaa,Kaa,Laa,Ma
This file has been truncated, but you can view the full file.
/*! For license information please see reverb-f71130e851996ce67141.bundle.js.LICENSE */
webpackJsonp([0],[,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__extends=function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},r.d(t,"__assign",function(){return o}),t.__rest=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]]);return r},t.__decorate=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},t.__param=function(e,t){return function(r