Skip to content

Instantly share code, notes, and snippets.

const zbug = (...args: any[]) => {
const stack = ((new Error).stack?.split('\n') as any[])
.map((line: string) => line.substring(line.lastIndexOf('/') + 1));
const _args: any[] = [...stack?.slice(2,3), ...args];
// @ts-ignore
return _debug('node-raspberrypi-usbboot')(..._args);
}
FROM ubuntu
RUN apt-get update
RUN apt-get install -yqq apt-utils
RUN apt-get install -yqq vim
# # device tree
RUN apt-get install -yqq i2c-tools
RUN apt-get install -yqq device-tree-compiler
# dtc -I fs /sys/firmware/devicetree/base > cur.dts
@zwhitchcox
zwhitchcox / sbc-imx8-no-wp.dts
Created January 19, 2022 14:30
etcher pro device tree
/dts-v1/;
/ {
compatible = "compulab,sbc-imx8\0compulab,cl-som-imx8,rev1.1\0compulab,cl-som-imx8\0fsl,imx8mq";
interrupt-parent = <0x01>;
#address-cells = <0x02>;
#size-cells = <0x02>;
model = "CompuLab CL-SOM-iMX8 rev1.1 on SBC-iMX8";
cpus {
@zwhitchcox
zwhitchcox / console.log.js
Created August 18, 2020 18:08
Console.log variables and names without retyping in Javascript
// Simple Public Service Announcement
// You can add variables to your variables on console.log
// by using the es6 shorthand
```js
console.log({variable})
```
// I just realized that
@zwhitchcox
zwhitchcox / gist:82be19a9ba281737baf01d258914335f
Created December 26, 2019 21:34
keyboard shortcuts vscode
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
"when": "editorTextFocus"
},
{
"key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup",
@zwhitchcox
zwhitchcox / tmux-cheatsheet.md
Last active October 9, 2019 04:01 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zwhitchcox
zwhitchcox / install-vim-with-python
Last active September 13, 2019 01:42
Bash Script to Install Vim With Python Support
#!/bin/bash
PY2_CONFIG_DIR=$(sudo find /usr/lib -type d -regex ".*python2.[0-9]/config[^/]*")
PY3_CONFIG_DIR=$(sudo find /usr/lib -type d -regex ".*python3.[0-9]/config[^/]*")
if ( [ -d "$PY2_CONFIG_DIR" ] || [ -d "$PY3_CONFIG_DIR" ] ) ; then
py2_arg="--with-python-config-dir=$PY2_CONFIG_DIR"
py3_arg="--with-python3-config-dir=$PY3_CONFIG_DIR"
fi
@zwhitchcox
zwhitchcox / go-exercise-web-crawler.go
Created September 20, 2018 19:40
Go Exercise: Web Crawler
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
Fetch(url string) (body string, urls []string, err error)
}
@zwhitchcox
zwhitchcox / force-kill
Created June 11, 2018 13:06
Force kill process by port in one command
#!/bin/bash
# force kill process by port
# Usage: "force-kill PORT"
sudo netstat -tulnp | grep "$1" | sed -r -e "s/.*LISTEN\\s+([0-9]+).*/\1/" | xargs sudo kill -9
@zwhitchcox
zwhitchcox / git-total-lines.sh
Last active June 10, 2018 03:12
show total amount of lines added or removed from git repository without yarn.lock or package-lock.json
# total lines removed
git log --numstat --pretty="" | grep -v lock | sed -r -e "s/^([0-9]+)\\s+([0-9]+).*/\2/" | grep -v "^-" | paste -sd+ | bc
# total lines added
git log --numstat --pretty="" | grep -v lock | sed -r -e "s/^([0-9]+)\\s+([0-9]+).*/\2/" | grep -v "^-" | paste -sd+ | bc
# the main thing to edit would be git log. You could change this to whatever author you like or over
# whatever time frame or between two commits, etc. The `grep -v lock` removes all files like yarn.lock
# or package-lock.json, which is the main reason I created this command, because those files added like 40,000
# line changes to my code. Also the `grep -v "^-"`removes `png` files and such that are not countedl