Skip to content

Instantly share code, notes, and snippets.

View bicycle1885's full-sized avatar

Kenta Sato bicycle1885

  • Karolinska Institute
  • Stockholm, Sweden
View GitHub Profile
@bicycle1885
bicycle1885 / vimrc
Last active July 22, 2020 02:37
My vimrc
" General
syntax enable
set nocompatible
set noswapfile
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
autocmd QuickFixCmdPost * copen
nnoremap <silent> <C-n> :cn<CR>
@bicycle1885
bicycle1885 / fusion.hs
Created June 10, 2014 14:16
minimal stream fusion
{-# LANGUAGE ExistentialQuantification #-}
module Main (main) where
import Prelude hiding (map, filter, foldl, sum)
import System.Environment (getArgs)
data Stream a = forall s. Stream (s -> Step a s) s
data Step a s = Done
| Yield a s
| Skip s
using LinearAlgebra
function main()
# input data
train_data = read_data("./ml-100k/u.data")
n_user = length(unique([t[1] for t in train_data]))
n_item = length(unique([t[2] for t in train_data]))
# parameters
P, Q = fit(n_user, n_item, train_data)
# LICENSE: Public Domain
import requests
def panther(species, genelist, ontology='biological_process',
correction='fdr', format='html', resource='PANTHER', timeout=15):
"""Post a over/under-representation test request to PANTHER."""
# NOTE: The species parameter seems to be different from conventional
@bicycle1885
bicycle1885 / setup-system.jl
Last active January 30, 2020 04:29
Set up Julia packages for system
# Install packages in system
# ==========================
# License: Public Domain
# Usage: julia setup-system.jl package1 package2 ...
# Also, don't forget to add '@system' to your LOAD_PATH like this way:
# $ env JULIA_LOAD_PATH='@:@v#.#:@system:@stdlib' julia
using Pkg
@bicycle1885
bicycle1885 / load_alevin.jl
Created January 14, 2020 08:53
Utilities to read output files of Alevin.
# Utilities to read output files of Alevin.
# -----------------------------------------
#
# Copyright 2020 Kenta Sato
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@bicycle1885
bicycle1885 / noptime.cpp
Last active December 16, 2019 02:41
Measure throughput of nops' sequence using Xbyak
#include <iostream>
#include <chrono>
#include <cmath>
#include <xbyak/xbyak.h>
const size_t INIT_CODE_BUF_SIZE = 1 >> 10;
struct Code : Xbyak::CodeGenerator
{
Code(size_t n) : CodeGenerator(INIT_CODE_BUF_SIZE, Xbyak::AutoGrow)
using LinearAlgebra: qr
function equilibrium(Q::AbstractMatrix)
@assert size(Q, 1) == size(Q, 2)
R = qr(Q').R
n = size(Q, 1)
v = zeros(eltype(Q), n)
v[end] = 1
for i in n-1:-1:1
s = zero(eltype(Q))
@bicycle1885
bicycle1885 / par.jl
Created June 5, 2019 00:31
Parallel execution
macro par(expr)
thunk = esc(:(()->($expr)))
quote
local task = Task($thunk)
task.sticky = false
schedule(task)
task
end
end
@bicycle1885
bicycle1885 / array1.jl
Created June 4, 2019 03:30
Constant folding
const a = (1, 2, 3, 4)
function func(b)
sum = 0
for i in 1:4
sum += a[i] * b[i]
end
return sum
end