Skip to content

Instantly share code, notes, and snippets.

View mrjohannchang's full-sized avatar

Johann Chang mrjohannchang

View GitHub Profile
@JPvRiel
JPvRiel / journalctl_enable_persistent_storage.md
Last active November 17, 2024 20:29
Enable persistent storage for the systemd journal log

Enable persistent storage for the systemd journal log

Overview

The assumed default setting in /etc/systemd/journald.conf is Storage=auto which implies that systemd journaling will only persist the journal if the expected storage location is available. Otherwise, the journal data is stored in memory and lost between reboots. On Ubuntu 16.04, /var/log/journal does not exist by default. Create it to keep and query events from previous boots.

Considerations:

  • Syslog still provides the persistant log records for Ubuntu 16.04, so enabling persistant systemd journal logging does cause a level of duplicaiton.
  • There are sane defaults:

Tuning Windows 10 for Slow Machines

Windows 10 on slow netbook

This guide is for those who dares to install Windows 10 on slow netbooks (1GB of RAM).
Though Windows update program is over, you still may use old Windows product keys from license stickers to install Windows 10 on old machines.

UPD Jan 2019
This article is quite old, some instructions may be obsolete.

@byrnedo
byrnedo / ComputeHmac256.go
Created September 12, 2016 07:32
Compute a hmac for a message in golang
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@tripleee
tripleee / starttime.sh
Created August 17, 2016 06:23
starttime - print start time of a process on Linux
#!/bin/sh
# http://stackoverflow.com/a/38740102/874188
for p; do
printf "/proc/%i/stat\0" "$p"
done |
xargs -r0 awk -v ticks="$(getconf CLK_TCK)" 'NR==1 { now=$1; next }
{ print strftime("%c " $1 " " $2, systime() - (now-($22/ticks))) }
' /proc/uptime
@MOOOWOOO
MOOOWOOO / py-gitignore
Last active April 30, 2025 01:44
python pycharm gitignore
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
@huytd
huytd / .gitconfig
Created August 4, 2016 16:26
Use neovim as diff tool
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff
@thomastweets
thomastweets / PNGWhiteTrim.py
Last active February 8, 2024 18:53
Python script to trim all png images with white background in a folder
import Image
import sys
import glob
import ImageOps
# Trim all png images with white background in a folder
# Usage "python PNGWhiteTrim.py ../someFolder"
try:
folderName = sys.argv[1]
@r39132
r39132 / test.py
Created May 18, 2016 18:04
Writing Avro Without A Schema in Python
import avro.schema
import io, random
from avro.io import DatumWriter, DatumReader
import avro.io
# Path to user.avsc avro schema
schema_path="user.avsc"
schema = avro.schema.parse(open(schema_path).read())
#!/usr/bin/env bash
# echo -e "a\nb\nc\n" | lastln b
function lastln() {
pattern="$1"
i=0
n=-1
while read line; do
if [[ "$line" == "$pattern" ]]; then
n=$i