Skip to content

Instantly share code, notes, and snippets.

@akaron
akaron / asg_get_ip.tf
Last active June 5, 2020 15:38
terraform aws_autoscaling_group get private and public ip
# In terraform, the attribute of autoscaling group does not contain detail information of EC2 instances,
# i.e., cannot get the ip of instances for further usage (such as ansible). Of course it's better to make
# it no need to know the ip by using tools such as user-data of EC2 instance (for bootstrap) and LB and
# route 53.
#
# In case still want to know the ip addresses, one can use `data "aws_instances"` which
# `depends_on = [aws_autoscaling_group.name]`, then use tags to get the information of instances.
# ref: https://github.com/terraform-providers/terraform-provider-aws/issues/511#issuecomment-447934405
provider "aws" {
@akaron
akaron / vimrc
Created June 2, 2020 06:14
vimrc light version
set nocompatible " be iMproved, required
" vim-plug, see https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'vim-airline/vim-airline'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'sheerun/vim-polyglot'
@akaron
akaron / install_pip.md
Last active November 21, 2019 08:34
install pip for python2 and 3

For operation systems: Ubuntu, Debian, and MacOS. In windows the pip and virtualenv commands should be the same once python is installed somewhere.

Install pip, virtualenv, and python module in virtualenv

Debian/Ubuntu

Use python module psutil as example.

> sudo apt update
> sudo apt install python-pip virtualenv

> /usr/bin/virtualenv ~/venv # create virtualenv in ~/venv

@akaron
akaron / read.js
Last active September 25, 2019 00:14
streamr (read)
'use strict'
const StreamrClient = require('streamr-client');
const apiKey = '' // read-only key created via streamr.network/stream
// Create the client using api key
const client = new StreamrClient({
auth: {
apiKey: apiKey
}
})
@akaron
akaron / geth_rpc_server.md
Last active August 9, 2022 14:16
create private geth rpc server using ssh port forwarding

note: create private geth rpc server using ssh port forwarding

In short, user provide ssh key to rpc server manager. Once the manager configured, then everytime the user need to type folowing commands to access to the geth rpc server:

  1. ssh -N -L 9545:localhost:8545 geth@machine_A_addr
  2. ... and set the rpc to http://localhost:9545

For convenienve, in the following I use these abbreviations:

  • machine A: run geth full node with RPC server
  • machine B: using the geth RPC from machine A
@akaron
akaron / standardDeviation.js
Created June 8, 2019 02:17
mean and standard deviation for node.js
#!/usr/bin/env node
'use strict';
// basic functions for mean and standard deviation
let getMean = (data) => {
return data.reduce(function (a, b) {
return Number(a) + Number(b);
}) / data.length;
};
@akaron
akaron / markdown-folding.vim
Created July 25, 2016 10:39 — forked from anonymous/markdown-folding.vim
A simple demo of how a foldexpr works in Vim. See http://vimcasts.org/e/28 for full explanation.
function! MarkdownFolds()
let thisline = getline(v:lnum)
if match(thisline, '^##') >= 0
return ">2"
elseif match(thisline, '^#') >= 0
return ">1"
else
return "="
endif
endfunction
@akaron
akaron / vimrc
Last active December 31, 2022 22:07
vimrc (using vimplug)
set nocompatible " be iMproved, required
" vim-plug, see https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
" plugins
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
@akaron
akaron / matplotlib style sheets
Created January 27, 2015 21:48
matplotlib style sheets test
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "",
"signature": "sha256:7a91feb23f9c512cc162a8553eaa4f6eecbf03a82802d7a221f692c4cca3f475"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@akaron
akaron / reverse cubehelix colormap
Last active August 29, 2015 14:14
reverse cubehelix colormap
{
"metadata": {
"name": "",
"signature": "sha256:e0c232c15fa3e1f52b7519442a1e1f6f42fe81a3902983b5fd630d303452caa8"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [