Skip to content

Instantly share code, notes, and snippets.

View yannabraham's full-sized avatar

Yann Abraham yannabraham

  • Janssen Pharmaceutical Companies of Johnson & Johnson
  • Beerse (BE)
View GitHub Profile
@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mblondel
mblondel / kernel_kmeans.py
Last active January 4, 2024 11:45
Kernel K-means.
"""Kernel K-means"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state
@bobthecat
bobthecat / Rcpp_cosine.r
Created June 9, 2012 23:29
Rcpp cosine similarity
require(inline)
require(RcppArmadillo)
## extract cosine similarity between columns
cosine <- function(x) {
y <- t(x) %*% x
res <- 1 - y / (sqrt(diag(y)) %*% t(sqrt(diag(y))))
return(res)
}
@jeromyanglim
jeromyanglim / example-r-markdown.rmd
Created May 17, 2012 04:23
Example of using R Markdown
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown)
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for
[reproducible analysis](http://stats.stackexchange.com/a/15006/183).
Specifically, this post
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and
(5) discusses the implications of R Markdown.
@mattismyname
mattismyname / imgupload.py
Created January 3, 2011 04:20
Python script to upload a batch of files to Evernote
#!/usr/bin/env python
#
# To run, first set this environment variable to point to the Evernote API python bindings you downloaded from Evernote:
# export PYTHONPATH=/path/to/evernote/python/api
#
import sys
import hashlib
import time
import thrift.protocol.TBinaryProtocol as TBinaryProtocol
@mbostock
mbostock / .block
Last active May 22, 2022 00:36
Every ColorBrewer Scale
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-color-schemes
@dsparks
dsparks / alphahull.R
Created December 4, 2012 02:53
Alpha Hull Example
doInstall <- TRUE
toInstall <- c("alphahull")
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Generate some sample data:
myData <- data.frame(x = rnorm(500), y = rnorm(500))
# With a unit-circle hole in the center:
myData <- myData[sqrt(rowSums(myData^2)) > 1, ]
plot(myData)
@simecek
simecek / facebook_friendship1.r
Created January 18, 2012 11:28
Facebook Friendship Graph
# the code uses 'facebook' function from the previous gist (https://gist.github.com/1634662) or
# see the original http://romainfrancois.blog.free.fr/index.php?post/2012/01/15/Crawling-facebook-with-R
# scrape the list of friends
friends <- facebook( path="me/friends" , access_token=access_token)
# extract Facebook IDs
friends.id <- sapply(friends$data, function(x) x$id)
# extract names
friends.name <- sapply(friends$data, function(x) iconv(x$name,"UTF-8","ASCII//TRANSLIT"))
# short names to initials
//Demonstrates basic manipulation to predict a EI-MS in Bioclipse using
//a sdf file containing a list of molecule.
//Requires medea data installed in default location
var mols = cdk.loadMolecules("/Sample Data/SDFfiles/CAS.5.sdf");
for (var i = 0; i < mols.size(); i++) {
var mol = mols.get(i);
mol = cdk.generate2dCoordinates(mol);
ui.open(mol);
cmlSpectrum = medea.predictMassSpectrum(mol)
@mbostock
mbostock / .block
Last active February 26, 2019 22:38
Horizon Chart
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-horizon-chart