Skip to content

Instantly share code, notes, and snippets.

View mratsim's full-sized avatar
:shipit:

Mamy Ratsimbazafy mratsim

:shipit:
  • Paris
View GitHub Profile
@mratsim
mratsim / .theanorc
Created January 29, 2017 12:04
Theano config with the fast Winograd kernel
[global]
floatX = float32
device = gpu
config.openmp = True
OMP_NUM_THREADS=8
config.dnn.conv.algo_fwd='winograd'
config.dnn.conv.algo_bwd_data='winograd'
config.gcc.cxxflags="-march=native"
[lib]
@mratsim
mratsim / makepkg.conf
Created January 29, 2017 12:08
Makepkg config for Archlinux
#
# /etc/makepkg.conf
#
#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent'
@mratsim
mratsim / yaourtrc
Created January 29, 2017 12:08
Yaourt config for Archlinux
# yaourtrc - Configuration for yaourt
#
# See yaourtrc(5) for more information
#
#
# General
#AUTOSAVEBACKUPFILE=0
DEVEL=1
DEVELSRCDIR="/pkg/devel"
@mratsim
mratsim / R Makevars
Created March 20, 2017 17:37
~/.R/Makevars to compile R package with OpenMP and all compiler optimizations
# ~/.R/Makevars
PKG_LIBS = -fopenmp -lgomp
PKG_CFLAGS=-O3 -pipe -fstack-protector-strong -fopenmp -march=native
#-- Compiler and Linker Flags
# -march (or -mcpu) builds exclusively for an architecture
# -mtune optimizes for an architecture, but builds for whole processor family
CPPFLAGS=-D_FORTIFY_SOURCE=2
CFLAGS=-O3 -pipe -fstack-protector-strong -fopenmp -march=native
CXXFLAGS=-O3 -pipe -fstack-protector-strong -fopenmp -march=native
@mratsim
mratsim / unfold.nim
Last active April 1, 2017 22:13
Unfolding Nim magic
import options
import future
import sequtils
# Unfolding the Nim Magic
## Bug https://github.com/nim-lang/Nim/issues/5647 open.
## unfold proper type signature should have Option[(T, U)] instead of Option[(T, T)]
# proc unfoldr*[T, U](f: U -> Option[(T, U)], x:U): seq[T] {. inline .}=
@mratsim
mratsim / fptoolbox.nim
Created April 13, 2017 07:29
Nim functional programming
template scanr[T](s: seq[T], operation: untyped): untyped =
## Template to scan a sequence from right to left, returning the accumulation and intermediate values.
## This is a foldr with intermediate steps returned
## @[2, 2, 3, 5].scanr(a + b) = @[48, 24, 12, 4]
let len = s.len
assert len > 0, "Can't scan empty sequences"
var result = newSeq[T](len)
@mratsim
mratsim / pointer_arithmetic_arraymancer.nim
Created April 17, 2017 21:14
Nim pointer arithmetic examples
# Deleted pointer arithmetic routines
# Original data structure with pointer:
type Tensor*[B: static[Backend]; T] = object
# Size of the datastructure is 32 bytes - perfect !
dimensions: seq[int]
strides: seq[int]
offset: ptr T
data: seq[T] # Perf note: seq are always deep copied on assignement.
@mratsim
mratsim / fetch_page.py
Created April 20, 2017 10:59 — forked from Smerity/fetch_page.py
An example of fetching a page from Common Crawl using the Common Crawl Index
import gzip
import json
import requests
try:
from cStringIO import StringIO
except:
from StringIO import StringIO
# Let's fetch the Common Crawl FAQ using the CC index
resp = requests.get('http://index.commoncrawl.org/CC-MAIN-2015-27-index?url=http%3A%2F%2Fcommoncrawl.org%2Ffaqs%2F&output=json')
@mratsim
mratsim / compiler_context_typechecking.nim
Created April 20, 2017 11:23
Type checking a "Context" with Nim compiler
type
Context*[T] = ref object
nodes: seq[T]
Variable*[T; C: static[Context[T]]] = object
tape: Context[T]
index: int
value: T
proc newContext*[T]: Context[T] {.noSideEffect.} =