Skip to content

Instantly share code, notes, and snippets.

View focusj's full-sized avatar
💭
looking for a remote job

kangwang focusj

💭
looking for a remote job
View GitHub Profile
var node = db.getSiblingDB("db1");
var rs = db.getSiblingDB("db2");
function prepareMsgIds(table) {
var iter = table.find({"_id":{"$regex":"^sq:"}});
return iter;
}
//FIXME: performace
function districtArray(array) {
@focusj
focusj / null
Created January 20, 2014 16:43
for test
package sample.remote.test
import scala.actors.threadpool.Executor
import scala.actors.threadpool.Executors
import java.util.concurrent.ExecutorService
class Test1 {
private val map = scala.collection.mutable.HashMap[Int, String]()
def get(index: Int) = synchronized {
@focusj
focusj / gist:9018004
Created February 15, 2014 11:29
SimpleActorExample
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
class PrinterActor extends Actor {
def receive = {
case any => println(Thread.currentThread().getName())
}
}
@focusj
focusj / Test
Last active August 29, 2015 14:01
Example for testing MongoDB GeoIndex
mport com.mongodb.{Mongo, BasicDBObject, DBObject}
import scala.collection.convert.WrapAsJava
object Test extends App with WrapAsJava {
val mongo = new Mongo("host").getDB("TestGeoDB").getCollection("city")
private val line2Bson: String => DBObject = line => {
val Array(_id, country, city, lati, longi, elevation) = line.split(";").map(_.replace("\"", ""))
new BasicDBObject(
mapAsJavaMap(Map(
@focusj
focusj / Mongoose_tour_01
Created June 21, 2014 04:08
mongoose 官方文档学习
/**
* Created by focusj on 14-6-20.
*/
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.connect('mongodb://10.0.1.39:30000/TestGeo');
var db = mongoose.connection;
@focusj
focusj / CoffeeScript-CheetSheets
Created December 13, 2014 15:26
记录了一些CoffeeScript一些语法方便查阅
# CoffeeScript CheetSheet#
## Declaration
### there is no vars, and no need to add ';' and the end
i = 10
str = "hello world"
[firstName, lastName] = ["kang", "wang"]
@focusj
focusj / gist:bd3b6165364764d1b70814faf256c4e4
Created August 22, 2017 04:26
netty too many open files exception detail
Exception in thread "vert.x-eventloop-thread-0" java.lang.InternalError: java.io.FileNotFoundException: /usr/lib/jvm/java-8-oracle/jre/lib/ext/cldrdata.jar (Too many open files)
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:1040)
at sun.misc.URLClassPath.getResource(URLClassPath.java:239)
at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
@focusj
focusj / ByteBufExample
Created September 11, 2017 04:27
Netty ByteBuf Example
package netty.toturials;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.ByteProcessor;
/**
* 1. ByteBuf根据其分配空间不同有可以分为三种:JVM堆内的,直接内存,组合的。堆内受JVM的管辖,使用上相对安全一些,但是要注意GC是会影响性能。
* 直接内存不受JVM的管控,在编程的时候要注意不用的ByteBuf要手动释放,否则会造成内存泄漏。
* <p>
https://gist.github.com/dangbiao1991/7825db1d17df9231f4101f034ecd5a2b
https://gist.github.com/dangbiao1991/7825db1d17df9231f4101f034ecd5a2b