Skip to content

Instantly share code, notes, and snippets.

@bootleq
bootleq / WordTransform.vim
Last active October 14, 2020 05:54
vimrc snippet
" camelCase / under_score / kekab-case 轉換
function! s:case_tx_subs_camel(w) "{{{
let w = substitute(a:w, '-', '_', 'g')
return substitute(w, '_\([a-z]\)', '\u\1', 'g')
endfunction "}}}
function! s:case_tx_subs_kekab(w) "{{{
let w = s:case_tx_subs_snake(a:w)
return tr(w, '_', '-')
@bootleq
bootleq / vimrc
Created September 8, 2020 10:26
vimrc
" Vim configure file
" Author: bootleq <bootleq@gmail.com>
" Blog: bootleq.blogspot.com
" ============================================================================
" 7.4.1154 jsonencode() jsondecode() v:true v:null v:none
" 8.1.1068 complete_info()
" 8.1.1071 screenstring()
" 8.1.1056 rubyeval()
" 8.1.0846 has() bsd, linux, ...
@bootleq
bootleq / vagrant.log
Last active June 16, 2018 08:42
@hashicorp/vagrant/#9941: Debug output of `VAGRANT_LOG=debug VAGRANT_POWERSHELL_VERSION_DETECTION_TIMEOUT=2 vagrant status`
INFO global: Vagrant version: 2.1.1
INFO global: Ruby version: 2.4.4
INFO global: RubyGems version: 2.6.14.1
INFO global: VAGRANT_DETECTED_ARCH="32"
INFO global: VAGRANT_DETECTED_OS="cygwin"
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\2.1.1\\gems\\vagrant-2.1.1\\bin\\vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_LOG="debug"
@bootleq
bootleq / awesome_print.rb
Created February 8, 2018 08:05
Change certain classes' `ap` (awesome_print) display
module AwesomePrint
# Make awesome_print aware of certain classes and format differently
module YourName
def self.included(base)
base.send :alias_method, :cast_without_your_name, :cast
base.send :alias_method, :cast, :cast_with_your_name
end
def cast_with_your_name(object, type)
cast = cast_without_your_name(object, type)
@bootleq
bootleq / .pryrc
Created February 8, 2018 07:56
Pry `db-exec` command
if defined?(ActiveRecord::Base)
Pry::Commands.create_command 'db-exec' do
description 'Run SQL statement with ActiveRecord::Base.connection'
banner <<-BANNER
Usage: db-exec [ > OUTPUT ] STATEMENT
db-exec [ > OUTPUT ] < INPUT
db-exec < INPUT > OUTPUT
Examples:
@bootleq
bootleq / .tmux-in.rb
Created February 28, 2016 11:02
Script to serve Tmux `copy-pipe` input
#!/usr/bin/env ruby
type = ARGV.shift
# Support both ARGV (normal argument) and ARGF (tmux copy-pipe)
arg = ARGV.any? ? ARGV.join(' ') : ARGF.read
case type
@bootleq
bootleq / xhtml.html
Created October 5, 2015 13:00
Example file for testing webapi.vim xml#parse
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TEST XML PARSER</title>
</head>
<body><p>FOOBAR</p></body>
</html>
@bootleq
bootleq / upgrade_tig.sh
Created October 4, 2015 05:52
Install tig from source
#!/bin/bash
if which apt-get 2>&1 >/dev/null; then
[[ -z $(dpkg --get-selections | grep libncursesw5-dev) ]] && sudo apt-get install -y libncursesw5-dev
elif which brew 2>&1 >/dev/null; then
brew install tig --with-docs
exit
fi
@bootleq
bootleq / upgrade_git.sh
Created September 15, 2015 12:08
Install git from source
#!/bin/bash
if which apt-get 2>&1 >/dev/null; then
sudo apt-get install -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
fi
cd ~/src
[[ ! -d git ]] && git clone https://github.com/git/git --depth 10
@bootleq
bootleq / .zshrc
Last active August 29, 2015 14:27
Find ssh-agent and do ssh-add if needed
sshAgentFind() {
# Ref https://github.com/wwalker/ssh-find-agent
local -a sockets
if [[ -z "$SSH_AUTH_SOCK" ]] ; then
sockets=("${(@f)$(find /tmp/ -type s -path '/tmp/ssh-*/agent.*' -user $USER)}")
for socket in $sockets; do
SSH_AUTH_SOCK=$socket ssh-add -l 2> /dev/null > /dev/null
if [[ $? -eq 0 ]]; then
export SSH_AUTH_SOCK=$socket