Skip to content

Instantly share code, notes, and snippets.

@mookerji
mookerji / loop.py
Created May 6, 2021 03:44
Endless eigenvalues
from numpy import linalg as alg
import numpy as np
arr = np.array([
0.0, 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
@mookerji
mookerji / eni-analysis.py
Last active February 14, 2020 07:28
ECS service discovery hell
import pandas as pd
def read_eni_cap(filename):
return pd.read_csv(filename,header=None, sep='\t', names=['name', 'old', 'new']).set_index('name')
eni_cap = read_eni_cap('instance-types.txt')
def read_enis(filename):
enis = pd.read_json(filename, orient='records')
return enis.join(enis.Attachment.apply(pd.Series), rsuffix='.attach').set_index('NetworkInterfaceId')
@mookerji
mookerji / Script output
Last active May 7, 2018 17:08
Pandas (v0.22) fails to roundtrip category types.
# python3 bug_categories.py
a b c
0 foo foo foo
1 bar bar bar
2 baz baz baz
3 foo foo foo
4 bar bar bar
5 baz baz baz
6 foo foo foo
@mookerji
mookerji / build.sh
Created July 11, 2017 23:01
SBP-JSON timing tests, to test on an assumed hardware test log (in JSON).
# Assumes you have in third_party libsbp, rapidjson, and b64.c (built)
g++ -O3 -g -v -stdlib=libstdc++\
-Wall -Werror -Wno-c++11-extensions \
-Ithird_party/rapidjson/include \
-Ithird_party/libsbp/c/include \
-Ithird_party/b64.c/ \
third_party/b64.c/b64 $1;
time ./a.out
GST - GNSS Pseudorange Error Statistics
1 2 3 4 5 6 7 8
| | | | | | | |
$--GST,hhmmss.ss,x.x,x.x,x.x,x.x,x.x,x.x,x.x*hh<CR><LF>
1. UTC time of the GGA or GNS fix associated with this sentence.
2. RMS value of the standard deviation of the range inputs to
the navigation process. Range inputs include pseudoranges &
DGNSS corrections.
3. Standard deviation of semi-major axis of error ellipse (meters)
4. Standard deviation of semi-minor axis of error ellipse (meters)
@mookerji
mookerji / async.py
Created February 25, 2017 01:09
ZMQ piksi client
# Copyright (C) 2015 Swift Navigation Inc.
# Contact: Engineering <engineering@swiftnav.com>
#
# This source is subject to the license found in the file 'LICENSE' which must
# be be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
@mookerji
mookerji / quickcheck-file.hs
Last active December 17, 2015 05:04
Environmental fails
import Test.QuickCheck
import Test.QuickCheck.Instances.Maybe
import Test.QuickCheck.Monadic
instance Arbitrary LogLevel where
arbitrary = do
n <- choose (0, 4) :: Gen Int
return $ case n of
0 -> LevelDebug
1 -> LevelInfo
function generateDish() {
var ADJ_PROB = 0.5;
var STRUCTURE_PROB = 0.5;
var adjs = ["chilled", "fried", "smoked", "brined", "cultured", "farmer's", "pressed", "cured", "charred", "dill", "sweet", "corned", "kefir", "paprika", "pickled", "truffled", "black", "rye", "sour cream", "preserved", "burnt", "seeded", "dried"];
var ingredients = ["cabbage", "chicken", "tongue", "cheese", "liver", "sturgeon", "chard", "tuna", "beef", "radish", "mushroom", "trout", "carrot", "yoghurt", "lard", "bone marrow", "tripe", "bottarga", "egg", "catfish", "ramp", "tendon", "greens", "fennel", "chicories", "bonito", "potato", "garlic", "mussel", "nettle", "herring", "sardine", "walnut", "plum"];
var structures = ["croquettes", "melt", "stew", "soup", "slab", "bread", "butter", "pickles", "dip", "dumplings", "broth", "tartare", "loin", "crackers", "cake", "steak", "flatbread", "toast"];
var dish = "";
if (_.random(0, 100) < ADJ_PROB * 100) {
dish += _.sample(adjs) + " ";
}
@mookerji
mookerji / extras_swift.i
Created May 4, 2015 17:22
Python C extensions
%typemap(in) float value[ANY] (float temp[$1_dim0]) {
int i;
if (!PySequence_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
return NULL;
}
if (PySequence_Length($input) != $1_dim0) {
PyErr_SetString(PyExc_ValueError,"Size mismatch. Expected $1_dim0 elements");
return NULL;
}
### Keybase proof
I hereby claim:
* I am mookerji on github.
* I am mookerji (https://keybase.io/mookerji) on keybase.
* I have a public key whose fingerprint is E277 702B 9088 47A1 2228 5D2B A056 FAB1 7C28 EE91
To claim this, I am signing this object: