Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
@jeroen
jeroen / jsonlite_nested.S
Last active August 29, 2015 14:23
Nested data with jsonlite
# Nested data
library(jsonlite)
mydata <- jsonlite::fromJSON('https://gist.githubusercontent.com/mbostock/4063269/raw/a05a94858375bd0ae023f6950a2b13fac5127637/flare.json')
# Root node
mydata$name
mydata$children$name
# First child
mydata$children[[1,"name"]]
# Create your own free mongo database at https://mongolab.com/
# Need dev version of mongolite
devtools::install_github("jeroenooms/mongolite")
# Connect to the DB
library(mongolite)
m <- mongo("flights", url = "mongodb://readonly:[email protected]:43942/jeroen_test")
# Examples
m$count()
@jeroen
jeroen / example.R
Created July 1, 2015 08:42
ProtoBuf over OCPU
# Read data
library(httr)
library(RProtoBuf)
req <- GET("https://public.opencpu.org/ocpu/library/MASS/data/cats/pb")
cats <- unserialize_pb(req$content)
# rnorm(5, 10, 3)
payload <- list(
n = 5,
mean = 10,
@jeroen
jeroen / gist:ad47e94a27551ee4d961
Created July 2, 2015 09:34
useR 2015 to do list
- Implement public key verification for R packages
- Alternative windows buidls based on msys2
- Build Xapien for Stefan's: https://github.com/stewid/xapr
-
@jeroen
jeroen / gpgme-win-64.txt
Last active August 29, 2015 14:24
gpgme on windows x64
GPGME 2015-07-15 10:07:53 <0x12cc> gpgme_debug: level=9
GPGME 2015-07-15 10:07:53 <0x12cc> gpgme_check_version: call: 0=0000000000000000, req_version=(null), VERSION=1.5.5
GPGME 2015-07-15 10:07:53 <0x12cc> gpgme_check_version_internal: call: 0=0000000000000000, req_version=(null), offset_sig_validity=52
GPGME 2015-07-15 10:07:53 <0x12cc> gpgme_set_locale: enter: ctx=0000000000000000, category=2, value=English_United States.1252
GPGME 2015-07-15 10:07:53 <0x12cc> gpgme_set_locale: leave
GPGME 2015-07-15 10:07:53 <0x12cc> _gpgme_get_gpgconf_path: 'GNU\GnuPG\gpgconf.exe' not found
GPGME 2015-07-15 10:07:53 <0x12cc> gpgme-dinfo: gpgconf='[null]'
GPGME 2015-07-15 10:07:53 <0x12cc> _gpgme_get_gpg_path: 'GNU\GnuPG\gpg.exe' not found
GPGME 2015-07-15 10:07:53 <0x12cc> engine.c:155: returning error: Invalid crypto engine
Error : GPG engine init error: Invalid crypto engine
@jeroen
jeroen / gpgme-mingw-test.sh
Last active August 29, 2015 14:26
Test gpgme on mingw
# build with msys2
/usr/bin/gcc test.c -o gpgme-test-msys.exe -DDEBUG -I/usr/include -L/usr/lib /usr/lib/libgpgme.a /usr/lib/libgpg-error.a /usr/lib/libassuan.a -lintl -liconv
# works:
./gpgme-test-msys.exe
# build with mingw32 and mingw64
/mingw32/bin/gcc test.c -o gpgme-test-mingw32.exe -DDEBUG -I/mingw32/include -L/mingw32/lib /mingw32/lib/libgpgme.a /mingw32/lib/libgpg-error.a /mingw32/lib/libassuan.a -lws2_32
/mingw64/bin/gcc test.c -o gpgme-test-mingw64.exe -DDEBUG -I/mingw64/include -L/mingw64/lib /mingw64/lib/libgpgme.a /mingw64/lib/libgpg-error.a /mingw64/lib/libassuan.a -lws2_32
@jeroen
jeroen / test.md
Last active August 29, 2015 14:26
Test curl proxy conf

Test IE proxy settings with curl

The goal is to correctly test the various possible proxy configurations under windows and use those settings in the curl package.

Install the latest version of the curl package:

install.packages("curl")
stopifnot(packageVersion("curl") >= "0.9.2")
library(Rmpfr)
# To calculate x^3 when x is 256 bits
big <- function(x){mpfr(x, 256*3)}
# The standard secp256k1 curve
p <- big(2)^256 - sum(rep(big(2), 7) ^ c(32, 9, 8, 7, 6, 4, 0))
# Test the example from the book (p 67)
x <- big("55066263022277343669578718895168534326250603453777594175500187360389116729240")
@jeroen
jeroen / w32-util.patch
Last active August 29, 2015 14:26
Patch for mignw-w64-gpgme
--- w32-util.c 2015-08-05 14:36:14.302473400 +0200
+++ w32-util-fix.c 2015-08-05 14:34:49.600519000 +0200
@@ -454,6 +454,22 @@
}
}
}
+
+ /* On Windows x64 also check in C:\Program Files (x86)\ */
+ if (!result && SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILESX86, 0 ))
+ {
/* Jeroen Ooms 2015
* Example of queueing objects to be free later with their corresponding
* free() function.
*/
#include <stdlib.h>
#include <stdio.h>
struct node {
void (*fun)(void *target);
void *ptr;