Mysql doesn't auto lock or version lock records when select
in repeatable read
transactions. While PG can forbid concurrent updates.
The test table DDL in PG:
create table articles (
"id" serial,
"n" integer
);
Mysql doesn't auto lock or version lock records when select
in repeatable read
transactions. While PG can forbid concurrent updates.
The test table DDL in PG:
create table articles (
"id" serial,
"n" integer
);
/* | |
benchmark with gtime -f "%M" | |
pool alloc: | |
time: 0.028571 | |
22331392 | |
malloc: |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
# need to install ghostscript first | |
pdf-shrink() { | |
if [[ -e $1 ]]; then | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$2 $1 | |
else | |
echo 'usage: pdf-shrink in.pdf out.pdf' | |
fi | |
} |
def cn_id_verify id, gender=nil | |
return false if id !~ /\A\d{17}[\dX]\z/i | |
r = 0 | |
x = 1 | |
id.chars.take(17).reverse_each {|a| | |
x = (x * 2) % 11 | |
r += a.to_i * x | |
} | |
last = (12 - r % 11) | |
last = 'X' if last == 10 |
# generate a regexp for match full-width characters | |
# data from | |
# | |
# A ; Ambiguous 不确定 | |
# F ; Fullwidth 全宽 | |
# H ; Halfwidth 半宽 | |
# N ; Neutral 中性 | |
# Na ; Narrow 窄 | |
# W ; Wide 宽 | |
# |
require 'state_machine' | |
class StateMachine::Machine | |
def par_event events, test_field, trans | |
i = 1 | |
# binary 11....1 | |
full = (1 << events.size) - 1 | |
events.each do |e| | |
j = i | |
event e do | |
transition(hash.merge(:if => (lambda{ |obj| |
# 99 bottles of beer | |
class Fixnum | |
def bottle | |
"#{self} bottles of beer". | |
sub(/^-1/,'99'). | |
sub(/^0/,'no more'). | |
sub(/^(1\ .+)s/, '\1') | |
end | |
def wall | |
"#{self.bottle} on the wall" |
# state lexer | |
require 'strscan' | |
class StateLexer | |
attr_reader :state | |
class ScanError < StandardError; end | |
def initialize opts = {:states => []} |