Skip to content

Instantly share code, notes, and snippets.

View yuikns's full-sized avatar

Yu yuikns

  • 22:42 (UTC +08:00)
View GitHub Profile
import scala.collection.mutable.{ Map => MMap }
object Solution {
case class PrefixTrieNode(
base: Char, // current node
next: MMap[Char, PrefixTrieNode]) {
var v: Boolean = false
}
class PrefixTrieTree {
/**********************************************************************
Author: Sherlock
Created Time: 2008-10-28 16:24:47
File Name:
Description:
**********************************************************************/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
import scala.collection.mutable.{ Map => MMap }
object Solution {
case class PrefixTrieNode(next: MMap[Char, PrefixTrieNode]) {
var v: Boolean = false
}
class PrefixTrieTree {
val root: PrefixTrieNode = PrefixTrieNode(MMap[Char, PrefixTrieNode]())
const size_t K_TH_FIND_LENGTH_THRESHOLD = 5;
template <typename T>
bool k_th_find_default_comparator(T l, T r) {
return l < r;
}
template <typename T>
void k_th_find_partition(std::vector<T> *_v, T e, //
// Copyright 2014 Yu Jing<[email protected]>
#include <cstdio>
#include <syslog.h> // syslog
#include <vector>
#include <string>
#include <map>
#include <set>
@yuikns
yuikns / CMakeLists.txt
Created May 27, 2016 04:02 — forked from eruffaldi/CMakeLists.txt
A tiny example of CUDA + OpenGL interop with write-only surfaces and CUDA kernels. Uses GLFW+GLAD.
#sudo pip install --upgrade git+https://github.com/dav1dde/glad.git#egg=glad
#python main.py --api gl=3.3 --generator=c --out-path=GL
find_package(CUDA)
find_package(GLFW)
include_directories(${GLFW_INCLUDE_DIRS})
include_directories(GL/include)
cuda_add_executable(main main.c assert_cuda.c interop.c GL/src/glad.c kernel.cu)
target_link_libraries(main ${GLFW_LIBRARY})
pub struct DataSet<X, Y> {
d: Vec<(Vec<X>, Y)>
}
impl DataSet {
pub fn new<X, Y>() -> DataSet<X, Y> {
DataSet { d: Vec::<(Vec<X>, Y)>::new() }
}
}
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > chnroute.txt
@yuikns
yuikns / start-stop-daemon-template
Created September 25, 2016 23:21 — forked from bcap/start-stop-daemon-template
Template file for creating linux services out of executables using the start-stop-daemon
#!/bin/bash
### BEGIN INIT INFO
# Provides: <service name>
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: <service description>
### END INIT INFO
@yuikns
yuikns / dict.py
Last active October 2, 2016 06:09
#!/usr/bin/python
# encoding: utf-8
import sys
import argparse
from workflow import Workflow
#from workflow import Workflow3
from DictionaryServices import *
import urllib2