Skip to content

Instantly share code, notes, and snippets.

View alapini's full-sized avatar
🎯

Luc Alapini alapini

🎯
View GitHub Profile
@alapini
alapini / mkl.dockerfile
Created February 19, 2020 13:07 — forked from mgoldey/mkl.dockerfile
install basic mkl libraries in debian docker image
# install mkl
RUN apt update && apt install -y --force-yes apt-transport-https && \
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cpio intel-mkl-64bit-2018.3-051 && \
(find /opt/intel -name "ia32*" -exec rm -rf {} \; || echo "removing ia32 binaries") ; \
(find /opt/intel -name "examples" -type d -exec rm -rf {} \; || echo "removing examples") ; \
(find /opt/intel -name "benchmarks" -exec rm -rf {} \; || echo "removing benchmarks") ; \
(find /opt/intel -name "documentation*" -exec rm -rf {} \; || echo "removing documentation") ; \
@alapini
alapini / simple_chat.rs
Created December 12, 2019 17:07 — forked from andelf/simple_chat.rs
Simple Socket Chat Server in Rust. (TcpListener, TcpStream, SharedChan, RWArc)
extern mod sync;
// str op trait
use std::str::StrSlice;
// for tcp listen
use std::io::{TcpListener, TcpStream};
use std::io::net::ip::SocketAddr;
// for trait
use std::io::{Listener, Writer, Acceptor, Buffer};
// for spawn
@alapini
alapini / hclustering.py
Created April 8, 2019 17:17 — forked from codehacken/hclustering.py
Agglomerative clustering using Scikit-Learn (with a custom distance metric)
"""
Hierarchial Clustering.
The goal of gist is to show to use scikit-learn to perform agglomerative clustering when:
1. There is a need for a custom distance metric (like levenshtein distance)
2. Use the distance in sklearn's API.
Adapted from: sklearn's FAQ.
http://scikit-learn.org/stable/faq.html
"""
@alapini
alapini / numbamatmul.py
Created April 5, 2019 16:00 — forked from anilsathyan7/numbamatmul.py
Python numba matrix multiplication
import time
import numba
from numba import jit
import numpy as np
#input matrices
matrix1 = np.random.rand(30,30)
matrix2 = np.random.rand(30,30)
rmatrix = np.zeros(shape=(30,30))
@alapini
alapini / gpumem.py
Created April 1, 2019 15:57 — forked from gmarkall/gpumem.py
Get memory info for all GPUs in Numba
from numba import cuda
gpus = cuda.gpus.lst
for gpu in gpus:
with gpu:
meminfo = cuda.current_context().get_memory_info()
print("%s, free: %s bytes, total, %s bytes" % (gpu, meminfo[0], meminfo[1]))
@alapini
alapini / pycharm_conda.bat
Created March 5, 2019 05:17 — forked from phausamann/pycharm_conda.bat
Launch PyCharm from within conda environment
:: Launch PyCharm from within conda environment
:: This will ensure that all necessary environment variables are set.
:: Modify the paths and environment name for your installation, if necessary.
:: This configuration is for PyCharm x64 installed with JetBrains Toolbox and
:: will launch the latest installed version.
@set condaroot="%userprofile%\Anaconda3"
@set pycharmroot="%localappdata%\JetBrains\Toolbox\apps\PyCharm-P\ch-0"
@set env=base
@alapini
alapini / w2v.ipynb
Created February 25, 2019 10:59 — forked from mbednarski/w2v.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alapini
alapini / js-object-to-graphql.js
Created August 24, 2018 13:41
Javascript Object to Graphql Query
// Source : https://gist.github.com/Azerothian/dc84f009a94579b5bb43#gistcomment-2002977
function isObject(avar) {
// cosntructor.name tested for `function Animal(){}; var a = new Animal(); isObject(a);` will return true otherwise as it is [Object object]
return Object.prototype.toString.call(avar) === '[object Object]' && avar.constructor.name === 'Object';
}
function createGqlQuery(obj) {
let shape = [];
for (let [key, val] of Object.entries(obj))
shape.push(isObject(val) ? `${key} { ${createGqlQuery(val)} }` : key);
https://github.com/Microsoft/vscode/blob/c2d56115afa1647f204ec9afec3a078fc1dac67a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts#L333
@alapini
alapini / simple-server.java
Created May 9, 2018 07:12 — forked from gitawego/simple-server.java
simple HTTP server in Java
package com.stackoverflow.q3732109;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;