Skip to content

Instantly share code, notes, and snippets.

View cobalamin's full-sized avatar
👾

Simon Welker cobalamin

👾
View GitHub Profile
@ChrisRackauckas
ChrisRackauckas / diffeq_vs_torchsde.md
Last active September 28, 2022 20:49
torchsde vs DifferentialEquations.jl / DiffEqFlux.jl (Julia) benchmarks

torchsde vs DifferentialEquations.jl / DiffEqFlux.jl (Julia)

This example is a 4-dimensional geometric brownian motion. The code for the torchsde version is pulled directly from the torchsde README so that it would be a fair comparison against the author's own code. The only change to that example is the addition of a dt choice so that the simulation method and time step matches between the two different programs.

The SDE is solved 100 times. The summary of the results is as follows:

@IvanYashchuk
IvanYashchuk / poisson.jl
Last active April 29, 2021 21:29
FEniCS solver + Zygote.jl + Turing.jl
using PyFenicsAD
using Zygote
using PyCall
using Turing
import LinearAlgebra: norm
using Random, Distributions
fenics = pyimport("fenics")
fenics.set_log_level(fenics.LogLevel.ERROR)
fa = pyimport("fenics_adjoint")
@cobalamin
cobalamin / audiomgmt.sh
Created June 16, 2019 20:29
Audio management (prev/play+pause/next, volume up/down, speaker/headphone switching) via the command line
# I used the commands below not only on the command line, but also set up the aliased commands as global keyboard shortcuts.
# This can be useful if you have a keyboard that lacks media keys, or if the media keys don't behave exactly as you want them to.
# Everything below assumes PulseAudio on top of ALSA.
alias volup="amixer set 'Master' 10%+" # Using amixer because pacmd/pactl can increase beyond 100% volume, which I don't want.
alias voldn="amixer set 'Master' 10%-"
# This assumes sink port #1 and the naming of these ports. Check `pacmd list-sinks` and make adjustments if necessary.
alias outsp='pacmd "set-sink-port 1 analog-output;output-speaker' # output to speakers
alias outhp='pacmd "set-sink-port 1 analog-output;output-headphones-1' # output to headphones
@Francesco149
Francesco149 / docker-cross-device-link.md
Last active October 27, 2023 08:51
docker error creating new backup file '/var/lib/dpkg/status-old': Invalid cross-device link
@ardok
ardok / jest-config.browser.js
Created March 15, 2018 23:46
Running jest in node and browser env, then combine the coverage with istanbul
/* eslint-disable */
const common = require('../jest-config.common');
module.exports = Object.assign({}, common, {
"coverageDirectory": "<rootDir>/coverage/browser",
"testMatch": [
"**/test/browser/**/*.test.js"
],
"setupFiles": [
"<rootDir>/src/test/browser/setup.js"
]
@peteflorence
peteflorence / pytorch_bilinear_interpolation.md
Last active June 30, 2024 01:26
Bilinear interpolation in PyTorch, and benchmarking vs. numpy

Here's a simple implementation of bilinear interpolation on tensors using PyTorch.

I wrote this up since I ended up learning a lot about options for interpolation in both the numpy and PyTorch ecosystems. More generally than just interpolation, too, it's also a nice case study in how PyTorch magically can put very numpy-like code on the GPU (and by the way, do autodiff for you too).

For interpolation in PyTorch, this open issue calls for more interpolation features. There is now a nn.functional.grid_sample() feature but at least at first this didn't look like what I needed (but we'll come back to this later).

In particular I wanted to take an image, W x H x C, and sample it many times at different random locations. Note also that this is different than upsampling which exhaustively samples and also doesn't give us fle

@klaftertief
klaftertief / reactiveconf-2016-lightning-talk.md
Last active April 2, 2024 20:17
An API search engine in Elm for Elm, proposal for a Lightning Talk at ReactiveConf 2016

An API search engine in Elm for Elm

Elm is a statically typed functional language that compiles to JavaScript. It's well-known for its developer experience: the compiler provides nice error messages, the package system enforces semantic versioning for all published packages and makes sure every exposed value or type has some documentation and type annotations.

@thomastweets
thomastweets / PNGWhiteTrim.py
Last active February 8, 2024 18:53
Python script to trim all png images with white background in a folder
import Image
import sys
import glob
import ImageOps
# Trim all png images with white background in a folder
# Usage "python PNGWhiteTrim.py ../someFolder"
try:
folderName = sys.argv[1]
@d-akara
d-akara / JavaScriptSafeNavigation.md
Last active April 11, 2024 16:18
JavaScript Safe Navigation

Experimental Safe JavaScript Navigation

Implemented using ES6 Proxies and Symbols

The purpose of this function is to provide a way to avoid deep nested conditionals when traversing a hierarchy of objects. Some languages use an operator such as '?.' to perform this capability. This is sometimes called safe navigation or null conditional operators.

You can somewhat think of this as how a xpath select works. If any nodes along the path are not found, your result is simply not found without throwing an exception and without needing to check each individual node to see if it exists.

Suggestions for improvements welcome!

@eyecatchup
eyecatchup / git-commit-log-stats.md
Last active June 18, 2024 08:05
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.