Skip to content

Instantly share code, notes, and snippets.

@sohooo
sohooo / gist:15a1e84362c8e2a3c459fc53fdda45f7
Created November 25, 2017 17:32 — forked from Nerten/gist:f30e95a3f649c6938447
Mounting external usb drives automatically to its label on Ubuntu
sudo apt-get install -y usbmount
sudo bash -c "cat <<EOT > /etc/usbmount/mount.d/01_create_label_symlink
#!/bin/sh
# This script creates the volume label symlink in /var/run/usbmount.
# Copyright (C) 2014 Oliver Sauder
#
# This file is free software; the copyright holder gives unlimited
# permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
@sohooo
sohooo / mount-nbd.sh
Created November 25, 2017 18:45 — forked from karser/mount-nbd.sh
Automatic mounting of additional NBD volumes using systemd on Ubuntu
#!/bin/bash
if [ "$#" -ne 2 ] ; then
echo 'Usage: mount-nbd.sh <device> <mount_point>'
exit 1
fi
device=$1
fs_type=$(blkid -o value -s TYPE $device)
if [[ -z $fs_type ]] ; then
@sohooo
sohooo / dsnless-odbc-sequel.rb
Created January 20, 2018 17:17 — forked from rjattrill/dsnless-odbc-sequel.rb
DSN-less ODBC Connection with ruby-sequel
require 'sequel'
DB = Sequel.connect(:adapter=>'odbc',:driver=>'SQL Server Native Client 10.0',:server=>'localhost',:port=>1433, :uid=>'myuser',:pwd=>'mypass',:db_type=>'mssql')
DB.fetch("SELECT * FROM artist") do |row|
puts row
end
@sohooo
sohooo / dsnless-odbc-sequel.rb
Created January 20, 2018 17:17 — forked from rjattrill/dsnless-odbc-sequel.rb
DSN-less ODBC Connection with ruby-sequel
require 'sequel'
DB = Sequel.connect(:adapter=>'odbc',:driver=>'SQL Server Native Client 10.0',:server=>'localhost',:port=>1433, :uid=>'myuser',:pwd=>'mypass',:db_type=>'mssql')
DB.fetch("SELECT * FROM artist") do |row|
puts row
end
@sohooo
sohooo / logger.sh
Created March 19, 2019 19:59 — forked from bunchc/logger.sh
Bash Color Logging
# EasyColors
if [ ${libout_color:-1} -eq 1 ]; then
DEF_COLOR="\x1b[0m"
BLUE="\x1b[34;01m"
CYAN="\x1b[36;01m"
GREEN="\x1b[32;01m"
RED="\x1b[31;01m"
GRAY="\x1b[37;01m"
YELLOW="\x1b[33;01m"
fi
@sohooo
sohooo / organize-av-files
Created October 3, 2019 19:24 — forked from keithrbennett/organize-av-files
Helps separate your audio and video files into saves and deletes using Ruby and MPlayer.
#!/usr/bin/env ruby
# organize-av-files - Organizes files playable by mplayer
# into 'saves', 'deletes', and 'undecideds' subdirectories.
#
# stored at:
# https://gist.github.com/keithrbennett/4d9953e66ea35e2c52abae52650ebb1b
require 'date'
@sohooo
sohooo / settings.sh
Created October 7, 2020 13:13
MacOS Terminal Settings
# useful defaults settings
# delete Timemachine local backups
# https://github.com/mathiasbynens/dotfiles/issues/842
tmutil listlocalsnapshots
tmutil deletelocalsnapshots 2019-02-16-080424
# delete all snapshots
for snapshot in $(tmutil listlocalsnapshots /); do
timestamp=$(echo $snapshot | cut -d. -f4)
@sohooo
sohooo / build-ruby.sh
Created October 7, 2020 13:16
Build Rubies
# building Ruby versions on Vagrant box
#
# https://github.com/rbenv/ruby-build
#
# booting vagrant box
cd ~/Code/boxes/centos7
vagrant up
vagrant ssh
# install ruby-build
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
@sohooo
sohooo / setup.sh
Created March 4, 2021 09:38
Lab Setup
# .dotvim files
git clone http://github.com/sohooo/dotvim2.git ~/.dotvim
vim -u ~/.dotvim/vimrc -c PlugInstall
# colorized cat
wget -c https://github.com/owenthereal/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz -O - | tar -xz
mkdir -p ~/.local/bin
cp -v ~/linux-amd64-1.1.0/ccat ~/.local/bin
# install lens