Skip to content

Instantly share code, notes, and snippets.

@inproceedings{Lin:2013:ACA:2484028.2484035,
author = {Lin, Jovian and Sugiyama, Kazunari and Kan, Min-Yen and Chua, Tat-Seng},
title = {Addressing cold-start in app recommendation: latent user models constructed from twitter followers},
booktitle = {Proceedings of the 36th international ACM SIGIR conference on Research and development in information retrieval},
series = {SIGIR '13},
year = {2013},
isbn = {978-1-4503-2034-4},
location = {Dublin, Ireland},
pages = {283--292},
numpages = {10},
@jovianlin
jovianlin / matrix.cpp
Created May 26, 2014 12:02
1) make matrix; 2) ./matrix
#include <iostream>
#include <string>
#include <chrono>
#include <thread>
#include <cstdlib>
const int width = 158; // Width of terminal window
const int flipsPerLine = 5; // No. of columns changed per line
const int millisecondsOfSleep = 50; // Delay between lines in millisecond
int main() {
srand(time_t(NULL));
@inproceedings{Lin:2014:NIM:2600428.2609560,
author = {Lin, Jovian and Sugiyama, Kazunari and Kan, Min-Yen and Chua, Tat-Seng},
title = {New and Improved: Modeling Versions to Improve App Recommendation},
booktitle = {Proceedings of the 37th International ACM SIGIR Conference on Research \&\#38; Development in Information Retrieval},
series = {SIGIR '14},
year = {2014},
isbn = {978-1-4503-2257-7},
location = {Gold Coast, Queensland, Australia},
pages = {647--656},
numpages = {10},
@jovianlin
jovianlin / gist:60d38b72ec380127ccb3
Created August 8, 2014 07:10
random python code
while True:
user_input = raw_input("Type something: ")
print ' '.join(["#" + w.lower().capitalize() for w in user_input.split()]) + '\n'
@jovianlin
jovianlin / pip_upgrade_all_packages
Created April 10, 2015 15:01
Upgrading all packages with pip
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("sudo -H pip install --upgrade " + dist.project_name, shell=True)
@jovianlin
jovianlin / stop_pyc_files_from_being_produced
Created February 10, 2016 02:47
Stop .pyc files from being produced
# Include `sys.dont_write_bytecode = True` after `import sys`,
# if you don't want .pyc files to be produced
import sys
sys.dont_write_bytecode = True
@jovianlin
jovianlin / 00.howto_install_phantomjs.md
Last active March 7, 2016 15:52 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 2.1.1

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@jovianlin
jovianlin / get_available_gpus.py
Created October 3, 2016 09:58
Get List of Devices in TensorFlow
from tensorflow.python.client import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
get_available_gpus()
@jovianlin
jovianlin / run_cmd.py
Created November 5, 2016 11:03
Execute Linux Commands in Python
from subprocess import Popen, PIPE, STDOUT
def run(cmd):
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
return p.stdout.read()
@jovianlin
jovianlin / best_classifier_selector.py
Created November 9, 2016 07:27
Best Classifier Selector
# Snippet for identifying the best classifier from svm, per, KNN based on their respective (accuracy) scores.
idx = np.argmax([svm_accuracy, per_accuracy, knn_accuracy])
classifiers = {0: 'SVM', 1: 'Perceptron', 2: 'KNN'}
print('Best classifier is {}'.format(classifiers[idx]))