Instantly share code, notes, and snippets.

# Jérôme Renardjeromer

• Sort options
Created Feb 22, 2012
Orthodromic distance using the Harversine formula in Python
View orthodromicdistance.py
 # -*- coding: utf-8 -*- import math def calculate_orthodromic_distance(pointA, pointB): """ Calculates the great circle distance between two points. The great circle distance is the shortest distance. This function uses the Haversine formula : - https://en.wikipedia.org/wiki/Haversine_formula
Last active Oct 16, 2019
compass bearing between two points in Python
View compassbearing.py
 # LICENSE: public domain def calculate_initial_compass_bearing(pointA, pointB): """ Calculates the bearing between two points. The formulae used is the following: θ = atan2(sin(Δlong).cos(lat2), cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
Created Sep 3, 2013
Numbers Everyone Should Know
View numbers.everyone.should.know.txt
 Numbers Everyone Should Know L1 cache reference 0.5 ns Branch mispredict 5 ns L2 cache reference 7 ns Mutex lock/unlock 25 ns Main memory reference 100 ns Compress 1K bytes with Zippy 3,000 ns Send 2K bytes over 1 Gbps network 20,000 ns Read 1 MB sequentially from memory 250,000 ns
Created Sep 16, 2016
View postgres_update_strategies.py
 #! /usr/bin/env python # Tested on Postgres 9.5 import psycopg2 import datetime conn = psycopg2.connect("dbname=sandbox user=postgres") cursor = conn.cursor()
Created Nov 11, 2016
Graphite's storage aggregations for collectd metrics
View storageaggregations.conf
 # This is a work in progress. Any improvement welcome :) [collectd_plugin_entropy] pattern = \.entropy\.entropy\$ xFilesFactory = 0.3 aggregationMethod = last [collectd_plugin_tcpconns] pattern = \.tcp_connections.*\$ xFilesFactory = 0.3
Created Dec 23, 2016
View riemann.config
 (require '[org.spootnik.riemann.collectd :refer [rewrite-service-with]]) (require '[org.spootnik.riemann.thresholds :refer [threshold-check]]) (include "thresholds.clj") (include "services.clj") (logging/init {:file "/var/log/riemann/riemann.log"}) (let [host "127.0.0.1"] (tcp-server {:host host})
Created Jun 17, 2017
DateTime scalar for GraphQL
View graphql_datetime.go
 // DateTime Scalar for the https://github.com/graphql-go/graphql/ // See: https://github.com/graphql-go/graphql/pull/209 package graphqldatetime import ( "time" "github.com/graphql-go/graphql" "github.com/graphql-go/graphql/language/ast" )
Created Mar 8, 2019
View E0525.rs
 extern crate hyper; extern crate tokio; extern crate tokio_signal; use futures::Stream; use hyper::rt::Future; use hyper::service::service_fn_ok; use hyper::{Body, Request, Response, Server}; use futures::sink::Sink;
You can’t perform that action at this time.