Skip to content

Instantly share code, notes, and snippets.

View hoggren's full-sized avatar
💾

Patrik Höggren hoggren

💾
View GitHub Profile
# Removes the speech bubble with letters incl. accents etc.
# Great addon for this modificatiton
defaults write -g ApplePressAndHoldEnabled -bool false
# normal minimum is 15 (225 ms)
defaults write -g InitialKeyRepeat -int 20
# normal minimum is 2 (30 ms)
defaults write -g KeyRepeat -int 2
@hoggren
hoggren / batcharge.py
Last active April 27, 2020 21:47 — forked from remy/batcharge.py
FORKED! I'm not the founder :)
#!/usr/bin/env python
# saved to ~/bin/batcharge.py and from
# http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/#my-right-prompt-battery-capacity
#!/usr/bin/env python
# coding=UTF-8
import math, subprocess
p = subprocess.Popen(["ioreg", "-rc", "AppleSmartBattery"], stdout=subprocess.PIPE)
output = p.communicate()[0]
@hoggren
hoggren / apache_log.regex
Last active April 9, 2020 07:33
Regex for apache access log
(?<IP>[^ ]*) \- \- \[(?<Datetime>[^\]]+)\] \"(?<Verb>[^\ ]+)\ (?<Path>.*) (?<HTTP>HTTP/\d\.\d)"
@hoggren
hoggren / columnizer.md
Created April 7, 2020 09:55
Pipe separated log for LogExpert
@hoggren
hoggren / lscolors.sh
Last active May 2, 2020 20:58
WSL LSCOLORS - Nice colors for files and directories when browsing around in Windows files.
# Usage intendended for WSL. Add following row to your .zshrc, .bashrc, or what shell you are using.
# Try which variant suites your terminal best! :)
# Author: Patrik Höggren <p@hoggren.nu>
#
# Type 1:
LS_COLORS="rs=0:di=34:ln=35:mh=00:pi=35:so=32:do=34:bd=1;36:cd=1;37:or=40;31;01:mi=00:su=1,37:sg=30;1:ca=30;41:tw=30:ow=34:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;
@hoggren
hoggren / web-servers.md
Created October 17, 2019 18:55 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@hoggren
hoggren / Powershell_goodies.ps1
Last active December 22, 2019 12:02
Short description about the PSReadLine Module
# To scope this to your account, copy-paste the content below
# to `%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`.
# Create the file if it doesn't exists.
#PSReadline
# Remove the annoying warning/error sound and enable Emacs mode, it changes `Tab` completion behaviour, and much more:
# <https://docs.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-6>
Set-PSReadLineOption -EditMode Emacs -BellStyle None
@hoggren
hoggren / Pata.Boxstarter.ps1
Last active April 10, 2020 14:48
Personal boxstarter
# Boxstarter Configuration
# Updated 2020-01-28
# https://boxstarter.org/
# https://chocolatey.org/
# Install BoxStarter:
# `. { iwr -useb https://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force`
Set-WindowsExplorerOptions `
-EnableShowRibbon `
-EnableShowFileExtensions `
@hoggren
hoggren / bootable_usb4mac.sh
Last active August 21, 2020 23:02
Bootable usb flash drive for MacOS
#!/bin/bash
# Usage: ./bootable_usb4mac.sh /dev/rdiskX isofile.iso
# Writing to /dev/rdiskX requires root privilegies, and rdisk is FASTER
# https://superuser.com/questions/631592/why-is-dev-rdisk-about-20-times-faster-than-dev-disk-in-mac-os-x/631601
USBDISK=$1
ISOFILE=$2
TMPFILE="tempoutput"
if [ "$(whoami)" != "root" ]; then
echo "no root, qutting"
@hoggren
hoggren / linux.md
Last active June 23, 2022 18:14
commands I dont remember

Bunch of commands

Static HTTP Server

Serve files over HTTP with python 🐭

# python2
python -m SimpleHTTPServer 8000