Skip to content

Instantly share code, notes, and snippets.

@timothyklim
timothyklim / hardened.service
Created January 21, 2021 14:42 — forked from fionn/hardened.service
An example secure systemd unit file
[Unit]
Description=Some internet-facing service
After=network.target
[Service]
Type=simple
WorkingDirectory=...
EnvironmentFile=...
ExecStart=...
#!/usr/bin/perl
# credits:https://askubuntu.com/questions/26056/where-are-gnome-keyboard-shortcuts-stored
use strict;
my $action = '';
my $filename = '-';
for my $arg (@ARGV){
org.gnome.desktop.wm.keybindings switch-group ['<Super>Above_Tab', '<Alt>Above_Tab']
org.gnome.desktop.wm.keybindings begin-resize ['<Alt>F8']
org.gnome.desktop.wm.keybindings switch-to-workspace-7 []
org.gnome.desktop.wm.keybindings begin-move ['<Alt>F7']
org.gnome.desktop.wm.keybindings move-to-side-w []
org.gnome.desktop.wm.keybindings move-to-corner-nw []
org.gnome.desktop.wm.keybindings move-to-workspace-10 []
org.gnome.desktop.wm.keybindings move-to-workspace-6 []
org.gnome.desktop.wm.keybindings move-to-workspace-right ['<Control><Shift><Alt>Right']
org.gnome.desktop.wm.keybindings always-on-top []
@timothyklim
timothyklim / High_Performance_Redis.md
Created November 14, 2019 11:38 — forked from neomantra/High_Performance_Redis.md
Notes on running Redis with HPC techniques

High Performance Redis

In response to this brief blog entry, @antirez tweeted for some documentation on high-performance techniques for Redis. What I present here are general high-performance computing (HPC) techniques. The examples are oriented to Redis. but they work well for any program designed to be single- or worker-threaded and asynchronous (e.g. uses epoll).

The motivation for using these techniques is to maximize performance of our system and services. By isolating work, controlling memory, and other tuning, you can achieve significant reduction in latency and increase in throughput.

My perspective comes from the microcosm of my own bare-metal (vs VM), on-premises deployment. It might not be suitable for all scenarios, especially cloud deployments, as I have little experience with HPC there. After some discussion, maybe this can be adapted as [redis.io documentation](https://redis.io/do

@timothyklim
timothyklim / HotSpot JVM intrinsics
Created November 7, 2019 10:44 — forked from apangin/HotSpot JVM intrinsics
HotSpot JVM intrinsics
_hashCode java/lang/Object.hashCode()I
_getClass java/lang/Object.getClass()Ljava/lang/Class;
_clone java/lang/Object.clone()Ljava/lang/Object;
_dabs java/lang/Math.abs(D)D
_dsin java/lang/Math.sin(D)D
_dcos java/lang/Math.cos(D)D
_dtan java/lang/Math.tan(D)D
_datan2 java/lang/Math.atan2(DD)D
_dsqrt java/lang/Math.sqrt(D)D
_dlog java/lang/Math.log(D)D
@timothyklim
timothyklim / rust_mem_profiling.md
Created August 21, 2019 06:16 — forked from HenningTimm/rust_mem_profiling.md
Memory profiling Rust code with heaptrack in 2019
@timothyklim
timothyklim / Profile Rust on Linux.md
Created August 21, 2019 06:16 — forked from KodrAus/Profile Rust on Linux.md
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

@timothyklim
timothyklim / README.md
Created April 6, 2019 10:08 — forked from valyala/README.md
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@timothyklim
timothyklim / TreeList.scala
Created December 29, 2018 03:58 — forked from johnynek/TreeList.scala
Implementation of "Purely Functional Random Access Lists" by Chris Okasaki in scala. This gives O(1) cons and uncons, and 2 log_2 N lookup.
package org.bykn.list
import cats.Applicative
import cats.implicits._
/**
* Implementation of "Purely Functional Random Access Lists" by Chris Okasaki.
* This gives O(1) cons and uncons, and 2 log_2 N lookup.
*/