Skip to content

Instantly share code, notes, and snippets.

@lotuc
lotuc / java-util-uuid-string.js
Last active August 24, 2023 14:07
JavaScript implementation of java.util.UUID's stringify
// https://stackoverflow.com/questions/75387792/javascript-equivalent-of-javas-uuid-class/76967385#76967385
// assume x under range of signed long value
function unsignedBitShiftRight(x, n) {
if (n === 0) { return x; }
else if (x >= 0) { return x >> n; }
// convert to two's complement and then do the shifting
else { return (((1n << 64n) - 1n) ^ (- (x + 1n))) >> n; }
}
@lotuc
lotuc / camel_snake_kebab_rexport.clj
Last active May 25, 2023 04:34
Clojure Utilities
(ns camel-snake-kebab-rexport
(:require
[camel-snake-kebab.core :as csk]
[camel-snake-kebab.internals.string-separator
:refer [split classify-char StringSeparator]]))
;;; kebab patch
;;; https://gist.github.com/lotuc/fba421f74ea8610494118bc899f9f1b5#file-camel_snake_kebab_utils-clj
(defn generic-split [ss]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Seven Implementations of Incremental ;;
;; https://www.youtube.com/watch?v=G6a5G5i4gQU ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0:03: so I want to give you guys a talk about a library that we use internally
here called incremental and only some of you
0:12: have actually used incremental so I'll talk a little bit about what
incremental
@lotuc
lotuc / format-youtube-transcript.clj
Created April 12, 2023 13:41
Format youtube transcript
;; Go to video.
;; Click the three dot menu below the video.
;; Click open transcript.
;; Click and drag to highlight the whole transcript.
;; Save to /tmp/a.txt
;; Run this with clj/babashka
(require '[clojure.string :as str])
(->> (iterate (fn [[r lines]]
(ns etaoin.dev-patch
(:require [etaoin.dev :refer [get-performance-logs]]
[clojure.string :as str]))
(defn- try-parse-int
[line]
(try (Integer/parseInt line)
(catch Exception _e
line)))
@lotuc
lotuc / create_namespace_and_serivce_account_for_it.sh
Last active January 4, 2020 07:06
Create a kubernetes namespace & create a service account with full access to this namespace and access to this namespace only & generate the service account's config file for kubectl
#!/usr/bin/env bash
# namespace you want to create
NAMESPACE=<namespace>
# cluster configuration
CLUSTER_SERVER=https://<your-cluster-endpoint>
CLUSTER_NAME=<your-cluster-name>
# customize these names as needed
@lotuc
lotuc / expect-sample.sh
Created March 2, 2019 05:23
MISC Scripts
#!/usr/bin/env expect
spawn some command ...
expect 'some string'
send 'sth...\n'
# Interaction (eg, for a shell)
interact
@lotuc
lotuc / init.vim
Last active February 25, 2019 08:32
nvim
" vim-plug {{{
call plug#begin()
Plug 'jiangmiao/auto-pairs'
call plug#end()
" }}} vim-plug
" Spaces & Tabs {{{
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent
@lotuc
lotuc / idea-config.org
Last active February 6, 2019 09:11
Intellij Idea Related

Plugins

  • IdeaVim
  • Lombok
  • google-java-format

Shortcuts

Base on MacOS X 10.5+

shortcutsusage
@lotuc
lotuc / search_text_in_pdf.py
Created January 18, 2019 07:07
PDF 文本搜索
#!/usr/bin/env python3
'''
pip install pdfminer3k
'''
from pdfminer.pdfparser import PDFParser, PDFDocument
from pdfminer.pdfinterp import PDFTextExtractionNotAllowed
from pdfminer.layout import LAParams, LTTextContainer
from pdfminer.converter import PDFPageAggregator
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter