Skip to content

Instantly share code, notes, and snippets.

@dohq
dohq / isolate_cpu.sh
Created August 17, 2023 20:36
Gaming on Windows in comfort with PCI passthrough
#!/bin/sh
# /etc/libvirt/hooks/qemu.d/windows10/prepare/begin/isolate_cpu.sh
GUEST_NAME="$1"
GUEST_ACTION="$2/$3"
ALLOWED_CPUS="0-7,16-23"
ALL_CPUS="0-31"
function fzf-ssh-consul () {
local selected_host=$(consul catalog nodes | grep -v "DC" | awk '{print $1}' | fzf --query "$LBUFFER" --prompt="Consul Nodes SSH Remote > ")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}.node.consul"
zle accept-line
fi
zle reset-prompt
}

Keybase proof

I hereby claim:

  • I am dohq on github.
  • I am dohq (https://keybase.io/dohq) on keybase.
  • I have a public key ASAsJeIJ-_WbIfQGFoewCcqG1xr-OZljcqYCZfVZUPm75Ao

To claim this, I am signing this object:

@dohq
dohq / hosts.yml
Created February 10, 2020 19:09
Example Ansible hosts.yml
---
all:
children:
datanode:
hosts:
es1:
ansible_host: 192.168.33.31
ansible_ssh_private_key_file: ./.vagrant/machines/es1/libvirt/private_key
es2:
ansible_host: 192.168.33.32
@dohq
dohq / init-ansible.sh
Last active February 11, 2020 15:10
Initialize Ansible Best Prictice DIRs
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
create () {
if [[ $1 == "d" ]]; then
if [ ! -d $2 ]; then mkdir $2; echo "make dir $2"; fi
elif [[ $1 == "y" ]]; then
if [ ! -f $2 ]; then touch $2; echo "---" >> $2; echo "make yaml $2"; fi
fi
@dohq
dohq / prompt.sh
Created April 2, 2019 07:27
bash rightside gitstatus prompt
# from http://ezprompt.net/
function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && echo "$RETVAL"
}
# from http://ezprompt.net/
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
@dohq
dohq / server.go
Created March 14, 2019 06:47 — forked from mattn/server.go
package main
import (
"database/sql"
"fmt"
"github.com/go-gorp/gorp"
_ "github.com/mattn/go-sqlite3"
"golang.org/x/net/websocket"
"log"
"net/http"
@dohq
dohq / datetime_parser.py
Created January 9, 2018 15:08 — forked from dittore/datetime_parser.py
Parse input into YYYY-MM-DD HH:MM:SS (PYTHON)
def parse_datetime(d):
"""
Datetime parser
Creates datetimes from input into format yyyy-mm-dd hh:mm:ss
Needs proper validation!
Should accept following:
yyyy
@dohq
dohq / README.md
Created August 5, 2017 17:01 — forked from mattn/README.md
gvim で使える等幅フォント
@dohq
dohq / fzf-history.zsh
Last active July 26, 2019 02:40
fzf-history
setopt hist_ignore_all_dups
function fzf-history() {
BUFFER=$(history -n -r 1 | fzf --no-sort +m --query "$LBUFFER" --prompt="History > ")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N fzf-history
bindkey '^r' fzf-history