Skip to content

Instantly share code, notes, and snippets.

View zhuomingliang's full-sized avatar

Jimmy Zhuo zhuomingliang

  • Gan Zhou, China
View GitHub Profile
#include <stdio.h>
#include <stdint.h>
typedef union {
int64_t c;
struct {
int32_t a;
int16_t b;
} r;
} t;
-- check for containment
-- i.e. index A contains index B
-- and both share the same first column
-- but they are NOT identical
WITH index_cols_ord as (
SELECT attrelid, attnum, attname
FROM pg_attribute
JOIN pg_index ON indexrelid = attrelid
WHERE indkey[0] > 0
-- check for exact matches
WITH index_cols_ord as (
SELECT attrelid, attnum, attname
FROM pg_attribute
JOIN pg_index ON indexrelid = attrelid
WHERE indkey[0] > 0
ORDER BY attrelid, attnum
),
index_col_list AS (
SELECT attrelid,
@zhuomingliang
zhuomingliang / gist:df6910b982458dd6571b
Last active August 29, 2015 14:06
bash completion for (rakudo?) perl6 from http://pastebin.com/JNKuF4KY, firefish5000++
# bash completion for (rakudo?) perl6
# Usefull looking things that may or may not exist
# _filedir
_panda_read_json_perl() {
perl <<'HEREPERL'
use feature qw{say};
use utf8;
binmode STDOUT, q{:utf8};
use Module::Load::Conditional qw[can_load]; # builtin, so safe?
<fontconfig>
<match target="pattern">
<test qual="any" name="family">
<string>serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Noto Sans S Chinese</string>
<string>Noto Sans T Chinese</string>
<string>Noto Sans Japanese</string>
<string>Noto Sans Korean</string>
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %Cblue<%an>%Creset' --abbrev-commit --date=relative
@zhuomingliang
zhuomingliang / Inverse_fizzbuzz.php
Last active January 17, 2020 11:16
Inverse fizzbuzz
<?php
class FizzBuzz {
public function __construct($number) {
$this->number = $number;
}
public function __toString() {
if ($this->number < 1) return '';

##MoarVM source C language macros

Alphabetical list of all (over 700) C language macros defined in the src/ subtree of MoarVM (https://github.com/MoarVM/MoarVM). Generated by script included at the end.

Macros in .h files

####ATKEY(vm, hash, k) src/mast/nodes_moarvm.h:149 #define ATKEY(vm, hash, k) (MVM_repr_at_key_boxed(vm, hash, k))

@zhuomingliang
zhuomingliang / gist:6077134
Last active December 20, 2015 05:19
What we need when do apr => libuv in MoarVM

apr => libuv

What we need when do apr => libuv in MoarVM

NOTE: the no means it may be not found (by me) or not existed at all, but we can added it to libuv by ourself.

Threads

NOTE: libuv has a thread pool.

@zhuomingliang
zhuomingliang / fib(28) benchmarks between Parrot, Perl5 and MoarVM
Last active December 18, 2015 01:29
fib(28) benchmarks between Parrot, Perl5 and MoarVM
$ parrot fib.pir # Parrot
fib(28) = 317811
start : 1370329827.014
end : 1370329829.229
end - start: 2.21500015258789
$ perl fib.pl # Perl 5
fib(28) = 317811
start : 1370329768.826
end : 1370329769.45