Skip to content

Instantly share code, notes, and snippets.

View dokipen's full-sized avatar

Bob Corsaro dokipen

  • Medium.com
  • Newburyport, MA
View GitHub Profile
@dokipen
dokipen / gist:2077ce7e941f64d17691490b72cb4ea2
Created February 3, 2022 14:46
Crappy Makefile to build a pulsar-client whl for py3.7.12, M1 python, pulsar-2.9.1
BUILD_DIR=$(shell pwd)
ARCH=$(shell uname -m)
VERSION=$(shell sw_vers -productVersion | sed 's/\.[0-9]/_0/')
PYTHON_VERSION=3.7
PYTHON_PATCH_VERSION=3.7.12
PYTHON_POSTFIX=m
PYTHON_WHL_VERSION=cp$(subst .,,$(PYTHON_VERSION))-cp$(subst .,,$(PYTHON_VERSION))$(PYTHON_POSTFIX)
PYTHON_BASE=$(HOME)/.pyenv/versions/$(PYTHON_PATCH_VERSION)
PYTHON_LIBRARIES=$(PYTHON_BASE)/lib
"""
tropo.py implements resource types not yet supported by troposphere. This module
is ever changing and should be updated when troposphere is upgraded.
"""
from __future__ import print_function
from troposphere import AWSObject, AWSProperty
from troposphere.validators import positive_integer
from troposphere.ecs import (
### Keybase proof
I hereby claim:
* I am dokipen on github.
* I am doki_pen (https://keybase.io/doki_pen) on keybase.
* I have a public key ASB6BMJE2F-HO3RcgsxXNGQ_kHTAVcCv1kgnfIGgYukehgo
To claim this, I am signing this object:
@dokipen
dokipen / assoc_array.sh
Created October 28, 2016 20:27
Why don't fields set in the loop propagate out of the loop?
declare -A testthis
testthis[hello]="world"
echo "keys: ${!testthis[@]}"
printf "a\nb\nc\nd\ne\nf\n" | while read key && read value; do
testthis[$key]="${value}"
echo "keys: ${!testthis[@]}"
done
echo "keys: ${!testthis[@]}"
a = []
a[4294967294] = 1
console.log(a)
total = 4768
unpledged = 717
pledged = total - unpledged
clinton = 1279 + 18 - 3
bernie = 1027 + 47 + 3
needed = pledged / 2
assigned = clinton + bernie
remaining = pledged - assigned
bernie_needed = needed - bernie
bernie_perc_needed = bernie_needed.to_f / remaining
var hello = 0;
var values = [1,2,3,4];
for (var i = 0; i < values.length; i++) {
hello += values[i];
}
console.log(hello);
# --------------------------------------
@dokipen
dokipen / http.go
Last active January 8, 2016 17:11
func bindListener(port string) net.Listener {
for {
l, err := net.Listen("tcp", fmt.Sprintf(":%s", port))
if err != nil {
dlog("%+v", err)
time.Sleep(time.Duration(1) * time.Second)
} else {
return l
}
}
import operator
import itertools
def star(fn):
def wrapper(l):
retrun fn(*l)
return wrapper
pairs = [[1,2], [3,4], [5,6]
print map(star(operator.add), pairs)
a = u'Ա Բ Գ Դ Ե Զ Է Ը Թ Ժ Ի Լ Խ Ծ Կ Հ Ձ Ղ Ճ Մ Յ Ն Շ Ո Չ Պ Ջ Ռ Ս Վ Տ Ր Ց Ւ Փ Ք Օ Ֆ ՙ ՚ ՛ ՜ ՝ ՞ ՟ ա բ գ դ ե զ է ը թ ժ ի լ խ ծ կ հ ձ ղ ճ մ յ ն շ ո չ պ ջ ռ ս վ տ ր ց ւ փ ք օ ֆ և ։'
len(a.encode('punycode')) # 257
len(a.encode('utf-8')) # 254