Skip to content

Instantly share code, notes, and snippets.

@shawel
shawel / build.sh
Created June 15, 2022 21:19 — forked from jcmcneal/build.sh
#!/bin/bash -e
# Custom Variables
NODE_ARCH=$([ "$CI_RUNNER_EXECUTABLE_ARCH" == "linux/arm64" ] && echo "arm64v8" || echo "amd64")
echo "NODE_ARCH: $NODE_ARCH"
if [[ -z "$CI_COMMIT_TAG" ]]; then
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA}
else
@shawel
shawel / gist:1795afd9cee4dab2c4b3fc68def6ad69
Created March 17, 2021 15:58 — forked from tzapu/gist:f47924daae9d64b65fdfaf92b64f587c
connecting to a kubernets hosted kafka cluster from macOS
# you will need to alias the internal kube IPs to your loopback interface
# get pods with IPs
kubectl get pods -n kafka -o wide
# add aliases
sudo ifconfig lo0 100.101.168.109 alias
sudo ifconfig lo0 100.117.38.251 alias
sudo ifconfig lo0 100.121.158.154 alias
@shawel
shawel / atoi_test.go
Created June 29, 2020 05:21 — forked from evalphobia/atoi_test.go
golang benchmark: String and Int conversions
package bench
import (
"strconv"
"testing"
)
var smallStr = "35"
var bigStr = "999999999999999"
binary https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/09-go-type-system/01-bits/main.go#L16
memory size https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/09-go-type-system/03-predeclared-types/main.go#L17
shawoding shoort if https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/11-if/04-short-if/04-scope-shadowing/01-shadowing/main.go#L17
range https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/13-loops/05-for-range/01-loop-over-slices/main.go#L16
array 1 https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/14-arrays/04-array-literal/main.go#L21
append https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/16-slices/05-append/1-theory/main.go#L15
slices https://github.com/inancgumus/learngo/blob/6bab6e476b6be92438f732e1ed34d3079fa3e6d6/16-slices/08-slice-internals-1-backing-array/2-example/main.go#L15
slice 2 https://g
FROM python:alpine
ARG CLI_VERSION=1.18.87
RUN apk -uv add --no-cache groff jq less emacs curl htop && \
pip install --no-cache-dir awscli==$CLI_VERSION
WORKDIR /aws
CMD sh
@shawel
shawel / better-nodejs-require-paths.md
Created June 18, 2020 15:40 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@shawel
shawel / SparkWithHadoop.md
Created April 10, 2020 23:26 — forked from afranzi/SparkWithHadoop.md
Spark 2.4.0 with Hadoop 2.8.5

Setup Environmnet variables for Hadoop.

export HADOOP_VERSION=2.8.5
export HADOOP_HOME=${HOME}/hadoop-$HADOOP_VERSION
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=${HADOOP_HOME}/bin:$PATH

Download Hadoop files.

@shawel
shawel / Schema2CaseClass.scala
Created March 23, 2020 22:45 — forked from yoyama/Schema2CaseClass.scala
Generate case class from spark DataFrame/Dataset schema.
/**
* Generate Case class from DataFrame.schema
*
* val df:DataFrame = ...
*
* val s2cc = new Schema2CaseClass
* import s2cc.implicit._
*
* println(s2cc.schemaToCaseClass(df.schema, "MyClass"))
*
@shawel
shawel / kafka-cheat-sheet.md
Created May 30, 2019 05:06 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)