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 / UsageTrackingBlock.cs
Created January 2, 2020 23:45 — forked from anonymous/UsageTrackingBlock.cs
A tracker of slot usage for a region spanning a total of 2^14 (16384) slots, in a total of 3072 bytes using a combination of a Fenwick tree and a bitmap vector.
namespace TryOuts
{
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
/// <summary>
/// Tracks usage of a block of 2^14 (16384) slots using a bitmap that
/// contains the 16384 used/free bit flags for each slot (taking up a
/// total space of 2048 bytes, accessed as an array of 512 ints), in
@mratsim
mratsim / experimental.go
Created November 7, 2019 17:38 — forked from protolambda/experimental.go
Binary Tree as immutable state backing, with rebinding pattern for minimal copy-on-write modifications. Every merkle cached *by default*.
package experimental
import "encoding/binary"
// Experimental code! Everything a tree and cached by default.
type HashFn func(a Root, b Root) Root
// A link is called to rebind a value
@mratsim
mratsim / myproj.nim
Last active October 23, 2019 19:40 — forked from xmonader/myproj.nim
myproj.nim
# This is just an example to get you started. A typical binary package
# uses this file as the main entry point of the application.
import strformat, tables, json, strutils, asyncdispatch, asyncnet, strutils, parseutils, options, net
from cgi import decodeUrl
import terminaltables
import mimetypes
type
@mratsim
mratsim / nim_magic.py
Created September 26, 2019 11:40 — forked from apahl/nim_magic.py
Nim cell magic for Jupyter and JLab Notebooks
"""
nim_magic.py
Jupyter cell magic for your favorite programming language.
This is now also available as a proper repo:
https://github.com/apahl/nim_magic
All further changes will be tracked there.
Requirements: Nim (https://nim-lang.org), nimpy (`nimble install nimpy`, thanks to @yglukhov for this great library!)
@mratsim
mratsim / libdispatch-efficiency-tips.md
Created July 15, 2019 10:14 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

I suspect most developers are using the libdispatch inefficiently due to the way it was presented to us at the time it was introduced and for many years after that, and due to the confusing documentation and API. I realized this after reading the 'concurrency' discussion on the swift-evolution mailing-list, in particular the messages from Pierre Habouzit (who is the libdispatch maintainer at Apple) are quite enlightening (and you can also find many tweets from him on the subject).

My take-aways are:

  • You should have very few queues that target the global pool. If all these queues are active at once, you will get as many threads running. These queues should be seen as execution contexts in the program (gui, storage, background work, ...) that benefit from executing in parallel.
@mratsim
mratsim / keyservers.md
Created June 30, 2019 09:51 — forked from rjhansen/keyservers.md
SKS Keyserver Network Under Attack

SKS Keyserver Network Under Attack

This work is released under a Creative Commons Attribution-NoDerivatives 4.0 International License.

Terminological Note

"OpenPGP" refers to the OpenPGP protocol, in much the same way that HTML refers to the protocol that specifies how to write a web page. "GnuPG", "SequoiaPGP", "OpenPGP.js", and others are implementations of the OpenPGP protocol in the same way that Mozilla Firefox, Google Chromium, and Microsoft Edge refer to software packages that process HTML data.

Who am I?

@mratsim
mratsim / 0README.md
Created January 9, 2019 15:50 — forked from juancarlospaco/0README.md
Python Versus Nim: Async

Python Versus Nim: Async

  • No performance benchmark.
  • Python ⟿ PEP-8
  • Nim ⟿ NEP1
  • Python ⟿ 3.7
  • Nim ⟿ 0.19
  • No Ofuscation, no Code-Golf.

This is to compare elegant, simple, expressive code.

@mratsim
mratsim / min-char-rnn.py
Created December 9, 2018 20:10 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@mratsim
mratsim / lagrangeprop.py
Created October 1, 2018 12:41 — forked from timvieira/lagrangeprop.py
Automatic differentiation as the method of Lagrange multipliers. Code accompanies this blog post: http://timvieira.github.io/blog/post/2017/08/18/backprop-is-not-just-the-chain-rule/
# -*- coding: utf-8 -*-
"""
Backprop as the method of Lagrange multiplers (and even the implicit function
theorem).
"""
from __future__ import division
import numpy as np
from arsenal.alphabet import Alphabet
from arsenal.math.checkgrad import finite_difference
@mratsim
mratsim / dl-frameworks.rst
Created May 11, 2018 12:14 — forked from bartvm/dl-frameworks.rst
A comparison of deep learning frameworks

A comparison of Theano with other deep learning frameworks, highlighting a series of low-level design choices in no particular order.

Overview

Symbolic: Theano, CGT; Automatic: Torch, MXNet

Symbolic and automatic differentiation are often confused or used interchangeably, although their implementations are significantly different.