Skip to content

Instantly share code, notes, and snippets.

View thinker3's full-sized avatar
🎯
Focusing

Ken Chen thinker3

🎯
Focusing
  • solo
  • Chongqing
View GitHub Profile
@cweinberger
cweinberger / mysql-drop-all-tables.sh
Created June 6, 2018 12:44
drops all tables of a specific db
#!/bin/bash
#usage: mysql-drop-all-tables -d database -u dbuser -p dbpass
TEMP_FILE_PATH='./drop_all_tables.sql'
while getopts d:u:p: option
do
case "${option}"
in
@tiann
tiann / auto_switch_kb.py
Created December 2, 2015 06:51
auto switch keyboard to english in specific applications
#! /usr/bin/env python
# coding: utf-8
'''
auto switch keyboard between different applications
if you want to change the app list, modify the var 'ignore_list'
'''
from AppKit import NSWorkspace, NSWorkspaceDidActivateApplicationNotification, NSWorkspaceApplicationKey
@JetXing
JetXing / IDCard.java
Last active December 3, 2020 14:28
java, 身份证号的正则表达式, regular expression for ID card
package com.gitcafe.android.base.fragment;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.regex.Matcher;
# Put this in ~/.nvim/pythonx/
# requires python, see :he nvim-python
from threading import Thread
from time import sleep, strftime
class EventLoop(Thread):
def __init__(self, vim):
super(EventLoop, self).__init__()
self.vim = vim
@mdavey
mdavey / globalhotkeys.py
Created June 5, 2014 09:51
Global hot keys in Python for Win32
import ctypes
import ctypes.wintypes
import win32con
class GlobalHotKeys(object):
"""
Register a key using the register() method, or using the @register decorator
Use listen() to start the message pump
@christoomey
christoomey / json-vim-config.md
Last active January 4, 2018 18:24
Configuration for better JSON editing in Vim

Install jsonlint to act as syntastic json checker:

$ npm install jsonlint -g

Tell syntatastic about it:

" in your ~/.vimrc
# ASIA
_ = '173.194.36.%s' # del 印度 新德里
SG3 = '173.194.38.%s' # 新加坡
TW3 = '173.194.72.%s'
SG4 = '173.194.117.%s'
JP2 = '173.194.120.%s'
_ = '173.194.123.%s'
JP1 = '173.194.126.%s'
HK1 = '173.194.127.%s'
TW1 = '74.125.23.%s'
@phette23
phette23 / current-dir-in-iterm-tab-title.sh
Last active June 4, 2024 01:52
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html