Skip to content

Instantly share code, notes, and snippets.

View cbdavide's full-sized avatar

David Castelblanco cbdavide

View GitHub Profile
@jnothman
jnothman / plotview.py
Last active December 6, 2017 22:07
Generic Django plot view for matplotlib plot rendering and serving
from django.views import View
from django.http import HttpResponse
MIMETYPES = {
'ps': 'application/postscript',
'eps': 'application/postscript',
'pdf': 'application/pdf',
'svg': 'image/svg+xml',
'png': 'image/png',
'jpeg': 'image/jpeg',
public class Fibonacci{
public static int fibTopDown(int n, int [] fib) {
if(n==0) return 0;
if(n==1) return 1;
if(fib[n]!=0){
return fib[n];
}else{
fib[n] = fibTopDown(n-1, fib) + fibTopDown(n-2, fib);
return fib[n];
}
@viperwarp
viperwarp / ReactNativeJson.java
Created February 24, 2016 03:02
React-Native Module, ReadableMap/Array to Java JSON objects
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
@trajakovic
trajakovic / fedora-install-nodejs.sh
Last active February 16, 2019 16:55
Install node.js on fedora (23+).(v5.10.1)
#!/usr/bin/env bash
func_check_for_root() {
if [ ! $( id -u ) -eq 0 ]; then
echo "ERROR: $0 Must be run as root, Script terminating" ;exit 7
fi
}
func_check_for_root
#SETUP PARAMS