Skip to content

Instantly share code, notes, and snippets.

@jaredkc
jaredkc / git-cheat-sheet.md
Last active September 25, 2017 17:03
GIT Cheat Sheet

Git Cheat Sheet

Branches

Delete remote branch: git push origin :<branchName>

Add a remote branch: git remote add <remoteName> <gitAddress>

@pdostal
pdostal / GPG cheat sheet
Created March 1, 2014 03:40
GPG cheat sheet
$ gpg --gen-key
# 1) RSA and RSA (default)
# RSA keys may be between 1024 and 8192 bits long.
# You can set 'default-key $ID' in ~/.gnupg/gpg.conf
$ gpg --list-keys
$ gpg --list-secret-keys
$ gpg --export -a $ID > gpg-pubkey.asc
$ gpg --keyserver keys.gnupg.net --send-keys $ID
@raineorshine
raineorshine / bash-cheatsheet.sh
Last active April 4, 2018 18:45
Bash Cheat Sheet
type git # get the type of any command. Great for
# seeing if a command exists.
ls -t # sort by time, newest first
ls -tr # sort by time, oldest first
grep -r "test" FILE_OR_DIR # recursive full text search
grep -i "test" FILE # case insensitive
grep -c "pattern" FILE # count
grep -n "pattern" # show line numbers
@praeclarum
praeclarum / CSharpPredictor.fs
Created July 19, 2018 17:48
Predicts then next C# tokens given a history of previous tokens using CoreML on iOS with F#
// Given previous tokens, predict the next token (and runners up)
let predictNextToken (previousKinds : SyntaxKind[]) : Prediction[] =
if ios11 then
let model : MLModel = model.Value // Load the cached model
let mutable predictions : Prediction[] = [| |]
// RNNs require external memory
let mutable lstm_1_h : MLMultiArray = null
let mutable lstm_1_c : MLMultiArray = null
@bhepple
bhepple / i3-move-resize.py
Last active November 17, 2018 09:15
i3-move-resize.py
#!/usr/bin/python3
# lives at: https://gist.github.com/bhepple/5c43e83e945a42297ba6433ee8ba88ce
# derived from: https://github.com/benkaiser/i3-wm-config
# $0 x y width height (-1 for unchanged)
import subprocess
import sys
import json
<!-- $Header: /cvsroot/autodoc/autodoc/html.tmpl,v 1.4 2006/05/16 19:01:27 rbt Exp $ -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Index for synapse</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
BODY {
# To use this, you need Python 3.5+ and pip.
#
# 1. Make a new Discord app with a bot. https://discordapp.com/developers/applications/
#
# 2. Set environment variable SIMPLEWORDS_TOKEN on your computer to the bot's Token.
# Unix/Mac: export SIMPLEWORDS_TOKEN=MzABCDefghIJKLmnopQRSTuv.EnZ3kg.b5bdD74CKCr3du679hkemGJ7R7N
# PowerShell: $env:SIMPLEWORDS_TOKEN='MzABCDefghIJKLmnopQRSTuv.EnZ3kg.b5bdD74CKCr3du679hkemGJ7R7N'
#
# 3. Invite the bot to your server: https://stackoverflow.com/a/37743722/257418
#
@andrewchambers
andrewchambers / gist:1c473fd1595f4fcedbcfc634ee1decb0
Last active March 19, 2020 00:41
full disk encrypted nixos install
#! /bin/sh
set -e
set -u
set -x
# configure this!
hostname="nixos"
password="abc123"
diskdev=/dev/sda
@lynn
lynn / frac.rs
Last active March 19, 2020 15:35
A bitwise-magic fractional part function
/// A "fractional part" function on f32s that does bitwise magic
/// on the representation of its argument.
pub fn frac(f: f32) -> f32 {
f32::from_bits(_frac(f.to_bits()))
}
/// A "fractional part" function that operates on a signed integer
/// representation of an IEEE single-precision floating point number.
fn _frac(i: u32) -> u32 {
// A floating point number consists of a sign bit,
@keyboardcrunch
keyboardcrunch / pydocexec.py
Created April 30, 2020 02:24
Injects a python script inside a word document so the doc can be executed with python :)
#!/usr/bin/python3
import sys
import os
import zipfile
import tempfile
from xml.etree import ElementTree
from shutil import copyfile
def stuffer(py_file, doc_file):