Skip to content

Instantly share code, notes, and snippets.

View jgoizueta's full-sized avatar

Javier Goizueta jgoizueta

  • CARTO
  • Pamplona - SPAIN
View GitHub Profile
@jgoizueta
jgoizueta / cmp.py
Last active July 15, 2022 06:32
Python approximate dict comparison
import re
def floats_approx_equal(a, b, rel_tol=1e-5, abs_tol=0.0):
# for Python >= 3.5: math.isclose(a, b, rel_tol, abs_tol):
return abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)
floats_list = re.compile(r"""
^
(?:[-+]?\d*\.?\d+)(?:E([-+]?\d+))? # first float
@jgoizueta
jgoizueta / convert.rb
Created October 13, 2020 16:40
Zoom MRS-1266 File conversion
# Convert Zoom MRS-1266 .DAT files to .WAV
FIXED_HEADER = "52 49 46 46 24 00 5E 00 57 41 56 45 66 6D 74 20 10 00 00 00 01 00 01 00 44 AC 00 00 88 58 01 00 02 00 10 00 64 61 74 61"
input_file = ARGV[0]
data = File.open(input_file, 'rb') { |file| file.read }
data = data[65536..-1]
size = data.size
header = FIXED_HEADER.split.map{ |v| v.to_i(16) }.pack("C*")
output = header + [size].pack("V") + data
@jgoizueta
jgoizueta / notes.md
Created August 12, 2019 20:48
Numworks symbolic computation
@jgoizueta
jgoizueta / index.html
Last active June 7, 2017 15:41 — forked from ramiroaznar/index.html
How to display a Raster layer in CARTO
<!DOCTYPE html>
<html>
<head>
<title>How to load a Raster layer in CARTO</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@jgoizueta
jgoizueta / surprise.md
Created March 28, 2017 13:15
Floating Point Fun

Floating point unexpected results demo

Save for the last case (a poor try at showing floating point equality isn't reflexive), these examples seem specially surprising due to the base-conversion involved (since input is decimal and the floating point numbers used are binary), which hides the actual number of significant digits involved in each case.

Python

@jgoizueta
jgoizueta / application_helper.rb
Created February 24, 2017 19:42
Rails helpers to define tables column-wise
# encoding: UTF-8
module ApplicationHelper
# ...
def concat_content_tag(*args, &blk)
concat content_tag(*args, &blk)
end
end