Skip to content

Instantly share code, notes, and snippets.

@noppanit
noppanit / gist:6587723
Created September 16, 2013 22:54
A script to merge all csv files together. All the csv files must have the same headers.
#!/bin/sh
#Credit: https://linuxprograms.wordpress.com/2007/06/17/shell-script-to-recursively-list-files/
DIR="."
count=1
function list_files()
{
if !(test -d "$1")
@noppanit
noppanit / TestMemoryConsumption
Created December 5, 2013 10:57
One quick test to test memory consumption.
package com.noppanit;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import java.io.Serializable;
import java.util.HashMap;
@noppanit
noppanit / sample-data.js
Created November 24, 2017 16:57
Sampling data
const samples = [];
sampleSize = 5;
records = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
records.forEach((record, index) => {
if (samples.length < sampleSize) {
samples.push(record);
} else {
let rand = Math.floor(Math.random() * index);
if (rand < sampleSize) {