Skip to content

Instantly share code, notes, and snippets.

View roustem's full-sized avatar

Roustem Karimov roustem

View GitHub Profile
@roustem
roustem / test.go
Created August 27, 2016 15:25
Type conversion (with and without panic)
package main
import "fmt"
func test() interface{} {
return 123
}
func main() {
// no panic

Keybase proof

I hereby claim:

  • I am roustem on github.
  • I am roustem (https://keybase.io/roustem) on keybase.
  • I have a public key ASAydHUtI9pDZiM5XGGifDoFY_ZPnoLcdTyIn4KCoRiMtAo

To claim this, I am signing this object:

@roustem
roustem / main.go
Created September 13, 2016 23:50
Whitelist Handler
package main
import (
_ "expvar"
"io"
"log"
"net/http"
"strings"
)
@roustem
roustem / sha256-benchmarks.js
Last active April 12, 2019 19:13
Compare SJCL and WebCrypto SHA-256
// Run on https://start.1password.com to get sjcl
function timeSJCL_SHA256(iterations, value) {
let timerName = "SJCL SHA-256 (" + value.length + " bytes, " + iterations + " iterations)";
console.time(timerName);
for (let i = 0; i < iterations; i++) {
sjcl.hash.sha256.hash(value);
}
console.timeEnd(timerName);
"B5AppSubnet1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": { "Fn::Select" : ["0", { "Fn::FindInMap" : [ "SubnetCidr", { "Ref" : "Env" }, "b5app"] }] },
"AvailabilityZone": { "Fn::Select" : [ "0", { "Fn::GetAZs" : "" } ]},
"VpcId": { "Ref": "Vpc" },
"Tags": [
{ "Key" : "Application", "Value" : "B5" },
{ "Key" : "env", "Value": { "Ref" : "Env" } },
{ "Key" : "Name", "Value": { "Fn::Join" : ["-", [ {"Ref" : "Env"}, "b5", "b5app-subnet1"]] } }
resource "aws_subnet" "b5app" {
count = "${length(var.subnet_cidr["b5app"])}"
vpc_id = "${aws_vpc.b5.id}"
cidr_block = "${element(var.subnet_cidr["b5app"],count.index)}"
availability_zone = "${var.az[count.index]}"
tags {
Application = "B5"
env = "${var.env}"
type = "${var.type}"
#
# Terraform code changes
#
# variable "instance_type" {
# type = "string"
# - default = "t2.medium"
# + default = "t2.large"
# }
data "aws_ami" "bastion_ami" {
most_recent = true
filter {
name = "architecture"
values = ["x86_64"]
}
filter {
name = "name"
values = ["bastion-*"]
@roustem
roustem / cltools.sh
Created April 28, 2018 18:09 — forked from justinbellamy/cltools.sh
Install Autoconf and Automake on OS X El Capitan
#!/bin/sh
##
# Install autoconf, automake and libtool smoothly on Mac OS X.
# Newer versions of these libraries are available and may work better on OS X
#
# This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
export build=~/devtools # or wherever you'd like to build
@roustem
roustem / Install PIP to user site on macOS.md
Created July 6, 2018 21:28 — forked from haircut/Install PIP to user site on macOS.md
How to install and use pip without sudo or admin on macOS

Install and use pip on macOS without sudo / admin access

Most recently tested on macOS Sierra (10.12.6)

  1. Download the installation script; curl https://bootstrap.pypa.io/get-pip.py -o ~/Downloads/get-pip.py
  2. Run the installation, appending the --user flag; python ~/Downloads/get-pip.py --user. pip will be installed to ~/Library/Python/2.7/bin/pip
  3. Make sure ~/Library/Python/2.7/bin is in your $PATH. For bash users, edit the PATH= line in ~/.bashrc to append the local Python path; ie. PATH=$PATH:~/Library/Python/2.7/bin. Apply the changes, source ~/.bashrc.
  4. Use pip! Remember to append --user when installing modules; ie. pip install <package_name> --user

Note