Skip to content

Instantly share code, notes, and snippets.

@sanxfxteam
sanxfxteam / GJBehavior.cs
Last active August 29, 2015 14:11
Implements basic scoring example for Unity of GameJolt API and API Helper by Loic Teixiera @loicteixeira
using UnityEngine;
using System.Collections;
// 0. Download this file as GJBehavior.cs
// 1. Attach this script to a new GameObject and rename it to "GJAPI".
// 2. Edit game and api key
// 3. To post score from anywhere
// if (GameObject.Find("GJAPI").GetComponent<GJBehavior>().CanAddScore)
// GJAPI.Scores.Add(score.ToString() + " points", (uint)score, 14669, "");
@sanxfxteam
sanxfxteam / gist:9572451
Last active August 29, 2015 13:57
dataframeFromJSON using jsonlite
isNestedDataFrame <- function(df) {
cols = colnames(df)
for (col in 1:ncol(df)) {
c <- df[[cols[col]]]
if (is.data.frame(c)) {
return (TRUE)
}
}
return (FALSE)
}
@sanxfxteam
sanxfxteam / dataframeFromJSON
Last active November 14, 2017 05:04
R: flatten a JSON file into a data frame
## Example data.json
[{"event":"glop","params":{"name":"toto","value":"glop"}},
{"event":"glot","params":{"name":"toto","info":"gggg"}},
{"event":"gogo","params":"text"},
{"event":"gogo2"}
];
## Expected output
event params.name params.value params.info params
1 glop toto glop <NA> <NA>