Skip to content

Instantly share code, notes, and snippets.

View omegahm's full-sized avatar

Mads Ohm Larsen omegahm

View GitHub Profile

Keybase proof

I hereby claim:

  • I am omegahm on github.
  • I am omegahm (https://keybase.io/omegahm) on keybase.
  • I have a public key ASD9OfpkAraJRrz0ig65pntS5pvnGM6miJ3Ievw6IAZuUQo

To claim this, I am signing this object:

require 'rspec'
RSpec.describe do
%w(spongebobify minisponge).each do |method|
context "##{method}" do
it 'fox' do
expect(send(method, 'fox')).to eq('fOx')
expect(send(method, 'FOX')).to eq('fOx')
end
@omegahm
omegahm / def.rb
Last active May 22, 2019 09:20
Time differences?
def run
t = 12.hours.from_now
n = Time.zone.now
puts t
puts n
puts (t.to_datetime - n.to_datetime)
puts (t.to_datetime - n.to_datetime).to_f
(t.to_datetime - n.to_datetime).ceil
end
@omegahm
omegahm / add_benchmark.rb
Created December 15, 2017 18:56
Benchmarking various array addition techniques with Ruby
require "benchmark"
n = 100_000_000
puts "ADD"
puts "n = #{n}"
Benchmark.bm(20) do |measure|
measure.report("zip") do
output = ""
@omegahm
omegahm / ext-blas.py
Created February 21, 2017 10:06
Testing BLAS extension for Bohrium
a = np.random.rand(2000, 3000).astype(np.float32)
b = np.random.rand(3000, 4000).astype(np.float32)
t0 = time()
c = np.dot(a, b)
t1 = time()
print "[Numpy] It took {}s".format(t1-t0)
print c
#print
@omegahm
omegahm / quasicrystal.py
Last active April 28, 2021 01:44
Quasicrystals in Python
# -*- coding: utf-8 -*-
import bohrium as np
from math import pi
import matplotlib.pyplot as plt
import matplotlib.colors as colors
fig = plt.figure()
plt.xticks([])
plt.yticks([])
# -*- coding: utf-8 -*-
import numpy as np
from sys import argv
from matplotlib import pyplot as plt
from matplotlib import colors
def mandelbrot(c, maxiter, h, log_log_h):
output = np.empty(c.shape, np.float64)
z = np.empty(c.shape, np.complex64)
az = np.zeros(c.shape, np.complex64)
{
credits: {
enabled: false
},
chart: {
type: 'column',
backgroundColor: 'transparent'
},
title: {
var snd = new Audio("data:audio/wav;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAAKAAASdAAZGRkZGRkZGRkZMzMzMzMzMzMzM0xMTExMTExMTExmZmZmZmZmZmZmgICAgICAgICAgJmZmZmZmZmZmZmzs7Ozs7Ozs7OzzMzMzMzMzMzMzObm5ubm5ubm5ub///////////8AAAA6TEFNRTMuOTIgAckAAAAAAAAAAAKAJAbAQQAAAAAAEfTbBHdkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQxAAAFd4u3zipgALHwaCrgpAAAAAAADCCAAAA8TgbPLEXgKAWefIB+VCKEA/w6QAIYAIQwX/4sYswdhEw6D/8MYCkAywMgBtiBzf//iNwBjijk4AoQXIKU///FKg2HD3wAjiZCdAbFjqGQ///8AZYpIOUBtuGJxkxcBibh8YN//////DBZPjljvDLYoMcYHJwAUBgCGESE6E0Oz/////////IuT4cQFpgFhkIJ3AOYVYxQEACxQRYAU4DCxHAACAFIAABEXIiABJ47Hosx/BuX3PcM2thv2SVkqKcznJGGsKto0hmydoUFkgXbco0gJ1dKHWrIMQIEUDS1LzhuwnF6ZiEm3F4JxZ16nhLwQZJ9ym1aUquUZSgko1K0lUNZHUeqoqI4G4323k7tV1fabnS9k91sGIXFbTrkrxpW
function(doc) {
doc.postal_districts.forEach(function(pd) {
pd.postal_codes.forEach(function(pc) {
emit(pc.postal_code, {
postal_name: pc.name,
postal_code: pc.postal_code,
type: pc.type,
postal_district_id: pd.id,
slug: pd.slug
})