This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS bm_roles; | |
DROP TABLE IF EXISTS bm_users; | |
DROP TABLE IF EXISTS bm_data; | |
CREATE TABLE bm_roles ( | |
name String, | |
roles AggregateFunction(groupBitmap, UInt64) | |
) ENGINE=Memory; | |
CREATE TABLE bm_users ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OUTDIR=. | |
IGNORE_DBS="system information_schema INFORMATION_SCHEMA default tmp" | |
# supply options here as needed | |
CLIENT="clickhouse-client" | |
$CLIENT -q "SHOW DATABASES" | while read -r db ; do | |
$CLIENT -q "SHOW TABLES FROM $db" | while read -r table ; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: find the minimal package. | |
apt install qt5-default qtcreator | |
# Steps to create Qt app. | |
# 1. create main.cpp | |
# 2. create .pro file | |
# 3. create Makefile from .pro file | |
# 4. run make | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sharedInstance *single | |
var once sync.Once | |
func GetInstance() *single { | |
once.Do(func() { | |
// init code here | |
sharedInstance = &single{} // instantiate | |
}) | |
return sharedInstance | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple tornado app that implements fitbit oauth login. | |
# requires tornado 2.4-ish. run on the command line like so: | |
# $ python fitbit_auth_example.py --port=<your port> \ | |
# --fitbit_consumer_key=<your consumer key> \ | |
# --fitbit_consumer_secret=<your consumer secret> | |
# | |
# make sure to set your fitbit app's callback URL to | |
# http://your-app-url.example.com/login | |
import tornado.web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import operator | |
from sqlalchemy import func, column, select, text, between | |
from sqlalchemy.schema import * | |
from sqlalchemy.sql import sqltypes | |
from sqlalchemy.sql.functions import GenericFunction | |
class hyperunique(GenericFunction): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Tested in macOS Mojave (Dec 31, 2018) using Xcode 10.1 | |
* 1. Create a new Xcode project | |
* 2. Select macOS | |
* 3. Pick Cocoa App, give it a name, create | |
* 4. Open the project setting, click "Capabilities", goto "App Sandbox" -> "Hardware" -> check "Camera" | |
* 5. Open Info.plist of the project, and add row "Privacy - Camera Usage Description", give it some description | |
* 6. Open ViewController, and paste the code below | |
* 7. Click Play icon, give Cam access permissson "OK" | |
* 8. Voila! Preview screen! | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functional import seq | |
from pymongo import MongoClient | |
class dotdict(dict): | |
"""dot.notation access to dictionary attributes""" | |
__getattr__ = dict.get | |
__setattr__ = dict.__setitem__ | |
__delattr__ = dict.__delitem__ | |
client = MongoClient('mongodb://localhost:27017/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <iostream> | |
#define BOOST_FILESYSTEM_NO_DEPRECATED | |
#define BOOST_FILESYSTEM_VERSION 3 | |
#include <boost/filesystem.hpp> | |
#include <google/protobuf/compiler/importer.h> | |
#include <google/protobuf/io/zero_copy_stream_impl.h> | |
#include <google/protobuf/dynamic_message.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import argparse | |
from collections import namedtuple | |
class Record: | |
def __init__(self, crtime=0.00000, ch=1, hexid=0x000, dir="Rx", stat="d", data=None, length=0, bitcount=0, decid=0): | |
self.crtime = crtime | |
self.ch = ch | |
self.hexid = hexid |
NewerOlder