Skip to content

Instantly share code, notes, and snippets.

View rsperl's full-sized avatar

Richard rsperl

  • North Carolina, United States
View GitHub Profile
@rsperl
rsperl / .inputrc
Last active July 25, 2022 14:15
use vi-mode in mysql #nosnippet
# needed for vi-mode in mysql
set editing-mode vi
@rsperl
rsperl / installation_notes.md
Last active July 25, 2022 13:56
installing tmux with libevent #snippet

install libevent first

When compiling tmux, use the following options (assuming libevent was installed with prefix=$HOME/apps):

DIR=$HOME/apps
./configure CFLAGS="-I$DIR/include" LDFLAGS="-L$DIR/lib" --prefix=$HOME/apps
make && make install

if curses isn't found, you may have to add an extra LDFLAGS:

@rsperl
rsperl / copy_with_tar.sh
Last active July 25, 2022 14:43
copy files with tar #snippet
#!/bin/sh
tar cf - * | ( cd /target; tar xfp -)
@rsperl
rsperl / bitmasks.md
Last active July 25, 2022 13:04
Bitmasks #snippet

Does a mask have a certain bit set:

  • mask & bit == bit => yes
  • mask & bit == 0 => no

Example: do masks 514 or 512 have bit 2 set?

  • set: 514 & 2 == 2
  • not set: 512 & 2 == 0
@rsperl
rsperl / update_vscode.sh
Last active July 25, 2022 14:51
update visual studio code to the latest insider version #vscode #debian #ubuntu #snippet
#!/bin/bash
url="https://go.microsoft.com/fwlink/?LinkID=760865"
function get_latest_version()
{
url2=$(curl --silent -I "$url" | grep Location | awk '{print $NF}' | sed -e 's/\r//')
v=$(curl --silent -I "$url2" | grep Location | awk -F/ '{print $NF}' | awk -F_ '{print $2}' )
echo $v
}
@rsperl
rsperl / show_records_one_field_per_line.md
Last active July 25, 2022 13:50
show #mysql records one field per line #nosnippet

End the query with \g instead of ;:

mysql> select current_date, current_time \G
*************************** 1. row ***************************
current_date: 2017-06-29
current_time: 13:45:30
1 row in set (0.00 sec)

mysql>

@rsperl
rsperl / tasks.json
Last active July 25, 2022 13:35
#vscode task to find todos in the current workspace #snippet
{
"tasks": [
{
"taskName": "Find TODOs in this file",
"command": "ag",
"args": [
"--vimgrep",
"--no-color",
"-i",
"#\\s*todo|#\\s*hack|#\\s*fixme|//\\s*todo|//\\s*hack|//\\s*fixme"
@rsperl
rsperl / pullgists.sh
Last active July 25, 2022 14:58
clone or pull all your gists to a directory #snippet
#!/usr/bin/env bash
# pullgists.sh
#
# Syncs gists form github.com to your local computer.
#
# Authentication is by oath. If you don't have a token to use for authentication, then it will alert
# you the first time you run it, as well as give you the command to use to get it.
#
# Once your token is in place, you can run it with your username as an argument to sync gists to $GISTDIR,
@rsperl
rsperl / tmux.conf
Last active July 25, 2022 14:03
tmux cheatsheet #snippet
#
# tmux documentation: http://man7.org/linux/man-pages/man1/tmux.1.html
# copy a pane to the buffer (not the clipboard)
# -S from the start
# -1 to the end
:capture-pane -S 0 -0
# save the buffer to a file
:save-buffer /tmp/filename.txt
@rsperl
rsperl / python_comprehensions.py
Last active July 25, 2022 14:20
How to use python comprehensions instead of loops #nosnippet
vals = [expression
for value in collection
if condition]
# This is equivalent to:
vals = []
for value in collection:
if condition:
vals.append(expression)