Skip to content

Instantly share code, notes, and snippets.

View roustem's full-sized avatar

Roustem Karimov roustem

View GitHub Profile
"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"]] } }
@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);
@roustem
roustem / main.go
Created September 13, 2016 23:50
Whitelist Handler
package main
import (
_ "expvar"
"io"
"log"
"net/http"
"strings"
)

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 / 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
package main
import "fmt"
type myError struct {
Message string
}
func (m *myError) Error() string {
return "MyError: " + m.Message
@roustem
roustem / err.go
Created August 19, 2016 20:36
Go interface issue
package main
import "fmt"
type MyError struct {
Message string
}
func (m *MyError) Error() string {
return m.Message
@roustem
roustem / list.md
Last active November 11, 2015 07:26
WebCrypto in 1Password for Teams

WebCrypto APIs:

subtle.generateKey
subtle.exportKey
subtle.importKey
subtle.deriveBits
subtle.encrypt
subtle.decrypt
subtle.digest
@roustem
roustem / Terraform-Blue-Green-AWS.md
Created October 9, 2015 06:20 — forked from ryan0x44/Terraform-Blue-Green-AWS.md
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.

@roustem
roustem / mysql-foreign-keys-deadlock.sql
Last active February 19, 2023 23:00
MySQL Foreign Keys Deadlock
--
-- This example shows how bad MySQL is when handling foreign key locks.
-- Deadlock happens when multiple transactions are inserting child records
-- pointing to the same parent and then try to update the parent record.
--
-- The solution is to always try to update the parent record first
-- but it could be hard to track the when database schema is more complex.
--
-- Based on: https://bugs.mysql.com/bug.php?id=48652
--