Skip to content

Instantly share code, notes, and snippets.

View Gurpartap's full-sized avatar
:octocat:
Working from home

Gurpartap Singh Gurpartap

:octocat:
Working from home
View GitHub Profile
@Gurpartap
Gurpartap / body_bytes.go
Created May 2, 2021 08:55
Parse any arbitrary http body with grpc-gateway
package body_bytes
import (
"fmt"
"io"
"io/ioutil"
"reflect"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
)
@Gurpartap
Gurpartap / RotateDisplay.scpt
Created October 26, 2020 17:06
Display Rotation Toggle (Landscape/Portrait) AppleScript Shortcut Script for LG Ultrafine 5K Display
tell application "System Preferences"
quit
delay 0.3
launch
activate
reveal pane id "com.apple.preference.displays"
tell application "System Events"
tell process "System Preferences"
delay 0.3
tell window "LG Ultrafine"
@Gurpartap
Gurpartap / docker-compose-elassandra.yml
Created April 23, 2020 04:20
temporal + elassandra (cassandra + elasticsearch)
version: '3'
services:
elassandra:
image: docker.io/strapdata/elassandra:6.8.4.4
environment:
- "JVM_OPTS=-Dcassandra.custom_query_handler_class=org.elassandra.index.ElasticQueryHandler"
- "MAX_HEAP_SIZE=1200m"
- "HEAP_NEWSIZE=300m"
- "CASSANDRA_CGROUP_MEMORY_LIMIT=true"
- "DEBUG=true"
@Gurpartap
Gurpartap / csi-linode-controller.nomad.hcl
Created April 17, 2020 23:00
Linode CSI on Nomad 0.11+
job "csi-linode-controllers" {
datacenters = ["dc1"]
type = "service"
group "controllers" {
count = 1
# disable deployments
update {
max_parallel = 0
@Gurpartap
Gurpartap / 0_readme.md
Last active March 24, 2022 03:07
Cadence job file for the HashiStack (consul and nomad)

use cadence-setup-schema.nomad for automatic schema setup and update

# submit the parameterized batch job to cluster:
nomad job run ./cadence-setup-schema.nomad

# run this job (but without any param):
nomad job dispatch cadence-setup-schema
@Gurpartap
Gurpartap / nomad-jobs-allocs-dashboard.json
Last active March 24, 2020 17:11
Grafana dashboard for current CPU & Memory Usage Stats for nomad job allocs
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@Gurpartap
Gurpartap / nomad-grafana-dashboard.json
Created March 23, 2020 21:43
grafana dashboard for nomad v0.10.4
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@Gurpartap
Gurpartap / job.nomad.hcl
Created March 23, 2020 19:29
nomad + consul template comma separated services from tags
job web {
datacenters = ["dc1"]
type = "service"
priority = 70
group app {
count = 1
task env {
driver = "exec"
@Gurpartap
Gurpartap / playbook.yaml.jinja2
Created March 11, 2020 16:50
derive a list of dicts from ansible groups and hostvars
vars:
zookeeper_nodes: "\
{% set _zookeeper_servers = [] %}\
{% for host in groups.zookeeper %}\
{% set _zookeeper_client_port_address = hostvars[host]['zookeeper_client_port_address'] | default('0.0.0.0', true) %}\
{% set _zookeeper_client_port = hostvars[host]['zookeeper_client_port'] | default(2181, true) %}\
{% if _zookeeper_servers.append(dict(['host', 'port'] | zip([_zookeeper_client_port_address, _zookeeper_client_port]))) %}{% endif %}\
{% endfor %}\
{{ _zookeeper_servers }}"
@Gurpartap
Gurpartap / one-way-hashing-function.swift
Created April 28, 2019 20:07
Swift port of Apple's one-way hashing function for setting SKMutablePayment's applicationUsername
// Objective-C version available here:
// https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/RequestPayment.html#//apple_ref/doc/uid/TP40008267-CH4-SW6
// Usage:
//
// let userID = "146001"
// print(hashedValueForAccountName(userID))
//
// Output:
//