Skip to content

Instantly share code, notes, and snippets.

View wings27's full-sized avatar

wings27

View GitHub Profile
@wings27
wings27 / mysql隔离级别及事务传播
Created March 15, 2016 07:25 — forked from JagoWang/mysql隔离级别及事务传播
mysql隔离级别及事务传播
TRANSACTION(事务隔离级别)
1. ISOLATION_DEFAULT:这是一个PlatfromTransactionManager默认的隔离级别,使用数据库默认的事务隔离级别。
每种数据库的默认隔离级别是不同的,例如SQL Server、Oracle默认Read Commited,MySQL默认Repeatable Read。
另外四个与JDBC的隔离级别相对应,不同的隔离级别采用不同的锁类型来实现,在四种隔离级别中,Serializable的
隔离级别最高,Read Uncommited的隔离级别最低。
2. ISOLATION_READ_UNCOMMITTED:读未提交数据,这是事务最低的隔离级别,在并发的事务中,它充许一个事务可以
读到另一个事务未提交的更新数据。(会出现脏读,不可重复读和幻读)
3. ISOLATION_READ_COMMITTED:读已提交数据,保证在并发的事务中,一个事务修改的数据提交后才能被另外一个事
@wings27
wings27 / build_fail_email.html.haml
Created September 2, 2016 10:10
replacement for /opt/gitlab/embedded/service/gitlab-rails/app/views/notify/build_fail_email.html.haml
- content_for :header do
%h1{style: "background: #c40834; color: #FFF; font: normal 20px Helvetica, Arial, sans-serif; margin: 0; padding: 5px 10px; line-height: 32px; font-size: 16px;"}
GitLab (build failed)
%h3
Project:
= link_to namespace_project_url(@project.namespace, @project) do
= @project.name
%p
@wings27
wings27 / notepad_replacer.py
Created September 15, 2016 10:21
replace notepad with SublimeText using Windows IFEO
import os.path
import subprocess as sp
import sys
import time
def main():
new_notepad = 'C:\\Program Files\\Sublime Text 3\\sublime_text.exe'
args = sys.argv[2:] # ignore the first arg (this script itself) and the second arg (original notepad.exe)
@wings27
wings27 / scanner.py
Last active June 22, 2018 23:44
python equivalent for Scanner in java.
class Scanner:
def __init__(self):
self.__line_split = None
self.__pointer = None
def next_int(self):
try:
next_str = self._next_str()
ret = int(next_str)
return ret
@wings27
wings27 / grep_modifying_sql.py
Created October 24, 2016 10:29
filter lines starting with SHOW and SELECT from a sql file
import sys
def main():
try:
sql_file = sys.argv[1]
with open(sql_file, 'r') as f:
lines = f.readlines()
filtered_lines = filter(lambda l:
not l.startswith('/*')
@wings27
wings27 / execute.sh
Last active November 11, 2016 06:14
execute DB_xxx.sql from git.
MYSQL_HOST=10.17.1.153
git checkout develop
git pull --verbose --all
SQL_DIFF=`git diff --name-only develop..release/latest | grep \.sql$`
if [[ $(echo $SQL_DIFF | grep -c ".sql") -ne 0 ]]; then
echo "Executing:"
echo $SQL_DIFF
echo
echo $SQL_DIFF | while read a; do mysql -h$MYSQL_HOST -uroot -p1 $(echo $a | cut -d'_' -f 1) < "$(echo $a)" ; done
@wings27
wings27 / .gitconfig
Created December 14, 2016 07:46
git config
[push]
default = simple
[alias]
aa = add --all
b = branch --verbose --all
bnm = branch --no-merged
ch = checkout
chd = checkout develop
chm = checkout master
chr = checkout release
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b /ad`) DO (
echo "C:\Program Files\WinRAR\Rar.exe" u -r -hpPASSWORD -m5 -- %%F %%F
)
ENDLOCAL
echo.
pause