Skip to content

Instantly share code, notes, and snippets.

@eugeneteo
eugeneteo / animate.R
Created February 11, 2017 05:57 — forked from thomasp85/animate.R
Animating graph over time
library(ggraph)
library(gganimate)
library(igraph)
# Data from http://konect.uni-koblenz.de/networks/sociopatterns-infectious
infect <- read.table('out.sociopatterns-infectious', skip = 2, sep = ' ', stringsAsFactors = FALSE)
infect$V3 <- NULL
names(infect) <- c('from', 'to', 'time')
infect$timebins <- as.numeric(cut(infect$time, breaks = 100))
# We want that nice fading effect so we need to add extra data for the trailing
@eugeneteo
eugeneteo / generate.py
Created January 23, 2017 00:06 — forked from adulau/generate.py
Simple script to scatter plot ISN values over time (+ TCP port as color) from pcap
# Simple script to show the ISN value from a tshark output (extracting non relative ISN)
#
# tshark -n -r <yourcapturefile.cap" -T fields -e frame.time_epoch -T fields -e ip.src -T fields -e tcp.srcport -T fields -e ip.dst -T fields -e tcp.dstport -T fields -e tcp.seq -T fields -e tcp.flags -T fields -e ip.ttl -o tcp.relative_sequence_numbers:FALSE | awk -e '{print $1"\t"$6"\t"$5}' | python3 generate.py
#
# by Alexandre Dulaunoy - for analysis session given more info -> http://www.foo.be/cours/dess-20162017/
#
#
import numpy as np
import fileinput
@eugeneteo
eugeneteo / TestNgrams.scala
Created March 28, 2016 06:58 — forked from thvasilo/TestNgrams.scala
Simple job to ensure LZO compressed Google Ngrams data can be read
import org.apache.spark._
import org.apache.spark.SparkContext._
import org.apache.spark.rdd.RDD
import scala.util.Random
import java.io._
import java.util.Properties
import org.apache.hadoop.fs._;
import org.apache.hadoop.conf._;
import org.apache.hadoop.io._;
@eugeneteo
eugeneteo / scaladays2014.md
Created December 19, 2015 13:09 — forked from kevinwright/scaladays2014.md
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

## we need the libraries bookdown, knitr, inline, markdown, pryr
system("git clone https://github.com/hadley/adv-r.git")
setwd("adv-r")
library(knitr)
embed_png <- bookdown:::embed_png
rmds <- list.files(pattern = "^.*rmd$")
sapply(rmds, function(x) knit(x))
cat("---\ntitle: Advanced R\nauthor: Hadley Wickham\nlanguage: en-US\n...\n",
file = "front_matter.txt")
## assuming we installed pandoc via cabal
This Shiny application is designed to help analysing trading strategies. It is an ongoing project that I improve when time allows. Feel free to get in touch should you have any suggestion.
*How to use the App as it is?
The App uses as input several csv files (one for each strategy). Each file has two columns: date and daily return. There is an example of such a file in the Github repository. The code is essentially made of 3 files.
-ui.R: controls the layout and appearance of the app
-server.R: contains the instructions needed to build the app. You can load as much strategies as you want as long as the corresponding csv file has the right format (see below).
-shinyStrategyGeneral.R: loads the required packages and launches the app
put ui.R and server.R file in a separate directory
In the server.R file change the inputPath, inputFile and keepColumns parameters to match your setting. The first two are self explanatory the third one is a list of column names within the csv file. Keep only date and daily return
@eugeneteo
eugeneteo / zombie.c
Last active August 29, 2015 14:14 — forked from codeswimmer/zombie.c
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main ()
{
pid_t child_pid;
child_pid = fork ();
if (child_pid > 0) {
{
"metadata": {
"name": "",
"signature": "sha256:ca9fef18c8ba5d081020e90fd0b6e2aca0d619a72b0c58577939f5eeed6c8196"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
nomad=fromJSON(paste(scan("http://nomadlist.io/api/v1", what="c",sep=""),collapse=""))
nomad.has=function(){names(nomad[3]$cities[[1]])}
nomad.get=function(y){unlist(lapply(nomad[3]$cities,function(x){x[[y]]}))}
nomadCost = as.numeric(nomadvar("nomadCost")[names(nomadvar("nomadCost"))=="USD"])
nomadScore = as.numeric(nomadvar("nomadScore"))
plot(nomadCost, nomadScore)
cost.vs.score = lm(nomadScore ~ nomadCost)
abline(cost.vs.score,col="red")