Learn Go in ~5mins
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Basics
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/
the command zig run my_code.zig
will compile and immediately run your Zig
program. Each of these cells contains a zig program that you can try to run
(some of them contain compile-time errors that you can comment out to play
with)
#! Aaaaaaaaaaa this is JS!!! | |
// https://github.com/tc39/proposal-hashbang | |
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics | |
// Enjoy!!! | |
// Created at Nov 23, 2018 | |
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator | |
|> do { // https://github.com/tc39/proposal-do-expressions | |
case(?) { // https://github.com/tc39/proposal-pattern-matching | |
when {val}: class { |
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
const url = "https://projects.fivethirtyeight.com/2020-election-forecast/us_timeseries.json" | |
const req = new Request(url) | |
const res = await req.loadJSON() | |
const Biden = Math.round(res[0].candidates.find(x => x.candidate == "Biden").dates[0].winprob) + "%" | |
const Trump = Math.round(res[0].candidates.find(x => x.candidate == "Trump").dates[0].winprob) + "%" |
// This widget was created by Max Zeryck @mzeryck | |
/* | |
You can't add commit messages to gists, so I just want to say thanks to everyone who has used, modified, | |
and enjoyed this script. This version adds support for the iPhone 12 mini, thanks to arealhen for providing | |
a screenshot, and mintakka for a temporary solution. | |
*/ | |
// Widgets are unique based on the name of the script. | |
const filename = Script.name() + ".jpg" |
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: cyan; icon-glyph: magic; | |
// the node sonos http api base url (running on your Pi for example) | |
let sonosBaseUrl = "http://192.168.178.10:5005" | |
// optional for cover art: the ip address of one of your Sonos speakers | |
let sonosPlayerUrl = "http://192.168.178.38:1400" | |
let param = args.widgetParameter |
// set widget parameter to 1, 2, or 4 for small, wide or large widget | |
const url = "https://xkcd.com/info.0.json" | |
const req = new Request(url) | |
const { img: imgUrl } = await req.loadJSON() | |
const imgReq = await new Request(imgUrl) | |
const img = await imgReq.loadImage() | |
if (config.runsInWidget) { |
# Put this function to your .bashrc file. | |
# Usage: mv oldfilename | |
# If you call mv without the second parameter it will prompt you to edit the filename on command line. | |
# Original mv is called when it's called with more than one argument. | |
# It's useful when you want to change just a few letters in a long name. | |
# | |
# Also see: | |
# - imv from renameutils | |
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste) |
npm run test
npm run test:e2e
Tests should not be separated from the source code (think autonomous modules).
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |