Skip to content

Instantly share code, notes, and snippets.

Avatar
🤦‍♂️
Coding

Zander Martineau mrmartineau

🤦‍♂️
Coding
View GitHub Profile
@prologic
prologic / LearnGoIn5mins.md
Last active Apr 21, 2021
Learn Go in ~5mins
View LearnGoIn5mins.md
@ityonemo
ityonemo / test.md
Last active Apr 21, 2021
Zig in 30 minutes
View test.md

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

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)

@JamieCurnow
JamieCurnow / firestore.ts
Last active Apr 14, 2021
Using Firestore with Typescript
View firestore.ts
/**
* This Gist is part of a medium article - read here:
* https://jamiecurnow.medium.com/using-firestore-with-typescript-65bd2a602945
*/
// import firstore (obviously)
import { firestore } from "firebase-admin"
// Import or define your types
// import { YourType } from '~/@types'
@Jack-Works
Jack-Works / 2018.js
Last active Apr 9, 2021
cRAzY eSnEXt (*all* proposals mixed in)
View 2018.js
#! 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 {
@sammillner
sammillner / Forecast
Created Sep 30, 2020
Fivethirtyeight general election forecast
View Forecast
// 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) + "%"
@mzeryck
mzeryck / mz_invisible_widget.js
Last active Apr 17, 2021
A Scriptable script that creates "invisible" widget backgrounds based on your iOS wallpaper, and then either uses them as a Scriptable widget background or exports to your camera roll.
View mz_invisible_widget.js
// 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"
@marco79cgn
marco79cgn / sonos-nowPlaying.js
Last active Jan 28, 2021
A scriptable widget that shows what's playing on SONOS
View sonos-nowPlaying.js
// 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
View scriptable-xkcd-widget.js
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()
// for development, displays the widget if run
const debug = false;
@premek
premek / mv.sh
Last active Apr 17, 2021
Rename files in linux / bash using mv command without typing the full name two times
View mv.sh
# 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)
@tkrotoff
tkrotoff / HowToTest.md
Last active Jan 29, 2021
How I structure my tests
View HowToTest.md

File structure

  • src/fooBar.js
  • src/fooBar.html
  • src/fooBar.scss
  • src/fooBar....
  • src/fooBar.test.js => npm run test
  • src/fooBar.test.e2e.js (if I have E2E tests - Puppeteer, Playwright...) => npm run test:e2e

Tests should not be separated from the source code (think autonomous modules).