Skip to content

Instantly share code, notes, and snippets.

View fnoble's full-sized avatar

Fergus Noble fnoble

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fnoble
fnoble / ADT.hs
Last active March 24, 2016 02:18
Intro to Haskell ADTs
module ADT where
import Prelude hiding (Bool, True, False,
negate, and, or,
List, Cons, Nil,
Maybe, Just, Nothing,
Either, Left, Right,
Tree, Node, Leaf)
-- Simplest ADT
@fnoble
fnoble / Main.hs
Last active March 22, 2016 01:13
Euler 5 Haskell Golf
-- Much better
foo :: Int -> Int -> Int
foo x acc = if acc `mod` x == 0 then acc else lcm acc x
mult20 = foldr foo 1 [1..20]
-- 1st try
primes = [2 :: Integer, 3, 5, 7, 11, 13, 17, 19]
isInt x = (x :: Double) == fromInteger (round x)
power p x = length $ takeWhile id $ drop 1 $ map isInt $ iterate (/ fromInteger p) $ fromInteger x
mult20 = foldr (*) 1 $ zipWith (^) primes $ map maximum $ map (\p -> map (power p) [1..20]) primes
@fnoble
fnoble / sdiff_empty.c
Last active September 22, 2016 21:52 — forked from mookerji/sdiff_empty.c
single diff measurement question (intersection of two structs via prns)
// Compiles with gcc -O0 single_diff_libswiftnav.c
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
typedef uint8_t u8;
typedef uint16_t u16;
@fnoble
fnoble / example.c
Last active August 29, 2015 14:16
Swift Navigation Doxygen style example
/** Brief description which ends at this dot.
* Details follow here.
*
* \todo Fix the bugs
*
* \param a Description of first argument
* \param b Description of second argument
* \return Descripton of the return value
*/
float lolz(int a, int b)
@fnoble
fnoble / sbp_example.py
Last active May 31, 2023 22:23
SBP decoding example with Python
# This gist has been moved into libsbp:
# https://github.com/swift-nav/libsbp/blob/master/python/sbp/client/examples/simple.py
@fnoble
fnoble / gist:8855189
Created February 7, 2014 00:15
Pandas Panel problem
import pandas
wp = pandas.Panel(randn(2, 5, 4), items=['Item1', 'Item2'],
major_axis=pandas.date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])
wp2 = pandas.Panel(randn(3, 5, 4), items=['Item1', 'Item2', 'Item3'],
major_axis=pandas.date_range('1/1/2000', periods=5),
minor_axis=['A', 'B', 'C', 'D'])
wp.sub(wp2).ix[:, :, 'A']
#define TAU_CROSSOVER 0.5
#define TAU_BIAS (TAU_CROSSOVER*10)
#define A (1e-3/TAU_CROSSOVER)
#define B (1e-3/TAU_BIAS)
double dll_update = chan->dll_pgain*(chan->dll_disc-dll_disc_prev) + chan->dll_igain*chan->dll_disc;
double pll_update = (1.023e6/L1_HZ)*(chan->pll_pgain*(chan->pll_disc-pll_disc_prev) + chan->pll_igain*chan->pll_disc);
// Original: