Skip to content

Instantly share code, notes, and snippets.

View leonlee's full-sized avatar
🎯
Focusing

Leon Lee leonlee

🎯
Focusing
  • ACAR
  • Beijing
View GitHub Profile
@leonlee
leonlee / Merging tables with INSERT...ON DUPLICATE KEY UPDATE
Created March 14, 2013 07:56
Merging tables with INSERT...ON DUPLICATE KEY UPDATE
http://code.openark.org/blog/mysql/merging-tables-with-insert-on-duplicate-key-update
Had a case recently where I had to merge data from two identically structured tables containing nearly identical data.
"Nearly identical" meaning most table data is identical in both; sometimes a row is missing from one of the tables; sometimes same row (according to PK) appears in both, but some columns are NULL is one tables (while others can be NULL in the second).
Otherwise no contradicting data: it was not possible for some data to be "3" in one table and "4" in the other.
How do you create a merge of the tables, such that all missing rows are completed, and NULLs replaced by actual values when possible?
%%%-------------------------------------------------------------------
%%% @author Fernando Benavides <fernando.benavides@inakanetworks.com>
%%% @copyright (C) 2011 Inaka Networks S.R.L.
%%% @doc It listens and just repeats...
%%% @end
%%%-------------------------------------------------------------------
-module(gen_event_repeater).
-author('Fernando Benavides <fernando.benavides@inakanetworks.com>').
-behaviour(gen_event).
%%% @author Sergey Prokhorov <me@seriyps.ru>
%%% @copyright (C) 2013, Sergey Prokhorov
%%% @doc
%%% Walker alias method - efficient random selection with defined probabilities.
%%% <http://en.wikipedia.org/wiki/Alias_method>
%%%
%%% > ProbabilityValueList = [{10, a}, {20, b}, {30, c}, {40, d}],
%%% > WalkerVectors = walker_alias:build(ProbabilityValueList),
%%% > RandomValue = walker_alias:choice(WalkerVectors).
%%%
for (var j:int = 0; j < lengthItem; j++) {
sumItem += items[i].qty;
}
# Screen Options ##
shell bash # Tell screen your default shell
startup_message off # Turn off start message
defscrollback = 5000
shelltitle '$ |bash' # Dynamic window titled for running program
msgwait 1 # Set messages timeout to one second
nethack on # Turn on nethack error messages
backtick 0 0 0 whoami # Set "%0`" to equal the output of "whoami"
escape ^Oo
@leonlee
leonlee / aria2.conf
Created May 15, 2014 10:48
aria2.conf
# `host` is where aria2c is running on
host='localhost'
dir="/home/hassan/Downloads"
# cleanup_policy
# avalible options are
# "clean_got": clean downloads with mark as got
# "space_usage: clean got downloads on space usage upper than cleanup_percent
cleanup-policy="clean_got"
cleanup-percent="90%"
"20091020
let mapleader=";"
" " " 映射
" " 页面操作
" 一次移动5行
noremap j 5j
noremap k 5k
" 上下滚动
@leonlee
leonlee / linesplit.lua
Created February 9, 2015 09:07
tome4 chn 英文空格保留
-- 删除字符串中的空格和制表符
function delSpaceTxt(txt)
local chr = txt
local chr_new = ""
local len_chr = chr:len()
local cur_char
for i = 1 , len_chr do
cur_char = chr:sub(i,i)
if cur_char ~= " " and cur_char ~= "\t" then
chr_new = chr_new..cur_char
leon@ws-svr:~/lab/nim4c$ gcc -o m -Inimcache -I/home/leon/opt/nim/lib nimcache/*.c mth.c
nimcache/system.c: In function ‘allocinv_34409’:
nimcache/system.c:7867:10: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘NI’ [-Wformat=]
printf("%ld %p\012", (*it).Zerofield, it);
^
nimcache/system.c: In function ‘writecell_49018’:
nimcache/system.c:8330:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘NI’ [-Wformat=]
fprintf(stdout, "[GC] %s: %p %d rc=%ld; color=%ld\012", msg, c, kind, (NI)((NU64)((*c).Refcount) >> (NU64)(3)), (NI)((*c).Refcount & 3));
^
nimcache/system.c:8330:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘long long int’ [-Wformat=]

Spark project AS3 library list

Graphics/Color (AS3)