Skip to content

Instantly share code, notes, and snippets.

View lightscalar's full-sized avatar

Matthew J. Lewis lightscalar

View GitHub Profile
@lightscalar
lightscalar / autobike.md
Last active June 16, 2021 20:30
Building an AutoBike

Building an AutoBike

Set Up a Raspberry Pi

Install Raspian

Download the latest Raspian here. Burn the image to an SD card using Etcher.io or similar.

Configure the Pi's Wifi Network

We wish to set up the Raspberry Pi as a WiFi hotspot. In the boot sector of the image,

@lightscalar
lightscalar / debounce.md
Created April 1, 2020 21:16
Debounce for API calls based on key up.
function debounce(callback, wait) {
  let timeout;
  return (...args) => {
      const context = this;
      clearTimeout(timeout);
      timeout = setTimeout(() => callback.apply(context, args), wait);
  };
}
@lightscalar
lightscalar / hotspot.md
Last active January 24, 2020 16:46
Setting up Raspberry Pi as hotspot!
  1. Burn Buster image onto SD card.
  2. Navigate to /Volumes/boot
  3. Create a file called wpa_supplicant.conf
  4. Put this in it...
country=US # Your 2-digit country code
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_NETWORK_NAME"
@lightscalar
lightscalar / postgresql.md
Last active November 12, 2019 15:34
Postgresql commands

To start and stop the database server:

pg_ctl -D /usr/local/var/postgres start
pg_ctl -D /usr/local/var/postgres stop

To create and drop a database:

@lightscalar
lightscalar / do_this.md
Last active August 13, 2019 22:25
Can't connect to GitHub after setting up your SSH keys?

The simplest solution for password-less git access would be to use the git remote set-url command and set an SSH url for the existing repo.

git remote set-url origin [email protected]:name/repo

Then you should be able to git push origin without being asked for a password.

@lightscalar
lightscalar / .profile
Last active July 7, 2018 21:23
Minimal .profile to configure things the way I like 'em...
# Command line prompt should be reasonable.
export PS1="$\w> "
# Reasonable coloring of directories, etc.
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# added by Anaconda3 5.2.0 installer
export PATH="/Users/mjl/anaconda3/bin:$PATH"
@lightscalar
lightscalar / .tmux.conf
Last active July 21, 2018 14:11
Basic .tmux.conf file — good for working with vim
set -g status-keys vi
setw -g mode-keys vi
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
@lightscalar
lightscalar / .vimrc
Last active July 24, 2019 15:07
Latest .vimrc
" Here are the basics.
map Q <Nop>
if has('python3')
silent! python3 1
endif
imap jk <ESC>
" nnoremap <Leader>w <ESC>:w<CR>
set number
set relativenumber
set shell=bash\ -l " vim shell should behave like my usual shell.
@lightscalar
lightscalar / ffmpeg.md
Last active March 13, 2018 14:39
Grabbing frames and creating movies...

To grab frames from a video:

ffmpeg -y -i "xdfo.wmv" -qscale 0 -r 30 "./xdfo/xdfo.%05d.jpg" 

To do the reverse, to generate a movie from a sequence of frames:

ffmpeg -f image2 -r 30 -i img.%04d.png -vb 20M -vcodec mpeg4 -y movie_filtered.mp4
" Here are the basics.
imap jk <ESC>
" nnoremap <Leader>w <ESC>:w<CR>
set number
set relativenumber
set shell=bash\ -l " vim shell should behave like my usual shell.
set noswapfile " Get rid of these things; big problems.
map <Leader>] :noh <CR>
map <Leader>[ :StripWhitespace <CR>
map <Space>w :w <CR>