Skip to content

Instantly share code, notes, and snippets.

View coderfi's full-sized avatar

Fairiz 'Fi' Azizi coderfi

View GitHub Profile
@coderfi
coderfi / serverless.yml
Created January 9, 2019 02:04 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
service: service-name
provider:
name: aws
runtime: nodejs6.10
functions:
myfunc:
handler: handler.myfunc
@coderfi
coderfi / IAMCredentials.json
Last active January 11, 2019 07:31 — forked from ServerlessBot/IAMCredentials.json
Credential set for Serverless Framework + AppSync + ElasticSearch + Cognito
{
"Statement": [
{
"Action": [
"apigateway:*",
"appsync:CreateApiKey",
"appsync:CreateDataSource",
"appsync:CreateFunction",
"appsync:CreateGraphqlApi",
"appsync:CreateResolver",
@coderfi
coderfi / gateway-env.sh
Last active December 7, 2018 20:29
Istio Gateway Host and Port discovery (minikube or cluster)
#!/usr/bin/env bash
# Usage:
# eval $(bash ./gateway-env.sh)
# Author: [email protected]
INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
if [[ "${INGRESS_HOST}" == "" ]]; then
# assume minikube
@coderfi
coderfi / istio_gateway_env.sh
Created November 16, 2018 00:25
Gets the gateway url, works with minikube or remote (such as AWS EKS)
#!/usr/bin/env bash
INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
if [[ "${INGRESS_HOST}" == "" ]]; then
# assume minikube
INGRESS_HOST=$(minikube ip)
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
else
INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
@coderfi
coderfi / bitcoin_seed_nodes.py
Created November 16, 2018 00:11
A python script to resolve a few registered bitcoin nodes from the DNS entries of some seed nodes.
#!/usr/bin/env python3
from datetime import datetime
import dns.resolver
import time
# pip install --user dnspython
# https://bitcoin.stackexchange.com/questions/14371/what-is-a-dns-seed-node-vs-a-seed-node
# https://bitcoin.stackexchange.com/questions/2027/how-does-the-bitcoin-client-make-the-initial-connection-to-the-bitcoin-network/2030#2030
@coderfi
coderfi / ethereum_foundation_nodes.py
Created November 16, 2018 00:09
A little script to parse the ethereum foundation seed ip addresses directly from the git source code.
#!/usr/bin/env python3
import json
from datetime import datetime
from urllib.request import urlopen
# todo: https://github.com/ethereum/go-ethereum/blob/release/1.8/params/bootnodes.go
url = 'https://github.com/paritytech/parity-ethereum/blob/v1.11.11/ethcore/res/ethereum/foundation.json?raw=true'
with urlopen(url) as rs:
@coderfi
coderfi / ecverify.sol
Created October 11, 2018 18:05 — forked from axic/ecverify.sol
Ethereum ECVerify
//
// The new assembly support in Solidity makes writing helpers easy.
// Many have complained how complex it is to use `ecrecover`, especially in conjunction
// with the `eth_sign` RPC call. Here is a helper, which makes that a matter of a single call.
//
// Sample input parameters:
// (with v=0)
// "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad",
// "0xaca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf200",
// "0x0e5cb767cce09a7f3ca594df118aa519be5e2b5a"
@coderfi
coderfi / Upgrading HDF5 and h5py to use SWMR with h5 files.md
Created August 25, 2018 16:30 — forked from geyang/Upgrading HDF5 and h5py to use SWMR with h5 files.md
hdf5 v1.10 upgrade/installation instruction for using single-write-multiple-read (SWMR) in h5py.

The new 1.10 version of hdf5 library is stable. You can now install from the source to use this new capability.

The installation process has a few caveats, so here is how to do it.

Note:

  1. you need to first remove the hdf5 libraries currently installed in ubuntu.
  2. Then you need to reinstall h5py.
  3. when you reinstall h5py via pip, use the --no-binary flag. This is because the h5py wheel comes with its own hdf5 binary.

Instructions:

@coderfi
coderfi / docker_mint18.sh
Created June 28, 2018 05:20 — forked from mcmaur/docker_mint18.sh
Install Docker on Linux Mint 18 Sylvia
#remove old
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
@coderfi
coderfi / create-mint-sh
Created June 27, 2018 22:35 — forked from gildas/create-mint-sh
Create Linux Mint USB on Mac OS/X
#! /usr/bin/env bash
# Insert a USB key.
# if needed initialize it with MS/DOS FAT and MBR
# Download the Mint ISO image
# Convert the ISO -> IMG
hdiutil convert -format UDRW -o linuxmint-17.3-cinnamon-64bit linuxmint-17.3-cinnamon-64bit.iso
# Run a diskutil list to know the device for the USB key, e.g.: /dev/disk3