Skip to content

Instantly share code, notes, and snippets.

View nicokosi's full-sized avatar

Nicolas Kosinski nicokosi

View GitHub Profile
@nicokosi
nicokosi / strava-charts.r
Last active April 14, 2021 16:41
R code that generates charts from Strava API (http://strava.github.io/api/v3/activities/)
library(rjson)
library(httr)
library(ggplot2)
library(scales)
if (interactive()) {
token <- readline(prompt="Enter Strava access token: ")
activities <- GET("https://www.strava.com/", path = "api/v3/activities",
query = list(access_token = token, per_page = 200))
activities <- content(activities, "text")
query {
repository(owner: "softwarevidal", name: "arthur") {
pullRequests(states: [OPEN]) {
totalCount
}
}
}
@nicokosi
nicokosi / notes-on-funprog2.md
Last active September 21, 2017 23:06
Notes on Coursera course "Functional Program Design in Scala" (https://www.coursera.org/learn/progfun2)

Week 1

lecture "Recap: Functions and Pattern Matching"

recursive function + case classes + pattern matching: example JSON printer (Scala -> JSON) pattern matching in Scala SDK: PartialFunction is a Trait with def isDefinedAt(x: A): Boolean

lecture "Recap: Collections"

  • Iterable (base class)
    • Seq
import java.util.ArrayList;
import java.util.List;
import static java.lang.System.out;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static java.util.stream.IntStream.range;
public class WonderlandNumbers {
import Data.List
main = do
putStrLn $ unwords $ map show $ filter isWonderNumber [100000..10000000]
isWonderNumber :: Integer -> Bool
isWonderNumber x = all (== digits x) (map digits (multiples x))
multiples :: Integer -> [Integer]
multiples x = map (* x) [2..6]
@nicokosi
nicokosi / neo4j-gistgraph-for-fake-telco.adoc
Last active December 21, 2015 07:56
A Neo4J gistgraph (http://neo4j.com/graphgist) for a fake telco use case. Can be submitted on http://portal.graphgist.org/submit_graphgist.

Fake Telco

Let’s say that a ake telco needs to answer various questions such as:

  • contracts that are not used by any clients

  • etc…​

Setup graph:

import System.CPUTime
fibo :: Int -> Int
fibo n
| n <= 1 = n
| otherwise = fibo(n - 1) + fibo(n - 2)
getCPUTimeDouble :: IO Double
getCPUTimeDouble = do t <- System.CPUTime.getCPUTime; return ((fromInteger t) * 1e-12)
@nicokosi
nicokosi / linux-perf-tools.sh
Last active December 8, 2016 12:19
Some examples of Linux performance command lines as demonstrated by Brendan Gregg in video "Linux Performance Tools":http://techblog.netflix.com/2015/08/netflix-at-velocity-2015-linux.html
# CPU & mem usage per process (sampling)
top # list processes
top -h # list threads
top -c # show full command line
htop
# CPU usage per CPU:
mpstat -P ALL 1
# Processes (uptime, hierarchy, CPU usage, etc...):
@nicokosi
nicokosi / docker-nightclazz-découverte.md
Last active August 29, 2015 14:14
Notes durant le Docker nightclazz découverte de Zenika, le 05/02/2015

Docker nightclazz découverte

05/02/2015 par Mario Loriedo & Vincent Demeester

C'est une intro, prochaine session dans 1 mois

Intro

  • outil pour partager env de dev et env de prod (sysadmin) #devops: "build, ship and run" via conteneurs => + rapide, automatisation
// array
var myArray = [1, 2, 3];
// set
var mySet = { "foo": true, "bar": true, "baz": true };
set.foo // true
set.notExists // false
var object = { id: 126878, name: "ZALTRAP 25 mg/ml sol diluer p perf", sid: "vidal://product/126878", title: "ZALTRAP 25 mg/ml sol diluer p perf" };