Skip to content

Instantly share code, notes, and snippets.

View dendisuhubdy's full-sized avatar
🚀
at the speed of light

Dendi Suhubdy dendisuhubdy

🚀
at the speed of light
View GitHub Profile
@dendisuhubdy
dendisuhubdy / chacha20
Created June 28, 2020 11:05
ChaCha20 stream cipher in Python 3
# Pure Python ChaCha20
# Based on Numpy implementation: https://gist.github.com/chiiph/6855750
# Based on http://cr.yp.to/chacha.html
#
# I wanted an implementation of ChaCha in clean, understandable Python
# as a way to get a handle on the algorithm for porting to another language.
# There are plenty of bindings but few pure implementations, because
# Pure Python is too slow for normal practical use in Cryptography.
#
# The preceding implementation used NumPy, which avoided a lot of the
@dendisuhubdy
dendisuhubdy / k8s_delete_all_in_namespace.sh
Created June 9, 2020 05:06 — forked from BitProcessor/k8s_delete_all_in_namespace.sh
K8S: delete all resources in a given namespace
NAMESPACE=replace-me
kubectl -n ${NAMESPACE} delete "$(kubectl api-resources --namespaced=true --verbs=delete -o name | tr "\n" "," | sed -e 's/,$//')" --all
@dendisuhubdy
dendisuhubdy / k8s_get_pods.sh
Created June 9, 2020 05:06 — forked from BitProcessor/k8s_get_pods.sh
K8S: Get pod names
kubectl get pods --no-headers -o custom-columns=":metadata.name"
#kubectl get pods --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'
#kubectl get pods -o=name
kubectl get pods --all-namespaces -o json | \
jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)"' | \
xargs -n 1 bash -c
@dendisuhubdy
dendisuhubdy / k8s_delete_pods_ns.sh
Created June 9, 2020 05:06 — forked from BitProcessor/k8s_delete_pods_ns.sh
K8S: delete pods in namespace (restart)
NS=
kubectl get pods -n $NS --no-headers -o custom-columns=":metadata.name" | xargs kubectl -n $NS delete pod
@dendisuhubdy
dendisuhubdy / main.c
Created June 6, 2020 17:02 — forked from josephg/main.c
kqueue network & file example
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/event.h>
#include <netdb.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>

Inspired by this article. Neat tricks for speeding up integer computations.

Note: cin.sync_with_stdio(false); disables synchronous IO and gives you a performance boost. If used, you should only use cin for reading input (don't use both cin and scanf when sync is disabled, for example) or you will get unexpected results.

Multiply by a power of 2

x = x << 1; // x = x * 2

@dendisuhubdy
dendisuhubdy / clone-all-twitter-github-repos.sh
Created January 15, 2020 17:14 — forked from caniszczyk/clone-all-twitter-github-repos.sh
Clone all repos from a GitHub organization
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@dendisuhubdy
dendisuhubdy / grpc_asyncio.py
Created December 27, 2019 07:30 — forked from mmellison/grpc_asyncio.py
gRPC Servicer with Asyncio (Python 3.6+)
import asyncio
from concurrent import futures
import functools
import inspect
import threading
from grpc import _server
def _loop_mgr(loop: asyncio.AbstractEventLoop):