Skip to content

Instantly share code, notes, and snippets.

@wingchen
wingchen / rmongo_queries.r
Last active January 4, 2016 12:19
Turning my MongoDB queries into R data.frame type. This code example is written for my blog post: Building up an easy data analysis platform with RStudio server on top of your MongoDB: http://winston.attlin.com/2014/01/building-up-easy-data-analysis-platform.html
## The collection structure looks like this:
##{
## "col1": "some value 1",
## "col2": 1234,
## "col3": "somevalue 3",
## "col4": "some value 4",
## "col5": "some value 5",
## "col6": [
## {
## "some": 1,
@wingchen
wingchen / AttlinInMemoryCache.scala
Last active December 23, 2015 08:59
A little in memory cache that cleans itself and limit the the max size with AKKA.
package com.attlin.web.cache
import scala.collection.mutable.HashMap
import _root_.scala._
import java.util.Date
import akka.actor.Actor
import akka.actor.Props
import scala.concurrent.duration._
import org.apache.commons.lang.time.DateUtils
@wingchen
wingchen / fliptop_api.rb
Last active December 14, 2015 06:39
Fliptop API Code Example in Ruby. The 202 retry mechanism is built up into FliptopAPIRetryClass. To run this script, simply type 'ruby fliptop_api.rb' into your terminal.
#!/usr/bin/env ruby
require 'net/http'
require 'thread'
require 'rubygems'
require 'json'
FLIPTOP_API_KEY = 'your fliptop api key'
# this queue represent all the email inputs from your database
# please feel free to replace this queue into any data source that
@wingchen
wingchen / FliptopApi.java
Last active December 14, 2015 06:38
Fliptop API Code Example in java The 202 retry mechanism is built up into the202RetryQueue and FliptopAPIRetryClass. In order to run this code, you will have to download 'org.apache.httpcomponents(for HttpClient)', 'org.codehaus.jackson(for json-pojo conversion)', and 'commons-lang(for DateUtils)'. If you are using Maven, you can find pom.xml in…
package com.fliptop.api;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.codehaus.jackson.map.ObjectMapper;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.commons.lang.time.DateUtils;
@wingchen
wingchen / fliptop_api.py
Last active December 14, 2015 05:29
Fliptop API Code Example in Python The 202 retry mechanism is built up into the_202_retry_queue and FliptopAPIRetryClass. To run this script, simply type 'python fliptop_api.py' into your terminal.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
from datetime import datetime
import json
import threading
from collections import deque
import time
FLIPTOP_API_KEY = 'your fliptop api key'