Skip to content

Instantly share code, notes, and snippets.

View lassegit's full-sized avatar

Lasse lassegit

View GitHub Profile
@lassegit
lassegit / gist:a3afbeb1efcf8a5710c1ea077a122f11
Last active November 26, 2024 13:41
Restrict Cloudflare Workers for OpenAI API Access
const bannedColos = [
  // Hong Kong/Macau
  'HKG',
  'MFM',
  // China
  'CGD',
  'FUO',
  'FOC',
 'CAN',
@lassegit
lassegit / userData.sh
Created December 17, 2021 14:54
Install Docker and Docker Compose on EC2 Amazon Linux when initialised via user data
#!/bin/sh
# Install docker
yum update -y
amazon-linux-extras install docker -y
service docker start
usermod -a -G docker ec2-user
systemctl enable docker
# Install docker-compose
@lassegit
lassegit / flacToM4a
Last active February 13, 2021 15:20
Convert all .flac to .m4a
for i in *flac;do of="${i/.flac/.m4a}"; ffmpeg -i "${i}" -vn -acodec aac -b:a 320k -f mp4 -y "${of}";done
@lassegit
lassegit / functional-programming-utilities.md
Last active November 17, 2019 17:43
Functional programming utilities

Apply a list of functions to a value (right to left)

const compose = (...fns) => x => fns.reduceRight((y, f) => f(y), x);

const toSlug = compose(
  encodeURIComponent,
  join('-'),
  map(toLowerCase),
  split(' ')
);

Bøger - Bücher:

  • Viktor Frankl: Wer ein Warum zu leben hat: Lebenssinn und Resilienz
  • Viktor Frankl: Ärztliche Seelsorge: Grundlagen der Logotherapie und Existenzanalyse
  • Ian Kershaw: Das Ende
@lassegit
lassegit / composing-software.md
Last active March 17, 2019 23:05 — forked from rosario/composing-software.md
Eric Elliott's Composing Software Series
@lassegit
lassegit / redux.md
Created February 22, 2019 14:56
Redux structure

Isolate the redux datalayer in a separate redux/ folder within your src/ folder:

src/
  |-components/
  |-containers/
  |-utils/
  |-redux/
    |-actions/
    |-reducers/
@lassegit
lassegit / eslint.md
Last active March 19, 2019 12:29
Eslint installation and configuration for React apps

Install dependencies

yarn add -D eslint babel-eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-codebox eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react husky prettier lint-staged eslint-plugin-react-hooks

Add to package.json scripts:

"scripts": {
  "lint": "yarn lint:js",
  "lint:fix": "./node_modules/eslint/bin/eslint.js . --fix --cache",
  "lint:js": "./node_modules/eslint/bin/eslint.js . --cache",
  "prepush": "yarn lint"
import React from 'react';
const AppContext = React.createContext();
class AppContextProvider extends React.Component {
state = {};
render() {
return (
<AppContext.Provider value={this.state}>