Skip to content

Instantly share code, notes, and snippets.

@mks-m
mks-m / d8.clj
Last active December 27, 2018 14:26
(ns d8)
(defonce d8-input (slurp "d8.txt"))
(defonce d8-input-list (read-string (str "[" d8-input "]")))
(defn read-node [[cn mn & data]]
(let [[ccol rest]
(loop [ccol [] rest data cn cn]
(if (= 0 cn)
[ccol rest]
(let [[node rest] (read-node rest)]
@mks-m
mks-m / encrypt_decrypt.rb
Last active June 19, 2018 12:17 — forked from wteuber/encrypt_decrypt.rb
Simply encrypt and decrypt Strings in ruby.
require 'openssl'
require 'base64'
# key and iv stored in configs, generated using:
# cipher = OpenSSL::Cipher::Cipher.new('AES-256-CBC').encrypt
# key = cipher.random_key
# iv = cipher.random_iv
def encrypt_id(key, iv, id)
cipher = OpenSSL::Cipher::Cipher.new('AES-256-CBC').encrypt
@mks-m
mks-m / keybase.md
Created July 4, 2017 11:09
keybase.md

Keybase proof

I hereby claim:

  • I am keymone on github.
  • I am keymone (https://keybase.io/keymone) on keybase.
  • I have a public key whose fingerprint is 7937 BF76 A931 9144 4FB9 7BB7 E30B 109F 55EC 7BA8

To claim this, I am signing this object:

@mks-m
mks-m / fullnode.md
Last active November 13, 2023 14:26 — forked from romanz/fullnode.md
Bitcoin Full Node on AWS Free Tier

Bitcoin Full Node on AWS Free Tier

Provisioning

  • Launch one T2 micro instance, using Ubuntu 14.04 LTS AMI.
  • Open SSH and Bitcoin Protocol TCP ports: 22, 8333.
  • Attach 150GB EBS (General-Purpose SSD) volume for blockchain storage to /dev/sdf.

The pricing would be ~$15/month. See here for more details.

@mks-m
mks-m / cart_pole.py
Last active September 29, 2016 00:44
import gym
import numpy as np
import math
def atg01(x):
return 0.5 + math.atan(x) / math.pi
env = gym.make('CartPole-v0')
best = 1
@mks-m
mks-m / curlj.clj
Last active May 20, 2017 13:32
Convert curl command into http request
(def curl-opts
[["-A" "--user-agent AGENT" "User-Agent string"
:assoc-fn (fn [m _ v] (assoc-in m [:headers "User-Agent"] v))]
["-b" "--cookie DATA" "Cookie name=value"
:id :cookies :default {}
:assoc-fn (fn [m k v] (let [[kk & vv] (split v #"=")]
(assoc-in m [k kk] {:discard true
:path "/"
:value (join "=" vv)})))]
["-H" "--header DATA" "Header \"header: value\""
(defn baz [a] a)
; this does something and then returns anonymous function, closure is important
(defn bar [] (let [a b] #(do (baz a) )))
; this gets anonymous function as input and calls it
(defn foo [arg] (arg))
(foo (bar))
@mks-m
mks-m / .vimrc
Last active August 29, 2015 14:20
"
" mv ~/.vim ~/.vim.old; mkdir -p ~/.vim/bundle; pushd ~/.vim/bundle;
" git clone git@github.com:gmarik/Vundle.vim; vim +PluginInstall; popd
"
set nocompatible
" < vundle and plugins >
filetype off

Keybase proof

I hereby claim:

  • I am keymone on github.
  • I am keymone (https://keybase.io/keymone) on keybase.
  • I have a public key whose fingerprint is 664F 307D 773C 265C 2054 E89C BAEB B0D1 CA5B 3B07

To claim this, I am signing this object:

EventMachine::PeriodicTimer.new(10) do
@redis.keys("*checks*pattern*") do |keys|
@redis.get(keys) do |values|
values.each do |value|
check = MultiJson.load(value) rescue nil
next unless check
if check[:keepalive]
@redis.get("execution:key:#{check[:name]}") do |exec_time|
publish_critical if exec_time < Time.now.to_i - check[:keepalive]
end