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 | |
# submit a batch job to Druid that re-index for yesterday | |
# Therefore, run this script after midnight UTC | |
RANGE_FROM=$(date --date="yesterday" +%Y-%m-%d) | |
RANGE_TO=$(date +%Y-%m-%d) | |
curl -XPOST -H 'Content-Type: application/json' http://localhost:18090/druid/indexer/v1/task -d @- <<EOF | |
{ | |
"type": "index_hadoop", |
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
package com.fasterxml.jackson.dataformat.protobuf.schema; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.ObjectWriter; | |
import com.fasterxml.jackson.dataformat.protobuf.ProtobufFactory; | |
import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; | |
import java.io.IOException; | |
import java.io.StringReader; |
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
package com.fasterxml.jackson.dataformat.protobuf.schema; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper; | |
import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase; | |
import java.io.IOException; | |
import java.io.InputStream; | |
public class DeserializeTest extends ProtobufTestBase |
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 |
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
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
/* 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
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
# 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
var sharedInstance *single | |
var once sync.Once | |
func GetInstance() *single { | |
once.Do(func() { | |
// init code here | |
sharedInstance = &single{} // instantiate | |
}) | |
return sharedInstance | |
} |