Skip to content

Instantly share code, notes, and snippets.

@thoughtpolice
thoughtpolice / jj-signoff.sh
Last active June 25, 2024 01:51
my jjconfig.toml
#!/usr/bin/env bash
set -euo pipefail
NAME=$(jj config get user.name)
MAIL=$(jj config get user.email)
CID=$(jj log --no-graph -r @ -T "change_id" | sha256sum | head -c 40)
SIGNSTR="Signed-off-by: ${NAME} <${MAIL}>"
CHGSTR="Change-Id: I${CID}"
@wassname
wassname / running_stats.py
Last active November 14, 2023 15:09
Running stats (mean, standard deviation) for python, pytorch, etc
import numpy as np
# handle pytorch tensors etc, by using tensorboardX's method
try:
from tensorboardX.x2num import make_np
except ImportError:
def make_np(x):
return np.array(x).copy().astype('float16')
class RunningStats(object):
@crackcomm
crackcomm / output_shape_for.py
Created April 29, 2019 22:28 — forked from Erotemic/output_shape_for.py
Output shape information for pytorch
import math
import torch
import torch.nn as nn
import torchvision
REGISTERED_OUTPUT_SHAPE_TYPES = []
def compute_type(type):
def _wrap(func):
@cs8425
cs8425 / MSPCodes.js
Last active November 29, 2023 14:34
read 'USB Simulator Cable' as joystick and send to betaflight SITL via MSP over tcp.
// from https://github.com/betaflight/betaflight-configurator
'use strict';
//MSPCodes needs to be re-integrated inside MSP object
var MSPCodes = {
MSP_API_VERSION: 1,
MSP_FC_VARIANT: 2,
MSP_FC_VERSION: 3,
MSP_BOARD_INFO: 4,
MSP_BUILD_INFO: 5,
@sloanlance
sloanlance / Editing remote files in Vim with SSH.md
Created July 13, 2017 16:11
Editing remote files in Vim with SSH

Editing remote files in Vim with SSH

  1. Configure SSH

    In ~/.ssh/config, include the lines:

    Host *
    ControlPath ~/.ssh/sockets/%r@%h-%p
    
@simonw
simonw / recover_source_code.md
Last active June 21, 2024 00:11
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@application2000
application2000 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Last active May 23, 2024 07:53
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@bsantraigi
bsantraigi / arduino_ov7670.ino
Created March 30, 2016 20:14
OV7670 - Arduino Uno Interfacing
//
// Source code for application to transmit image from ov7670 to PC via USB
// By Siarhei Charkes in 2015
// http://privateblog.info
//
#include <stdint.h>
#include <avr/io.h>
#include <util/twi.h>
#include <util/delay.h>
@ocornut
ocornut / imgui_node_graph_test.cpp
Last active April 23, 2024 19:02
Node graph editor basic demo for ImGui
// Creating a node graph editor for Dear ImGui
// Quick sample, not production code!
// This is quick demo I crafted in a few hours in 2015 showcasing how to use Dear ImGui to create custom stuff,
// which ended up feeding a thread full of better experiments.
// See https://github.com/ocornut/imgui/issues/306 for details
// Fast forward to 2023, see e.g. https://github.com/ocornut/imgui/wiki/Useful-Extensions#node-editors
// Changelog
// - v0.05 (2023-03): fixed for renamed api: AddBezierCurve()->AddBezierCubic().
@Yawning
Yawning / orhttp_example.go
Created April 29, 2015 14:41
How to dispatch HTTP requests via Tor in Go.
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"