# create disk
$ qemu-img create -f qcow2 ~/QEMU/ubuntu-desktop-18.04.qcow2 10G
# setup
$ qemu-system-x86_64 -m 2048 -vga virtio -show-cursor -usb -device usb-tablet -enable-kvm -cdrom ~/QEMU/ubuntu-18.04.2-desktop-amd64.iso -drive file=~/QEMU/ubuntu-desktop-18.04.qcow2,if=virtio -accel hvf -cpu host
# run (unmount CDROM)
$ qemu-system-x86_64 -m 2048 -vga virtio -show-cursor -usb -device usb-tablet -enable-kvm -drive file=~/QEMU/ubuntu-desktop-18.04.qcow2,if=virtio -accel hvf -cpu host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def csvfile_to_array(csvfilepath, delimiter=',', ignore_header=False, set_required_num_cols=(True, 4)): | |
results = [] | |
with open(csvfilepath, 'r') as csvfile: | |
ctareader = csv.reader(csvfile, delimiter=delimiter) | |
if ignore_header: | |
next(ctareader, None) | |
for row in ctareader: | |
if set_required_num_cols[0]: | |
# hackishly doubly check for None and for cols in one pass | |
if len([v for v in row if v]) == set_required_num_cols[1]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -w install /var/log/dpkg.log | awk '{ if ($1 == "2013-08-22") { print $4 }}' | while read -r line; do sudo apt-get -y purge $line && sudo apt-get -y autoremove; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get Apple Health data as Pandas DataFrame | |
# === | |
# pre-reqs: python3, lxml, pandas | |
# to get started: | |
# export and mail yourself your data following steps within the Health app on iPhone | |
# download and unzip contents of exported zip file; find path to export.xml and set path_to_exportxml below | |
import pandas as pd | |
import xml.etree.ElementTree | |
import datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lsof -i +c 0 | awk '{ print $1 }' | uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIR=`pwd` awk '{ gsub("\\$DIR",ENVIRON["DIR"]); print $0 }' infile > outfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference guide from Google: https://www.tensorflow.org/install/install_sources | |
# assumes python3 and pip3 installed (/usr/local/python3.6), along with homebrew | |
# python pkgs path: `python3 -m site` (/usr/local/lib/python3.6/site-packages) | |
# --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-msse4.1 --copt=-msse4.2 | |
# ^ these are some potential CPU optimizations but just allowing the ./configurewizard to do its thing and use -march=native | |
# also seems to work fine for just CPU optim. | |
$ brew install bazel # v.0.9.0 | |
$ pip3 install numpy six wheel | |
$ git clone https://github.com/tensorflow/tensorflow.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# brute force scanner for sonos devices on a network | |
# (just looks for open port 1400: e.g., http://ip:1400/support/review) | |
echo Scanning network for Sonos devices... | |
for i in $(seq 1 255); | |
do | |
IP=192.168.1.$i | |
PORT=1400 | |
nc -n -z -G 1 $IP $PORT 2>&1 | awk '{print $3}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# record desktop to .mkv which is safely ended via ctrl+c | |
ffmpeg -y -f gdigrab -i desktop -r 10 -vcodec libx264 -pix_fmt yuv420p output.mkv | |
# clip some time (in this case 22s) from the start of the video and transcode to .mp4 (a format not safe to end w/ctrl+c) | |
ffmpeg -ss 00:00:22.0 -i output.mkv output.mp4 | |
# create a palette | |
ffmpeg -y -i output.mp4 -vf fps=10,scale=768:-1:flags=lanczos,palettegen palette.png | |
# create the final gif | |
ffmpeg -i output.mp4 -i palette.png -filter_complex "fps=10,scale=1024:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ffshow='firefox "data:text/html;base64,$(base64 -w 0 <&0)"' | |
# usage: curl google.com | ffshow |
OlderNewer