Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / Network.swift
Last active August 29, 2015 14:27 — forked from jbergen/Network.swift
Networker made from enums
/**
paste this code into a playground to test it out
*/
import Foundation
/**
@sohooo
sohooo / plugin.js
Last active August 29, 2015 14:11
jQuery plugin template
// Protect the '$' alias and add scope by putting everything in
// an Immediately Invoked Function Expression:
// http://stage.learn.jquery.com/javascript-101/functions/#immediately-invoked-function-expression-iife
(function($) {
// As $.fn is just an alias for $.prototype, all jQuery
// objects ($ constructor) get our function.
$.fn.helloWorld = function(options) {
debug(this);
@sohooo
sohooo / jailuser.pp
Last active August 29, 2015 14:01
Creating jailed users based on my jailkit module; interfacing with common::shelluser.
common::jailuser { 'nova':
sections => ['jk_lsh', 'basicshell'],
binds => ['/var/log => log', '/opt => opt'],
keys => ['funky', 'george'],
}
define common::jailuser(
$user = $title,
$sections = [],

Clone & Build

curl https://gist.github.com/raw/970438/caff9a09ed2d223b1123a69ede17cb19ad352af9/build.sh | sh
@sohooo
sohooo / dbbackup.sh
Last active May 23, 2021 06:17
Simple script to create a backup of your Wordpress database. It uses the credentials from your wp-config.php and mysqldump's the data to wp-content/backups. Place it next to your wp-config.php and adjust $KEEP_DAYS.
#!/bin/bash
# fail on error
set -e
pushd `dirname $0` > /dev/null
SCRIPT=`pwd -P`
popd > /dev/null
KEEP_DAYS=150