Skip to content

Instantly share code, notes, and snippets.

@leolord
leolord / vim.sh
Last active August 4, 2021 19:45
Compiling vim on Ubuntu 18 with LUA-support
# Remove previous installations
sudo apt-get remove vim vim-runtime vim-tiny vim-common
# Install dependencies
sudo apt-get install libncurses5-dev python-dev liblua5.3-dev lua5.3 python3-dev
# Fix liblua paths
# You have to compile luajit for yourself.
sudo ln -s /usr/include/lua5.3 /usr/include/lua
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/local/lib/liblua.so
@kastnerkyle
kastnerkyle / audio_tools.py
Last active April 26, 2024 07:11
Audio tools for numpy/python. Constant work in progress.
raise ValueError("DEPRECATED/FROZEN - see https://github.com/kastnerkyle/tools for the latest")
# License: BSD 3-clause
# Authors: Kyle Kastner
# Harvest, Cheaptrick, D4C, WORLD routines based on MATLAB code from M. Morise
# http://ml.cs.yamanashi.ac.jp/world/english/
# MGC code based on r9y9 (Ryuichi Yamamoto) MelGeneralizedCepstrums.jl
# Pieces also adapted from SPTK
from __future__ import division
import numpy as np
@tdoris
tdoris / Promises.md
Last active November 10, 2023 01:15

Does Haskell make promises it can't keep?

or The big problem with wrapping numeric types

When coding financial calculations, it's common to have a variety of numeric values such as Quantity, Price, Amount and so on. In quant finance, these usually refer to the Price observed in the market, a Quantity of shares. A Quantity of shares all traded at a given Price in a given currency will give you an Amount of that currency (the total value of the trade).

It's simple and fun exercise to write the functions you'd need to perform all the correct ways of combining Price, Quantity and Amount. There are a couple of things that don't work as you might expect (e.g., multiplication is ok but you need to think about division semantics.).

Many Haskell tutorials encourage the coder to wrap Double and Int in newtypes like this, so the compiler can help by detecting incorrect combinations of the different types, and so the code documents itself better. e.g.

@elad
elad / neural-style-ec2.txt
Created September 7, 2015 08:09
Running neural-style in EC2
Start a g2.2xlarge or better (GPU instance) with https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-ffba7b94
Login, username is ubuntu
Update a bunch of stuff and make sure cudnn R2 is used:
luarocks install image
luarocks install loadcaffe
luarocks install torch
export LD_LIBRARY_PATH=/home/ubuntu/torch-distro/install/lib:/home/ubuntu/torch-distro/install/lib:/home/ubuntu/cudnn-6.5-linux-x64-v2-rc2
@webcss
webcss / eventsmixin.js
Last active August 9, 2016 12:44
PubSub mixin using CustomEvents
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
@AGoblinKing
AGoblinKing / component.js
Last active August 29, 2015 14:14
Mithril Components using a Module Loader
var m = require("mithril");
module.exports = function Component(ctrl) {
var foo = ctrl.Component.foo = m.prop(5);
ctrl.Component.clicked = function() {
ctrl.Component.foo(++foo);
};
return function ComponentView() {
@StephanHoyer
StephanHoyer / gist:bddccd9e159828867d2a
Last active March 29, 2022 11:46
Isomorphic applications with mithril

Attention

This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.

The example is updated with the current version of mithril, though.

Isomorphic applications with mithril

@demisx
demisx / gulpfile.js
Last active July 14, 2022 16:06
Gulp 4 gulpfile.js
// Gulp 4
var gulp = require('gulp');
var using = require('gulp-using');
var grep = require('gulp-grep');
var changed = require('gulp-changed');
var del = require('del');
var coffee = require('gulp-coffee');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var sourcemaps = require('gulp-sourcemaps');
@StephanHoyer
StephanHoyer / gist:de107b794c43f28ffd75
Last active August 10, 2023 17:16
SVG Icons with mithril.js

Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.

They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.

A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  
  <symbol id="beaker" viewBox="214.7 0 182.6 792">
@kachayev
kachayev / concurrency-in-go.md
Last active March 11, 2024 11:27
Channels Are Not Enough or Why Pipelining Is Not That Easy