Skip to content

Instantly share code, notes, and snippets.

@FrankFang
FrankFang / lambda.js
Last active January 7, 2024 15:14
λ演算
ZERO = f => x => x
ONE = f => x => f(x)
TWO = f => x => f(f(x))
THREE = f => x => f(f(f(x)))
FOUR = f => x => f(f(f(f(x))))
FIVE = f => x => f(f(f(f(f(x)))))
SIX = f => x => f(f(f(f(f(f(x))))))
SEVEN = f => x => f(f(f(f(f(f(f(x)))))))
EIGHT = f => x => f(f(f(f(f(f(f(f(x))))))))
NINE = f => x => f(f(f(f(f(f(f(f(f(x)))))))))
@guojianwei001
guojianwei001 / aproducer.py
Created June 1, 2022 12:49 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@guojianwei001
guojianwei001 / program.cs
Last active May 30, 2022 13:01
Convert old BeginRead/EndRead asyn method to async/await method; implete a simple FromAsync similar to Task.Factory.FromAsync
#nullable enable
using System;
using System.IO;
using System.Threading.Tasks;
namespace AsyncAwaitPlay
{
class Program
{
/*
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@dhkatz
dhkatz / msys2-visual-studio-code.md
Last active November 4, 2024 14:06
Using MSYS2 with Visual Studio Code

Using MSYS2 with Visual Studio Code is extremely easy now thanks to the Shell Launcher extension by Tyriar.

First, install the extension and reload Visual Studio Code.

Then, open the settings.json to edit your settings.

Add the field shellLauncher.shells.windows. I recommend using autocompletion here so that all the default shells are added.

You should having something like this now:

@martin-magakian
martin-magakian / setup-kubernetes-ubuntu-16.md
Last active May 13, 2022 16:33 — forked from ruanbekker/setup-kubernetes-ubuntu-16.md
Install a 3 Node Kubernetes Cluster on Ubuntu 18

Master: Dependencies

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
@bvaughn
bvaughn / updating-external-data-when-props-changes-using-promises.js
Last active June 16, 2024 21:56
Example for loading new external data in response to updated props
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};
@ruanbekker
ruanbekker / setup-kubernetes-ubuntu-16.md
Last active October 21, 2023 08:25
Install a 3 Node Kubernetes Cluster on Ubuntu 16

Master: Dependencies

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@emoacht
emoacht / Program.cs
Created October 25, 2015 04:52
Sample of Task.Factory.FromAsync method
using System;
using System.IO;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
if (0 == args.Length)
return;