# | |
# Proof of concept - import maps with JSX transpilation. Can trivially | |
# be extended to TypeScript and all the languages currently supported | |
# with Sprockets. | |
# | |
# There are two parts to this: | |
# * Have `find_javascript_files_in_tree` in importmap-rails to not only | |
# find JS files, but also files that can be transpiled to JS. | |
# * Add sprockets JSX transformer, making use of esbuild | |
# |
function getMicroDataFromElement(element) { | |
element = element || document.body | |
function descendToAttribute(scope, attribute) { | |
return [].slice.apply(scope.children).reduce(function(props, child) { | |
return props.concat( | |
child.hasAttribute(attribute) ? [child] : descendToAttribute(child, attribute) | |
) | |
}, []) | |
} |
[ Update 2020-05-31: I won't be maintaining this page or responding to comments anymore (except for perhaps a few exceptional occasions). ]
Most of the terminal emulators auto-detect when a URL appears onscreen and allow to conveniently open them (e.g. via Ctrl+click or Cmd+click, or the right click menu).
It was, however, not possible until now for arbitrary text to point to URLs, just as on webpages.
# Backup DB | |
docker run \ | |
--rm \ | |
--link running_mongo:mongo \ | |
-v /data/mongo/backup:/backup \ | |
mongo \ | |
bash -c ‘mongodump --out /backup --host $MONGO_PORT_27017_TCP_ADDR’ | |
# Download the dump | |
scp -r USER@REMOTE:/data/mongo/backup ./backup | |
# Generates necessary certificates to ~/.docker | |
# | |
# Usage: | |
# bundle install | |
# ruby certgen.rb <domain> | |
require 'certificate_authority' | |
require 'fileutils' | |
if ARGV.empty? |
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common | |
sudo apt-get build-dep vim-gnome | |
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev | |
sudo rm -rf /usr/local/share/vim | |
sudo rm /usr/bin/vim | |
Some notes about the gist:
-
Calling "sync" creates an array to keep track of return values from any asynchronous operation.
-
The "resume" method is called in your generator code and its return value is passed as the callback to your asynchronous operation. Calling "resume" causes a counter to increment, letting your "sync" method know how many asynchronous operations are in flight.
-
The return value of "resume" is a function that causes the result of the asynchronous operation to be placed into the data structure in #1. Immediately after doing this assignment, we check to see if there are any outstanding asynchronous operations. If not, we resume the generator with either an (ordered) array containing the results of our asynchronous operations or (in the event of only one operation having been fired off)
The important thing to note is that both asynchronous operations have been fired off before yielding. Each callback (passed to these asynchronous calls) is the return value from the call to "resume" -
package main | |
import( | |
"log" | |
"net/url" | |
"net/http" | |
"net/http/httputil" | |
) | |
func main() { |