Edit: This list is now maintained in the rust-anthology repo.
| // Gist name placeholder |
| Code from PyCon India 2019 Keynote Talk | |
| David Beazley (https://www.dabeaz.com) | |
| ====================================== | |
| This code is presented "as is" and represents what was live-coded | |
| during my closing keynote presentation at PyCon India, Chennai, | |
| October 13, 2009. I have made no changes to the files. | |
| Requires: Python 3.6+, numpy, pygame |
| "use strict"; | |
| [foo,bar] = TNG(foo,bar); | |
| // NOTE: intentionally not TNG(..) wrapping useBaz(), so that it's | |
| // basically like a "custom hook" that can be called only from other | |
| // TNG-wrapped functions | |
| function foo(origX,origY) { | |
| var [x,setX] = useState(origX); | |
| var [y,setY] = useState(origY); |
| import React, { Component } from 'react'; | |
| import firebase from '@firebase/app'; | |
| import firestore from './firestore'; // Code: https://gist.github.com/sconstantinides/546a48ba183b1234f750ca6261440199 | |
| class App extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| userId: localStorage.getItem('userId') || '', |
| function logColor(color, args) { | |
| console.log(`%c ${args.join(' ')}`, `color: ${color}`); | |
| } | |
| const log = { | |
| aliceblue: (...args) => { logColor('aliceblue', args)}, | |
| antiquewhite: (...args) => { logColor('antiquewhite', args)}, | |
| aqua: (...args) => { logColor('aqua', args)}, | |
| aquamarine: (...args) => { logColor('aquamarine', args)}, | |
| azure: (...args) => { logColor('azure', args)}, |
EDIT November 2017: recently the target wasm32-unknown-unknown was added to rustc which uses the LLVM WASM backend and works without Emscripten. This is now the recommended way of generating WASM code from Rust (as it is much easier). Thus, this gist document is pretty much useless now. A great resource on getting started with WASM and Rust is hellorust.com: Setup and Minimal Example.
| // UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that | |
| // does not support `nomodule` is probably not being used anywhere. The code below is left | |
| // for posterity. | |
| /** | |
| * Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will | |
| * load <script nomodule> anyway. This snippet solve this problem, but only for script | |
| * tags that load external code, e.g.: <script nomodule src="nomodule.js"></script> | |
| * | |
| * Again: this will **not** prevent inline script, e.g.: |
Forewarning: this can be a bit painful and may not work as expected. I've already had issues with even including stdlib through clang.
Make sure you have git installed and properly configured before continuing. This is trivial on Windows these days (https://git-scm.com/download/win) but is required to pull down Binaryen and Wabt.
Make sure to add the binary to your PATH variable in Windows.
This function create a saga that runs the sagas in the startingSagas array and takes
the actions with type indicated by changeActionType to replace the running sagas.
The replacing actions must have a field sagas cointaining the array with the new sagas.
function createDynamicSaga (changeActionType, startingSagas) {
function* _start (sagas) {
try {
yield sagas