Skip to content

Instantly share code, notes, and snippets.

@arsane
arsane / command list.md
Created August 28, 2018 06:30
gcloud command list
  • List resources filter with specified pattern
gcloud alpha resources list --filter='utopian-theater-20112'

Contacts

  • Id
  • Name
  • Email
  • Personal HP
  • Office Hp
  • Company
  • Address
@arsane
arsane / docker.md
Last active July 30, 2017 04:44
useful docker command lines

Remove old container not used over 1 month.

docker ps --filter "status=exited" | grep 'months ago' | awk '{print $1}' \
| xargs --no-run-if-empty docker rm

Copy file between docker and host

@arsane
arsane / monad.rb
Last active September 10, 2016 17:48
Optional = Struct.new(:value) do
def and_then(&block)
if value.nil?
Optional.new(nil)
else
block.call(value)
end
end
def method_missing(*args, &block)
# lambda recusion.
puts ->() {
error = ->(n) {throw "SHOULD NEVER BE CALLED"}
->(g) {
g.(g)
}.(
->(f) {
->(n) {n.zero? ? 1 : n * f.(f).(n-1)}
}
@arsane
arsane / pps.py
Created February 11, 2016 05:50
smart card pps speed dump fi/di
def dump_speed_matrix():
Fi = [ 372, 372, 558, 744, 1116, 1488, 1860, "RFU", "RFU", 512, 768, 1024, 1536, 2048, "RFU", "RFU"]
FMax = [ 4, 5, 6, 8, 12, 16, 20, "RFU", "RFU", 5, 7.5, 10, 15, 20, "RFU", "RFU"]
Di = ["RFU", 1, 2, 4, 8, 16, 32, 64, 12, 20, "RFU", "RFU", "RFU", "RFU", "RFU", "RFU"]
for fi in [0, 1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13]:
for di in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
v = Fi[fi] / Di[di]
text = "Fi=%2s(%4d), Di=%2s(%2d), %4g cycles/ETU (%7d bits/s at 3.57 MHz, %7d bits/s for fMax=%4.1f MHz)"
args = (fi, Fi[fi], di, Di[di], v, 3570000 / v, FMax[fi] * 1000000 / v, FMax[fi])
;;;; http://stuartsierra.com/2010/01/05/taming-the-gridbaglayout
(import '(javax.swing JFrame JPanel JButton JOptionPane JLabel))
(import 'java.awt.event.ActionListener)
(import '(java.awt GridBagConstraints GridBagLayout Insets))
;;;
(comment
(def button (JButton. "Click Me!"))
(def panel (doto (JPanel.)
@arsane
arsane / excel_merge.py
Created September 15, 2015 08:30
a python script to copy specified columns from one excel to another.
#!/usr/bin/python
from string import ascii_uppercase
from sys import argv
from os.path import splitext
from openpyxl import Workbook, load_workbook
S_KEY_COL = "A"
L_COLS_FILL = ["C", "D"]
N_ROW_START = 15
@arsane
arsane / ijc_dump.py
Last active September 15, 2015 08:28
dump ijc (java card applet) file.
#!/usr/bin/python
import sys
comp_tag_names = [
"None",
"Header", # 1
"Directory", # 2
"Applet", # 3
"Import", # 4
"ConstantPool", # 5
var arrays = [
[1, 4, 6, 123, 78, 8, 9, 124, 44],
[44, 6, 9, 123],
[124, 44, 16, 9, 123]
]
function findCommonElements(arrays) {
var sorted_arr = arrays.map(function(arr) {
// sort and remove duplicated elements in each array.
return arr.sort(function (a, b) {return a - b; }).reduce(function (r_arr, ele) {