Skip to content

Instantly share code, notes, and snippets.

View aleksandar-b's full-sized avatar
:electron:
Focusing

Aleksandar.B aleksandar-b

:electron:
Focusing
View GitHub Profile
@marcosci
marcosci / olympus_hex.R
Created November 5, 2021 12:32
Hexagonal Rayshading
library(LaCroixColoR)
library(sf)
library(fasterize)
library(rayshader)
library(raster)
library(exactextractr)
library(rayrender)
# load raster into R
elevation <- raster("Olympus_Mons_ortho-image.tif")
@walkerjeffd
walkerjeffd / rayshader-streamflow.R
Last active October 17, 2021 14:47
3D plot of ranked daily streamflow using {rayshader}
library(tidyverse)
library(dataRetrieval)
library(rayshader)
# install {av} to render movie
# install.packages("av")
# fetch daily streamflow from USGS NWIS
df_nwis <- readNWISdv(siteNumbers = "01059000", parameterCd = "00060") %>%
renameNWISColumns() %>%
import * as fs from 'fs';
import * as path from 'path';
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda-nodejs';
import * as kms from '@aws-cdk/aws-kms';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import * as acm from '@aws-cdk/aws-certificatemanager';
import * as alias from '@aws-cdk/aws-route53-targets';
import * as iam from '@aws-cdk/aws-iam';
import * as api from '@aws-cdk/aws-apigatewayv2';
@tylermorganwall
tylermorganwall / hadley_attractor.R
Last active April 9, 2021 19:06
3D Hadley Attractor
library(deSolve)
library(rayrender)
parameters = c(a = 0.2, b = 4, c = 8, d = 1)
state = c(X = 1, Y = 0, Z = 1)
Lorenz = function(t, state, parameters) {
with(as.list(c(state, parameters)), {
dX = -Y^2 - Z^2 - a*X + a*c
dY = X * Y - b * X * Z - Y + d
dZ = b * X * Y + X * Z - Z
@tylermorganwall
tylermorganwall / india_historical_map.R
Last active February 25, 2024 18:22
Historical Map of India with 3D elevation
library(raster)
library(rayshader)
#Load QGIS georeference image (see https://www.qgistutorials.com/en/docs/3/georeferencing_basics.html)
testindia = raster::stack("1870_southern-india_modified.tif")
#Set bounding box for final map (cut off edges without data, introduced via reprojection)
india_bb = raster::extent(c(68,92,1,20))
cropped_india = raster::crop(testindia, india_bb)
#Convert to RGB array
#lang rosette/safe
(require rosette/lib/angelic
(only-in racket/base syntax->datum))
(define-syntax-rule (define-distinct v x ...)
(begin
(define x v) ...
(assert (distinct? x ...))))
(define-syntax-rule (list-choices x ... sol)
(list (list (evaluate x sol) (syntax->datum #'x)) ...))
@cowboy
cowboy / abstraction-2020.js
Last active March 28, 2025 20:50
Abstraction.js 2020 Edition (ES6)
/*
* Abstraction.js 2020 Edition
*
* Copyright (c) 2020 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
let $elseif, $else, $if = state => state ? (
$elseif = () => () => {},
@andrewroberts
andrewroberts / createPDF_filename.gs
Last active January 23, 2025 15:40
This is a Google Apps Script that creates a PDF file using a Google Doc template and the values in a Google Spreadsheet. It is based on www.andrewroberts.net/2014/10/google-apps-script-create-pdf/ but allows placeholders to be used in the filename.
// dev: andrewroberts.net
// Replace this with ID of your template document.
var TEMPLATE_ID = ''
// var TEMPLATE_ID = '1wtGEp27HNEVwImeh2as7bRNw-tO4HkwPGcAsTrSNTPc' // Demo template
// Demo script - http://bit.ly/createPDF
// You can specify a name for the new PDF file here, or leave empty to use the
// name of the template. Placeholders can also be placed in here.
import {Component} from '@nestjs/common';
import {InjectRepository} from '@nestjs/typeorm';
import {ILabelService} from './ILabelService';
import {Repository} from 'typeorm';
import {Label} from '../Models/Label';
@Component()
export class LabelsService implements ILabelService {
@branneman
branneman / fp-lenses.js
Last active May 17, 2023 00:56
JavaScript: Lenses (Functional Programming)
// FP Lenses
const lens = get => set => ({ get, set });
const view = lens => obj => lens.get(obj);
const set = lens => val => obj => lens.set(val)(obj);
const over = lens => fn => obj => set(lens)(fn(view(lens)(obj)))(obj);
const lensProp = key => lens(prop(key))(assoc(key));