Skip to content

Instantly share code, notes, and snippets.

View lxe's full-sized avatar
πŸ¦€
Crab

Aleksey Smolenchuk lxe

πŸ¦€
Crab
View GitHub Profile
@lxe
lxe / goestilevideo.sh
Created April 9, 2020 19:32
goestilevideo.sh
#!/bin/bash
# Usage: ./goestiles ~/goes17 2020-04-02
# Makes a video like this: https://twitter.com/lxe/status/1248117991067095040
# Requirements: imagemagick and ffmpeg
ROOT=$1
DATE=$2
# Clean up
@lxe
lxe / is-this-flux.md
Last active September 23, 2018 20:17
Simple React Flux/Redux Alternative

1. One global mutable (oh no) store:

const Store = {
  name: 'My Name',
  counter: 0
}

window.Store = Store; // Convenient!
@lxe
lxe / goes16-rtlsdr.md
Last active April 9, 2025 14:33
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 February 21, 2025 14:20
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
[email protected] /Users/aleksey/gl
└─┬ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”¬ [email protected]
β”‚ └─┬ [email protected]
β”‚ β”œβ”€β”¬ [email protected]
β”‚ β”‚ β”œβ”€β”€ [email protected]
β”‚ β”‚ β”œβ”€β”€ [email protected]