Skip to content

Instantly share code, notes, and snippets.

View lxe's full-sized avatar
🌮
Taco

Aleksey Smolenchuk lxe

🌮
Taco
View GitHub Profile
@lxe
lxe / goes16-rtlsdr.md
Last active May 8, 2024 20:43
Receive GOES-16 and GOES-17 Images with a Raspberry Pi and RTL-SDR dongle

Let's say a library developer Bob builds a module/library that exports a reducer and and action. He publishes the module to npm:

const INITIAL_STATE = { timesPoked : 0 };

export function makeSharedModuleAction(payload) {
  return { 'type': 'POKE', payload };
}

export function sharedModuleReducer(state = INITIAL_STATE, action) {
@lxe
lxe / montyhall.js
Created August 4, 2018 16:49
Monty Hall Problem Simulation
const winsIfSwitched = [];
const winsIfStayed = [];
function monty () {
const doorWithCar = Math.floor(Math.random() * 3);
const guessedDoor = Math.floor(Math.random() * 3);
// Host removes a door that...
const removedDoor = [0,0,0].reduce((result, n, index) => {
// 1) contestant didn't pick and...
@lxe
lxe / keybase.md
Created December 19, 2017 01:05
keybase.md

Keybase proof

I hereby claim:

  • I am lxe on github.
  • I am lxe (https://keybase.io/lxe) on keybase.
  • I have a public key whose fingerprint is A5EB BBE1 8756 D076 7335 5299 DB75 F538 D74F 76CF

To claim this, I am signing this object:

package main
import (
"encoding/json"
"errors"
"fmt"
"reflect"
"strconv"
)
@lxe
lxe / semver.sh
Last active September 18, 2022 22:16
Semver range validator in bash (using sed, grep, and bc)
#!/bin/bash
# set -x
# Stupid Simple Semver range validator
# (no build metadata and no prereleases, and no multiple ranges (||))
# Prints a list of versions that match a semver range
# ./semver.sh "range" version version version...

How do I React Component?

A variation with an unnecessary const

...since nothing in that file should be accessing that 'MyComponent' except the export.

Also that react import is very confusing though. Why do I need it? I don't reference that variable anywhere... oh wait some tool compiles the JSX for me at some point into React.createElement or whatever. Very opaque:

~/gl$ npm ls
gl-test@1.0.0 /Users/aleksey/gl
└─┬ gl@2.1.5
├── bindings@1.2.1
├── bit-twiddle@1.0.2
├─┬ glsl-tokenizer@2.0.2
│ └─┬ through2@0.6.5
│ ├─┬ readable-stream@1.0.33
│ │ ├── core-util-is@1.0.2
│ │ ├── isarray@0.0.1
CXX(target) Release/obj.target/bignum/bignum.o
In file included from ../bignum.cc:8:
In file included from ../../nan/nan.h:74:
In file included from ../../nan/nan_new.h:190:
../../nan/nan_implementation_12_inl.h:181:66: error: too many arguments to function call, expected at most 2, have 4
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~
/Users/aleksey/.node-gyp/5.3.0/include/node/v8.h:4674:3: note: 'New' declared here
static Local<Signature> New(
Searching 1282 files for "pulseTillDone\(" (regex)
/Users/aleksey/.nvm/v0.10.32/lib/node_modules/npm/lib/fetch-package-metadata.js:
109 pickVersionFromRegistryDocument(clone(regCache[url]))
110 } else {
111: npm.registry.get(url, {auth: auth}, pulseTillDone('fetchMetadata', iferr(next, pickVersionFromRegistryDocument)))
112 }
113 function returnAndAddMetadata (pkg) {
/Users/aleksey/.nvm/v0.10.32/lib/node_modules/npm/lib/cache/add-named.js: