Skip to content

Instantly share code, notes, and snippets.

View amrynsky's full-sized avatar

Alex Mrynsky amrynsky

  • Palo Alto Networks
  • CA, USA
View GitHub Profile
`git config --global --edit`
```
[alias]
# Command shortcuts
ci = commit
co = checkout
st = status
# Display tree-like log, because default log is a pain…
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit
@amrynsky
amrynsky / gist:bd379b8e107e787611daf34f8ca5309b
Last active October 1, 2023 19:52
Rate limiter in Java (Token bucket & sliding window)
package com.example.demo;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.ArrayDeque;
@amrynsky
amrynsky / checkstyle.xml
Last active January 27, 2020 19:25
Customized Google Checkstyle v8.28 - indent: tabs, line: 120
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html
Checkstyle is very configurable. Be sure to read the documentation at
@amrynsky
amrynsky / gist:eef394e7a8a15bf2412c36943dea76a1
Last active August 25, 2022 16:45
Change default java version

First run /usr/libexec/java_home -V which will output something like the following:

Matching Java Virtual Machines (5):
    11, x86_64:	"OpenJDK 11"	/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home
    10.0.2, x86_64:	"Java SE 10.0.2"	/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
    9.0.4, x86_64:	"Java SE 9.0.4"	/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
    1.8.0_152, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
    1.8.0_111, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
@amrynsky
amrynsky / sshuttle.sh
Created August 14, 2018 19:38 — forked from Davor111/sshuttle.sh
How to use sshuttle with .key, .csr or .pem files for authentication
#It's not directly mentioned in the documentation on how to do this, so here you go. This command will tunnel everything including DNS:
sshuttle --dns -vr user@yourserver.com 0/0 --ssh-cmd 'ssh -i /your/key/path.pem'
@amrynsky
amrynsky / brew_symlink_error_sierra.md
Created August 14, 2018 19:28 — forked from dalegaspi/brew_symlink_error_sierra.md
Homebrew Symlink errors in Mac OSX High Sierra
@amrynsky
amrynsky / run.tpl
Created February 12, 2018 23:24 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name={{.Name}} \
{{range $e := .Config.Env}}--env="{{$e}}" \
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \
{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from="{{.}}" \
{{end}}{{range $v := .HostConfig.Binds}}--volume="{{.}}" \
{{end}}{{range $l, $v := .Config.Labels}}--label "{{$l}}"="{{$v}}" \
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{.}} \
{{end}}{{range $v := .HostConfig.CapDrop}}--cap-drop {{.}} \
{{end}}{{range $d := .HostConfig.Devices}}--device={{(index $d).PathOnHost}}:{{(index $d).PathInContainer}}:{{(index $d).CgroupPermissions}} \
@amrynsky
amrynsky / awscli_functions.sh
Created February 8, 2016 14:38 — forked from cbsmith/awscli_functions.sh
A handy collection of bash functions to make the aws cli a bit more usable
# Usage: . awscli_functions.sh
# Suggested: add to ~/.bashrc
# This code lazily uses your default profile && region.
# It wouldn't take much to add some logic for using ${PROFILE} and/or ${REGION} as some kind of override.
# Lots more functions would be helpful, but I've been playing with ec2 & vpcs a lot lately, so...
clusters()
{
local __resultvar=$1
local __clusters=$(aws ecs list-clusters | jq -r '.clusterArns[]')