Skip to content

Instantly share code, notes, and snippets.

@lotuc
lotuc / ColorPrint.java
Last active March 21, 2017 16:27
Java color print
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class ColorPrint {
public static final String ANSI_RESET = "\u001B[0m";
public static final String ANSI_BLACK = "\u001B[30m";
public static final String ANSI_RED = "\u001B[31m";
public static final String ANSI_GREEN = "\u001B[32m";
public static final String ANSI_YELLOW = "\u001B[33m";
@lotuc
lotuc / tmux.conf
Last active November 5, 2020 23:51
tmux configuration
unbind-key C-b
set -g prefix 'C-x'
bind-key 'C-x' send-prefix
set -g base-index 1
# tmux attach - attach a session, if none exists, create one.
new-session -n $HOST
# Automatically set window title
@lotuc
lotuc / .bash_profile
Last active February 22, 2019 09:51
macOS Bash Configuration
. ~/.bashrc
@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
@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 / 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 / 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 / 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
(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 / 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]]