Skip to content

Instantly share code, notes, and snippets.

View alecmce's full-sized avatar

Alec McEachran alecmce

View GitHub Profile
@alecmce
alecmce / google-maps-elevation-request.js
Created September 28, 2021 14:07
A very rough and ready file for requesting elevation data in a square grid pattern from Google Maps
const axios = require('axios');
const fs = require('fs')
const API_KEY = '[your google API key]'
const COMMA = '%2C'
const UNIT = 0.0001 // roughly 11.1 meters, +/- 5.55 m
const queue = makeLocations([55.9446035, -3.1940965], 10, UNIT * 8)
fs.writeFileSync('./data.csv', 'lat,lng,elevation\n')
@alecmce
alecmce / debounceUnlessCancelled.ts
Last active January 16, 2020 13:25
A way of using rxjs to wire-up a cancellable, debounced action
import { Observable, race, Subject, SubscribableOrPromise } from 'rxjs'
import { debounce, filter } from 'rxjs/operators'
describe('debounceUnlessCancelled', () => {
let action: jest.Mock<string>
let input: Subject<string>
let cancel: Subject<void>
let manualTrigger: Subject<string>
beforeEach(() => {
ˇÿˇ‡JFIFHHˇ˛,Optimized by JPEGmini 3.11.5.0 0x4a337109ˇ€C    
!'%!)/;3)-G=?CCCIOIAN;AC#ˇ€C #++##################################################ˇ¿"ˇƒˇƒK !"1AQ#2aqÅ—Bë°Ò3R±¡$b·CÇ“%4r¬‚Sí¢Ú5≤cDTsɡƒˇƒ'!1AQa"qÅ2ëB±°ˇ⁄ ?]XI[|Ï;‡ÁÎUl‚„J4ì®ç±Ô«”2hƒ2ÃÁ%ÆqU,XCr;.Ä[}+ØÀ9U∏e– {c:ùlŸ∫ëbfiR,Go≥A∫ø ≥®›¯€˜°¡?
Y¡§å·≥ÿ˚Í ˘UÒ+) ê∫Têƒv®ÆVI©‰nÄUynƒ±Ÿ≥H8S M¿˝™$W)nBß*t©Èälæ‹ë$ˇ.È#
íƒu|b„ŸŒ≤¨rñÎæü≥[µë¶I±¸' qÿ˝‚æ∑ìâ-¶ê∫n ë …Ÿ«OÈ@»XÌŸ\k:yI˜~ıÙg—Ôy≥¶FÊa”z‚‹HÇGõs†eáMuã flL≤çÆÄ4å”ÂSîªzR5»“WoüÔDàµáãÄ‹3ê}‘¢\£Y›@Ì∑fi‘Ùûº‡dò%Jí£ol
dWm•—=^sö^ké8@t∂tåTÓ+Is“Ã7Ìär2{ãâù_'9Ω)4fië◊¨ùE%=¡mEH8aÅEè2]>…<√ΩRtO[FæäP≤s–PcƒsdåÙ¶„:°e k\‡`Ù£'ı‹∫9D:z(ÿfãm ê2„≠@¡z˜UõL`‰b¨ùÓ€∂Æ!€ëyGææS§ÚzR“1e][(;Z/âˆ#Øn¥dӽ鉂6–GZn6,\Íà»⁄ì∑¨TÎÂÏÊãi. ìQÄÍ]Ñä‘Qˇ?c∂OùC∫‰ãÜ∏‹è ©$⁄¢S–g¶jEÏ⁄"n]z≤≥ˇh∆;<!Gñh∂flƒ˜ÄFÆˇ{“·Û,lõïNf#À
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/combineLatest';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/takeUntil';
/**
* I am learning rxjs. The most complicated part is understanding the
attribute vec3 vertexPosition;
attribute vec4 vertexColor;
attribute vec2 positionOnFace;
uniform mat4 bodyTransform;
uniform mat4 cameraTransform;
varying vec4 color;
varying vec2 texturePosition;
@alecmce
alecmce / console_output.txt
Created August 21, 2013 18:20
This app, built onto the iPad will eventually crash with the console_output.txt message. This is after using "sudo port install gcc47" and "sudo port select --set gcc mp-gcc47" (running on Mac 10.8 Mountain Lion, XCode 4 installed, Command Line Tools installed)
Reading symbols for shared libraries ............... done
Switching to remote-macosx protocol
[New thread 9219]
[Switching to process 9219 thread 0x2403]
0x2fe70028 in ?? ()
Reading symbols for shared libraries + done
Reading symbols for shared libraries +++++++++++++++............................................................................................................. done
Detected hardware: iPad 2 (WiFi)
Reading symbols for shared libraries .. done
Reading symbols for shared libraries ... done
@alecmce
alecmce / gist:6296341
Created August 21, 2013 15:56
partial from Object.h, built by #hxcpp
inline OBJ_ *GetPtr() const { return mPtr; }
inline OBJ_ *operator->()
{
#ifdef HXCPP_CHECK_POINTER
if (!mPtr) NullReference("Object", true);
// The handler might have fixed up the null value
if (!mPtr) NullReference("Object", false);
#endif
return mPtr;
}
@alecmce
alecmce / diff
Created August 18, 2013 21:40
I'm having problems running HXCPP (https://code.google.com/p/hxcpp/) dependent haxe IOS builds on Mac OS X "Mavericks" (XCode5-DP2 installed, running openfl-tools 1.0.8, so using G++). NULL references have to be removed. This diff removes all the build-breaking errors, though it's a big hacky guess.
Index: src/Math.cpp
===================================================================
--- src/Math.cpp (revision 748)
+++ src/Math.cpp (working copy)
@@ -133,7 +133,8 @@
#else
int pid = getpid();
struct timeval tv;
- gettimeofday(&tv,NULL);
+ struct timezone dummy;
@alecmce
alecmce / macro_problem
Created July 21, 2013 01:46
Currently https://github.com/alecmce/dust fails to compile because CollectionMap's macro pulls in the CollectionMapping class, which is an 'incomplete type' during the macro compilation pass. Does anyone have an idea how to fix this?
rake make:ipad
<SNIP/>
./src/dust/gui/GUIConfig.cpp:106:83: error: member access into incomplete type 'dust::collections::control::CollectionMapping_obj'
this->collections->mapDefined(Array_obj< int >::__new().Add((int)3).Add((int)4))->__Field(HX_CSTRING("toListeners"),true)(hx::ClassOf< ::dust::gui::systems::UIRootManager >());
^
include/dust/collections/control/CollectionMap.h:14:1: note: forward declaration of 'dust::collections::control::CollectionMapping_obj'
HX_DECLARE_CLASS3(dust,collections,control,CollectionMapping)
^
@alecmce
alecmce / Main.hx
Last active December 19, 2015 21:58
Interesting Macro error: if you define Example here in the same file as Main.hx then you get the error "Cannot access static field [field] from a class instance", but it's lying. Extract Example.hx to a different file and it compiles (and outputs "hello world", as you would expect).
package;
#if macro
import haxe.macro.Expr;
import haxe.macro.Expr.ExprOf;
import haxe.macro.Context;
import haxe.macro.Type;
#end
class Main