Skip to content

Instantly share code, notes, and snippets.

@rutcreate
rutcreate / README.md
Last active June 20, 2025 07:28
Install Python 3.10.x on Ubuntu 20.04

Prerequisite

sudo apt update
sudo apt install software-properties-common -y

Add custom APT repository

@alyleite
alyleite / wsl.md
Last active July 1, 2025 10:55
Failed to connect to bus: Host is down - WSL 2

» sudo systemctl daemon-reload

System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

==============================================

Edit*

  1. Open /etc/wsl.conf with any editor:
@CostasAK
CostasAK / one-dark-pro.json
Created February 22, 2021 14:35
Windows Terminal One Dark Pro
{
schemes: [
{
"name": "One Dark Pro",
"foreground": "#abb2bf",
"background": "#282c34",
"cursorColor": "#abb2bf",
"black": "#3f4451",
"red": "#e05561",
"green": "#8cc265",
@doggy8088
doggy8088 / WSLConfig.md
Created July 28, 2020 07:17
WSL 2 的 .wslconfig 設定檔說明
  • 編輯 %UserProfile%\.wslconfig 檔案

    • Command Prompt

      notepad %UserProfile%\.wslconfig
    • Windows PowerShell

@CatsMiaow
CatsMiaow / main.ts
Created June 12, 2020 05:26
Comlink example for Node.js with TypeScript
/**
* https://github.com/GoogleChromeLabs/comlink/blob/master/docs/examples/06-node-example/main.mjs
* https://github.com/GoogleChromeLabs/comlink/issues/476#issuecomment-642765445
* esModuleInterop to true in tsconfig.json compilerOptions.
*/
import { Worker } from 'worker_threads';
import * as comlink from 'comlink';
import nodeEndpoint from 'comlink/dist/umd/node-adapter';
import { cpus } from 'os';
@hamiltop
hamiltop / index.ts
Last active January 28, 2022 07:15
Example of Node, Typescript, and Comlink
import { getRemoteAPI } from "./my_worker";
async function init() {
console.time("launch");
const api = getRemoteAPI();
console.timeLog("launch");
console.time("first result");
console.timeLog("first result", await api.doMath());
console.time("second result");
console.timeLog("second result", await api.doMath());
@brandon93s
brandon93s / vs_code_context_menus.reg
Created October 8, 2017 19:39
Add context menu options for Visual Studio Code installed via scoop
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\Brandon\\scoop\\apps\\vscode\\current\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\Brandon\\scoop\\apps\\vscode\\current\\Code.exe\" \"%1\""

Motivation

  • expression-oriented programming one of the great advances of FP
  • expressions plug together like legos, making more malleable programming experience in-the-small

Examples

Write in an expression-oriented style, scoping variables as locally as possible:

var div = document.querySelectorAll('div'),
result;
for (var i = 0; i < div.length; i++) {
result = div[i];
result.addEventListener('click', function() {
alert(this.innerHTML);
});
}
@ova2
ova2 / map.ts
Last active December 27, 2019 06:52
// map.ts
import {Observable} from "./observable";
declare module "./observable" {
interface Observable<T> {
map<U>(f: (x: T) => U): Observable<U>;
}
}
Observable.prototype.map = function (f) {
// ... another exercise for the reader