Skip to content

Instantly share code, notes, and snippets.

View RanaivosonHerimanitra's full-sized avatar
🏠
Working from home

Ranaivoson RanaivosonHerimanitra

🏠
Working from home
  • Québec
View GitHub Profile
@walkerke
walkerke / app.R
Last active September 12, 2022 13:27
library(shiny)
library(spdep)
library(leaflet)
library(RColorBrewer)
atx <- readRDS('travis.rds')
atx$id <- 1:nrow(atx)
atx2 <- atx[!is.na(atx$income), ]
@jqtrde
jqtrde / modern-geospatial-python.md
Last active August 1, 2023 14:50
Modern remote sensing image processing with Python
@RanaivosonHerimanitra
RanaivosonHerimanitra / StratifiedRandomSampling.R
Last active January 3, 2016 13:29
built with 'data.table' package, this function aims to determine the number of sample to be surveyed in each strata using Optimal Stratified Random Sampling ( à la Neyman). Inputs include the raw dataset that contains information about strata, the name of the strata variable in this dataset and another dataset containing standard deviation of a …
require(data.table)
alloc_opti_data.table=function(n=1000
,dataset=ese_op2013_reste
,strate="strate2013"
,sd=ecart_type )
{
#count obs per strata to form Nh:
dataset=data.table(dataset)
output=dataset[,.N,by=strate]
@katowulf
katowulf / 1_query_timestamp.js
Last active September 21, 2023 20:28
Get only new items from Firebase
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
@anantn
anantn / firebase_detect_data.js
Created December 18, 2012 00:54
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
@cengel
cengel / rpyDemo.py
Created April 10, 2012 05:22
A simple example to use ggplot R library from within Python
import pandas
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
from rpy2.robjects.lib import grid
from rpy2.robjects.lib import ggplot2
## read in the distances to railroad (we calculated)
neardist = pandas.read_csv('data/NearDistance.csv')
## convert to R dataframe, via Python Dictionary data type