Skip to content

Instantly share code, notes, and snippets.

View tuan3w's full-sized avatar
👋

Tuan Nguyen tuan3w

👋
View GitHub Profile
@tuan3w
tuan3w / task_construct.c
Created November 26, 2013 09:27
task_construct.c
#include <pthread.h>
#include <stdio.h>
#include <vector>
#include <unistd.h>
#include <stdlib.h>
struct Job {
void* (*func)(void*);
void *param;
void (*reduce)(void*);
@tuan3w
tuan3w / active.md
Created January 15, 2014 11:37 — forked from paulmillr/active.md

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Sun, 13 Jan 2013 21:59:04 GMT till Mon, 13 Jan 2014 21:59:04 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -&gt; user.followers &gt; 233)
@tuan3w
tuan3w / latency.txt
Last active August 29, 2015 14:24 — forked from jboner/latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@tuan3w
tuan3w / blas.sh
Created November 9, 2015 04:24 — forked from jarutis/blas.sh
get native blas running with dl4j on centos 6
# install general deps
sudo yum groupinstall "Development Tools"
sudo yum install wget unzip
# install java
cd /opt/
sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz"
sudo tar xzf jdk-8u60-linux-x64.tar.gz
cd /opt/jdk1.8.0_60/
package org.apache.spark.examples
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.rdd.RDD
import java.util.Random
import scala.collection.mutable
import org.apache.spark.serializer.KryoRegistrator
import com.esotericsoftware.kryo.Kryo
#!/usr/bin/env bash
. ./common.sh
NR_HUGEPAGES=128
NR_CPUS=$(n_cpus)
NIC=${SERVER_NIC:-eth0}
# First IRQ of given NIC
function first_irq() {
#!/usr/bin/env bash
. ./common.sh
NR_HUGEPAGES=128
NR_CPUS=$(n_cpus)
NIC=${SERVER_NIC:-eth0}
# First IRQ of given NIC
function first_irq() {
package com.vcc.bigdata.monitoring.graphite
import java.net.Socket
import java.io.PrintWriter
import java.util.Collection
import scala.collection.JavaConversions._
import java.io.DataOutputStream
import java.io.OutputStreamWriter
import java.io.BufferedWriter
import java.nio.charset.Charset
@tuan3w
tuan3w / ALS2.scala
Last active June 16, 2020 20:23
Implementation of Biased Matrix Factorization on Spark
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@tuan3w
tuan3w / fast_io.py
Created June 21, 2016 15:14
fast way to read big file line by line
from functools import partial
import codecs
def fast_read(name, bytes):
with codecs.open(name, 'r', 'utf-8') as f:
prev = ''
f_read = partial(f.read, bytes)
for text in iter(f_read, ''):
if text == '':
return