Skip to content

Instantly share code, notes, and snippets.

View reutsharabani's full-sized avatar
🐻
with Mia <3

Reut Sharabani reutsharabani

🐻
with Mia <3
View GitHub Profile
import java.util.Deque;
import java.util.Iterator;
import java.util.ArrayDeque;
public class ExtendableIterator<T> implements Iterator<T> {
public Deque<Iterator<T>> its = new ArrayDeque<Iterator<T>>();
public ExtendableIterator() {
@reutsharabani
reutsharabani / get_caller.py
Created December 27, 2016 15:40
Get calling module's name in python
import inspect
def whoami():
'''Return the module name of where the call came from.'''
frame_records = inspect.stack()[1]
calling_module = inspect.getmodulename(frame_records[1])
return calling_module
# Test
@reutsharabani
reutsharabani / docker-aliases.sh
Created January 10, 2017 13:53
docker aliases
# docker aliases
alias drmv='docker volume ls -qf dangling=true | xargs -r docker volume rm'
alias drmi='docker images --filter dangling=true -q | xargs -r docker rmi'
alias drmc='docker ps -q -f status=exited | xargs -r docker rm'
alias drm='drmc;drmi;drmv'
alias docker-clean='docker-compose stop && drm'
alias docker-names='docker ps | cut -d " " -f1 | tac | head -n-1'
#alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'" $@
alias dip="docker ps --format=\"{{.Names}}\" | xargs docker inspect --format '{{.Name}} {{ .NetworkSettings.IPAddress }}' | column -t -s\" \""
#!/usr/bin/python
import boto
import math
# Use boto to Copy an Object greater than 5 GB Using S3 Multipart Upload API
# probably could be made more pythonesque, based directly off the AWS Java example
# Copy an Object [greater than 5 GB] Using the AWS SDK for Java [S3] Multipart Upload API
# http://docs.aws.amazon.com/AmazonS3/latest/dev/CopyingObjctsUsingLLJavaMPUapi.html
# copy in same bucket as a simple test
@reutsharabani
reutsharabani / chunks.py
Last active August 30, 2017 08:20
Python chunks function with overlaps
def skip(iterator, n):
"""
skip n items in iterator
from itertools recipes:
https://docs.python.org/3/library/itertools.html#itertools-recipes
(see "consume")
:param iterator: iterator to skip
:param n: items to skip
:return: iterator with n items skipped
from itertools import chain
import inspect
# very naive deastruct implementation (not native...)
def _destruct(selector):
def _(value):
if isinstance(selector, dict):
yield from chain.from_iterable(_destruct(selector[k])(value[k]) for k in selector)
Computer Information:
Manufacturer: Apple
Model: iMac19,1
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
CPU Family: 0x6
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
# provision application load balancer
kubernetes.io/ingress.class: alb
# on a public subnet
alb.ingress.kubernetes.io/scheme: internet-facing
# register pods to Load Balancer (not nodes)
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb-ip
name: my-nlb
spec:
ports:
- port: 80
protocol: TCP
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb-ip
service.beta.kubernetes.io/aws-load-balancer-target-group-attributes: proxy_protocol_v2.client_to_server.header_placement=on_first_ack,proxy_protocol_v2.enabled=true
name: my-nlb
spec:
ports:
- port: 80