Skip to content

Instantly share code, notes, and snippets.

evalparse xiaodaigh

Block or report user

Report or block xiaodaigh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View example_rayshader_4walls_hole.r
library(rayshader)
library(av)
library(future)
plan(multiprocess)
# set up an elevation matrix with a wall around the outside and a gap on each of
# the walls.
elmat1 = matrix(0, 500, 500)
elmat1[1:100, 1:200] = 3000
@xiaodaigh
xiaodaigh / ok.r
Created Mar 12, 2019
3d sun around a pole
View ok.r
library(rayshader)
library(av)
elmat1 = matrix(0, 500, 500)
elmat1[200:400, 200:400] = 971.0
sunangle = 33
for(sunangle in 140:360) {
elmat1 %>%
sphere_shade %>%
add_shadow(ray_shade(elmat1,zscale=3,maxsearch = 300, sunangle = sunangle),0.5) %>%
View cpu_bitonic_sort.jl
shared = rand(16)
bisort(shared) = begin
NUM = UInt(length(shared))
k = UInt(2)
while (k <= NUM)
j = div(k,2)
while(j >=1)
for tid in UInt(0):UInt(NUM-1)
@xiaodaigh
xiaodaigh / benchmark_2048.jl
Created Oct 15, 2018
2048 Simulation challenge
View benchmark_2048.jl
using StatsBase
const DIRS = [:left, :up, :right, :down]
function init_game()
grid = zeros(Int8,4,4)
grid[rand(1:4),rand(1:4)] = rand2_1()
grid[rand(1:4),rand(1:4)] = rand2_1()
grid
end
@xiaodaigh
xiaodaigh / server.R
Last active Oct 12, 2018
A gist of programatically changing panel tabs in Shiny
View server.R
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# Reactive expression to generate the requested distribution. This is
# called whenever the inputs change. The renderers defined
# below then all use the value computed from this expression
data <- reactive({
dist <- switch(input$dist,
@xiaodaigh
xiaodaigh / 1_forwardflag.r
Last active Dec 20, 2017
Fast implementation of binary (true/false) forward looking flag
View 1_forwardflag.r
forwardflag <- function(bools, ...) {
if(typeof(bools) != "boolean") {
warning("input variable not of boolean type, the only other accepted type is 0 & 1")
}
forwardflag_(bools, ...)
}
forwardflag_ <- function(bools, period = 12) {
stopifnot(period > 0)
@xiaodaigh
xiaodaigh / ctree_kmeans_iris_model_assessment
Created Oct 15, 2017
ctree vs kmeans on the iris dataset
View ctree_kmeans_iris_model_assessment
# data prep ---------------------------------------------------------------
library(data.table)
data(iris)
iris_copy <- copy(iris)
setDT(iris_copy)
iris_copy_ctree <- copy(iris_copy)
# ctree model -------------------------------------------------------------
View infix.r
`infix_fn` <- function(left, right) {
#...some code
}
@xiaodaigh
xiaodaigh / feeatherc.r
Created Aug 28, 2017
Some R to read .feather data chunkwise
View feeatherc.r
# featherc
library(data.table)
library(feather)
library(future)
library(dplyr)
plan(multiprocess)
options(future.globals.maxSize = Inf)
split_feather <- function(feather_file, by = NULL, parts = parallel::detectCores()) {
system.time(inputdata <- feather::read_feather(feather_file))
You can’t perform that action at this time.