Skip to content

Instantly share code, notes, and snippets.

View nktpro's full-sized avatar

Jacky Nguyen nktpro

View GitHub Profile
@subfuzion
subfuzion / README.md
Last active November 17, 2023 02:53
Lima template
  1. Create the following directories in your home directory:
mkdir -p lima/code

This mounts your local filesytem (under $/lima/code) to $/code in the Lima instance.

  1. Install Lima if you haven't already done so.
@GlitchWitch
GlitchWitch / 0-vlan-to-wan2.md
Last active September 29, 2024 17:34
UDMP VLAN to WAN2 Policy Based Routing

Ubiquiti UDM-Pro Dual-WAN Setup Scripts

VLAN to WAN2 Policy Based Routing + Disable WAN Failover

Tested on UDM-Pro 1.10.0

The following scripts can be used on a UDM-Pro with on boot script to force specific vlans out WAN2 as well as prevent that traffic from going out wan1 and all other traffic from going out wan2 in the event one WAN is disconnected.

curl -fsSLo /mnt/data/on_boot.d/98-vlan_to_wan2.sh https://gist.githubusercontent.com/GlitchWitch/9833888842dbd7d0b42669faab4c4a4a/raw/9ede55da6820c65c3aeb5d0951a71855641b0041/98-vlan_to_wan2.sh 
import com.google.protobuf.Descriptors.{MethodDescriptor, ServiceDescriptor}
import com.trueaccord.scalapb.compiler.FunctionalPrinter.PrinterEndo
import com.trueaccord.scalapb.compiler._
import scala.collection.JavaConverters._
final class MonixGrpcPrinter(service: ServiceDescriptor,
override val params: GeneratorParams)
extends DescriptorPimps {
@w1ndy
w1ndy / seccomp.json
Created September 20, 2016 15:27
Allowing numactl in docker container
{
"defaultAction": "SCMP_ACT_ERRNO",
"architectures": [
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"name": "accept",
@jpallari
jpallari / Main.scala
Last active February 5, 2024 08:29
Ways to pattern match generic types in Scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}
@valyala
valyala / README.md
Last active September 1, 2024 20:40
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:
@fabiofl
fabiofl / gist:5873100
Created June 27, 2013 00:41
Clear Mac OS X's icon cache.
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;