Skip to content

Instantly share code, notes, and snippets.


Camilo clsource

View GitHub Profile

Creating a .so dynamic library of a haskell program and calling it from C


  • Export a haskell function with foreign export.
  • Create a C wrapper that calls hs_init when the library is loaded.
  • Compile the .hs and .c wrapper with ghc, linking with lHSrts-ghc8.6.5
  • Use it from C by linking as usual.

(For more details, see here.)

Pigu-A /
Last active Nov 18, 2020
Deflemask module (.dmf) to DevSound 2.4 converter. Not all features are converted correctly.
import io, string, sys, zlib
def sane(a):
cap = True
t = ""
for i in a.decode():
if i in string.ascii_letters + string.digits + "_":
t += i.upper() if cap else i
cap = False
jsomers /
Created Sep 27, 2018
Using websockets to easily build GUIs for Python programs

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:


(Each row represents a "worker" in my model, and each rectangle represents a "task.")

markblundeberg /
Created Aug 31, 2018
Using PGP signatures with bitcoin script OP_CHECKDATASIG

Using PGP signatures with bitcoin script OP_CHECKDATASIG

Dr. Mark B. Lundeberg, 2018 August 30 bitcoincash:qqy9myvyt7qffgye5a2mn2vn8ry95qm6asy40ptgx2

Since version 2.1, GnuPG is able to use the very same secp256k1 elliptic curve signature algorithm (ECDSA) as used in bitcoin. Quite soon Bitcoin Cash will add a new script opcode OP_CHECKDATASIG that is able to check signatures not just on the containing transaction, but also on arbitrary data. For fun, let's try to intersect the two signature systems and see what can be done!



ibrunotome /
Last active Sep 1, 2021
A Domain Driven Design (DDD) approach to the Laravel Framework
├── /Application
|  ├── /Exceptions
|  ├── /Middlewares
|  ├── /Providers
|  ├── /Requests
├── /Domain
|  ├── /MyDomainA
|  |   ├── /Contracts
demidovakatya /
Last active Oct 31, 2021
telegram stickers // anime
james2doyle /
Last active Sep 25, 2021
Enable remote debugging on the iOS simulator using Chrome Dev Tools

Install the tools:

brew install ios-webkit-debug-proxy

Run the simulator. And choose an iOS 10 device. The chrome remote debugging doesn't work with iOS 11 yet.

Enable the inspector

Daniel-Hug / probabilities.js
Last active Oct 5, 2020
JS probability functions
View probabilities.js
// probability that the event with the passed probability will NOT occur
function complement(p) {
return 1 - p;
// probability that a and b will happen when neither outcome
// is affected by the other (accepts 1 or more arguments)
function intersectionOfIndependentEvents(a, b) {
var ret = a;
for (var i = 1; i < arguments.length; i++) {
rhernandog / regiones-provincias-comunas.json
Last active Oct 14, 2021
Archivo en formato JSON con las regiones de Chile, sus provincias y las respectivas comunas de cada provincia.
View regiones-provincias-comunas.json
"region": "Arica y Parinacota",
"region_number": "XV",
"region_iso_3166_2": "CL-AP",
"provincias": [
"name": "Arica",
"comunas": [
unbug / Middleware.js
Last active Jul 20, 2021
Powerful Javascript Middleware Pattern Implementation, apply middleweares to any object.
View Middleware.js
'use strict';
/* eslint-disable consistent-this */
let middlewareManagerHash = [];
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.