Skip to content

Instantly share code, notes, and snippets.

View datiti's full-sized avatar

Cyrille Mescam datiti

View GitHub Profile
@datiti
datiti / randomint.cpp
Created April 20, 2022 08:28
C++ random generate int in range
// source: https://stackoverflow.com/questions/288739/generate-random-numbers-uniformly-over-an-entire-range
#include <iostream>
#include <random>
int main() {
const int range_from = 0;
const int range_to = 6;
std::random_device rand_dev;
std::mt19937 generator(rand_dev());
std::uniform_int_distribution<int> distr(range_from, range_to);
@datiti
datiti / example.dot
Created February 15, 2018 11:09
Graphviz dot examples
digraph {
//rankdir=LR
node[fontname=Roboto, style=rounded, shape=box]
edge[fontname=Roboto]
api_gateway [label=<api gateway<br/><font point-size="10">port:123</font>>]
config [label=<config<br/><font point-size="10">port:456</font>>]
discovery [label=<discovery<br/><font point-size="10">port:789</font>>]
hello [label="hello service"]
foo [label="foo service"]
bar [label="bar service"]
@datiti
datiti / morningstar.R
Created December 13, 2017 16:58 — forked from anonymous/morningstar.R
How to retrieve data from Morningstar
require(RCurl)
require(jsonlite)
myticker<-"FB"
url.histprice<-function(x){ return(paste0("http://globalquote.morningstar.com/globalcomponent/RealtimeHistoricalStockData.ashx?ticker=",x,"&showVol=true&dtype=his&f=d&curry=USD&range=1900-1-1|2014-10-10&isD=true&isS=true&hasF=true&ProdCode=DIRECT"))}
url.keyratios<-function(x){return(paste0("http://financials.morningstar.com/ajax/exportKR2CSV.html?t=",x))}
#Retrieve historical prices
json.histprice<-getURL(url.histprice(myticker))
json.histprice<-sub("NaN","\"NA\"",json.histprice)
@datiti
datiti / compute_specific_closed_days.py
Created December 13, 2017 12:51
Compute easter/ascension/pentecost dates
from datetime import date
from datetime import timedelta
def calc_easter_sunday(year: int) -> date:
"""
Returns Easter as a date object.
An implementation of Butcher's Algorithm for determining the date of Easter for the Western church.
Works for any date in the Gregorian calendar (1583 and onward).
Reference: http://code.activestate.com/recipes/576517-calculate-easter-western-given-a-year/
"""
@datiti
datiti / A_README
Created November 3, 2017 00:38 — forked from AndyFaibishenko/A_README
Example FIX to JSON mapper
This Gist contains an example of how to write a a FIX protocol parser using QuickFIX/J.
It also includes the XML data dictionary and a sample FIX message file with one OrderList message.
If you want to build/run this, you will need to link with QuickFIX/J and Jackson jars:
quickfixj-all-1.5.3.jar
mina-core-1.1.7.jar
slf4j-api-1.6.3.jar
log4j-1.2.15.jar
jackson-core-2.5.1.jar
jackson-databind-2.5.1.jar
jackson-annotations-2.5.1.jar
@datiti
datiti / GeoIP_update
Created May 13, 2015 10:14
Update GeoIP database for xtables geoip module of iptables
#!/bin/bash
# /usr/local/sbin/GeoIP_update
#
# Update geoip databases for xtables geoip module of iptables
# Last updated: 20150513
#
XTABLESADDONS=/usr/lib/xtables-addons/
XTABLEGEOIPDIR=/usr/share/xt_geoip/