Skip to content

Instantly share code, notes, and snippets.

View royguo's full-sized avatar

Roy Guo royguo

  • Bytedance
  • Beijing
View GitHub Profile
@royguo
royguo / index.cc
Created March 23, 2013 14:27
Inverse Index
std::vector<std::string> InverseIndex::getWords(std::string line)
{
std::vector<std::string> words;
char* str = (char*)line.c_str();
char* end = str + strlen(str) + 1;
unsigned char symbol[5] = {0,0,0,0,0};
while( str < end ){
utf8::uint32_t code = utf8::next(str, end);
@royguo
royguo / face_detection.cc
Last active December 16, 2015 12:08
human face detection
#include <stdio.h>
#include <opencv2/opencv.hpp> // for highgui, core etc.
using namespace cv;
// cascade : classifier using to detect haar objects.
// storage : memory to store detected objects.
void DetectAndDraw(CvHaarClassifierCascade* cascade,
CvMemStorage* storage,
IplImage* img,
@royguo
royguo / buffers.js
Last active December 19, 2015 01:09
WebGL-Test. index.html里是shader,buffers.js里是所有的物体
/**
* Global variables:
* bgVertexBuffer
* trianglesVertexBuffer
* cubeVertexBuffer
* cubeIndexBuffer
*/
function initBuffers() {
// bg
bgVertexBuffer = gl.createBuffer();
@royguo
royguo / BufferTest.java
Created July 16, 2013 08:16
双Buffer切换的一个Java小实验
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class BufferTest {
private static volatile List<String> list = new ArrayList<String>();
public static void init() {
@royguo
royguo / Leaves.java
Last active December 30, 2015 08:29
Java Mail using Playframework
package controllers.oa;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import models.oa.Leave;
import models.oa.Vacation;
import models.system.User;
package main;
import java.util.concurrent.atomic.AtomicReference;
public class CASCalculator extends CalculatorBase {
private enum Status {
NOT_STARTED,
STARTED,
DISPOSED
#include <iostream>
#include <terark/db/db_table.hpp>
#include <terark/io/MemStream.hpp>
#include <terark/io/DataIO.hpp>
#include <terark/io/RangeStream.hpp>
#include <terark/lcast.hpp>
#include "user.hpp"
jstests/aggregation/mongos_slaveok.js
jstests/aggregation/testshard1.js
jstests/aggregation/testSlave.js
jstests/aggregation/bugs/match.js
jstests/aggregation/bugs/server19095.js
jstests/aggregation/bugs/server21632.js
jstests/aggregation/bugs/server6118.js
jstests/aggregation/bugs/server6125.js
jstests/aggregation/bugs/server6179.js
jstests/aggregation/bugs/server6556.js
@royguo
royguo / wiki-media.sql
Created June 15, 2017 04:26
WIKI Media SQL Schema
-- SQL to create the initial tables for the MediaWiki database.
-- This is read and executed by the install script; you should
-- not have to run it by itself unless doing a manual install.
-- This is a shared schema file used for both MySQL and SQLite installs.
--
-- For more documentation on the database schema, see
-- https://www.mediawiki.org/wiki/Manual:Database_layout
--
-- General notes:
@royguo
royguo / mapsun.hpp
Last active December 23, 2018 09:23
test demo
// https://www.lintcode.com/problem/map-sum-pairs/description
class MapSum {
class TrieNode {
public:
unordered_map<char, TrieNode*> children;
int val = 0;
TrieNode() {}
TrieNode(const int& val) : val(val) {