Skip to content

Instantly share code, notes, and snippets.

View beeender's full-sized avatar
🤡

Chen Mulong beeender

🤡
  • VMware
  • Beijing, China
View GitHub Profile
type Conn struct {
dbconn *dbconn.DBConn
}
type ConnPair struct {
src *Conn
dest *Conn
}
type ConnInfo struct {

MPP FDW

CREATE SERVER server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
    FOREIGN DATA WRAPPER fdw_name
    [ OPTIONS ( option 'value' [, ... ] ) ]
sub() {
to_replace=""
for var in "$@"
do
if [ -z "$to_replace" ]
then
to_replace=$var
else
RAW_STR=$(echo $RAW_STR | sed "s/${to_replace}/${var}/g")
to_replace=""

CaliburnMicro to make MVVM with WPF easier

Compared with MVC, MVVM does a better job to decouple the Views from other modules. It is supposed to even allow designers to write the View part. But, without the right tools, the View layer can be unbelievably complex. Don't mention the View is usually presented in XML -- the most flexible and complicated thing in the world. If you have experienced writing an application with the raw WPF, you will know what I am saying. The XAML view is getting fatter and fatter, lots of boilerplate code. Sometimes you have to write all of the boilerplate code without code completion since the data binding is dynamic. CaliburnMicro is all about writing less code in a natural way.

Nature way for data binding

Let's start with a simple example:

TEST_CASE("results: benchmark") {
InMemoryTestFile config;
config.cache = false;
config.schema = Schema{
{"object", {
{"int", PropertyType::Int},
{"intIndexed", PropertyType::Int, false, true},
{"string", PropertyType::String},
{"stringIndexed", PropertyType::String, false, true},
}},
#include <stdlib.h>
#include <time.h>
TEST_CASE("438") {
srand(time(nullptr));
InMemoryTestFile config;
config.automatic_change_notifications = false;
auto r = Realm::get_shared_realm(config);
r->update_schema({
{"filter", {
@Test
public void breaking_changes() throws InterruptedException {
// # Global Realm listeners -- Both Realm & DynamicRealm#
// ## The global Realm change listener will be called immediately when commitTransaction() on the same thread ##
realm.addChangeListener(new RealmChangeListener<Realm>() {
@Override
public void onChange(Realm element) {
// Notice this will be called 3rd in the next event loop in the old implementaion.
RealmLog.info("This will be printed 2nd.");
}
@beeender
beeender / mem_usage.sh
Created July 15, 2016 09:48
Script to show the average/peak memory usage for Android app.
#!/bin/zsh
OUTPUT=""
PROCESS_EXISTS=false
PROCESS_STARTED=false
COUNT=0
JAVA_HEAP_TOTAL=0
NATIVE_HEAP_TTAL=0
JAVA_HEAP_AVG=0
@Test
public void dateSort() {
Date d20160127 = new GregorianCalendar(2016, Calendar.JANUARY, 27).getTime();
Date d20160227 = new GregorianCalendar(2016, Calendar.FEBRUARY, 27).getTime();
Date d20160510 = new GregorianCalendar(2016, Calendar.MAY, 10).getTime();
Date d20160527 = new GregorianCalendar(2016, Calendar.MAY, 27).getTime();
Date begin = new GregorianCalendar(2016, Calendar.JANUARY, 1).getTime();
Date end = new GregorianCalendar(2016, Calendar.FEBRUARY, 29).getTime();