Skip to content

Instantly share code, notes, and snippets.

#
# 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)
)
}, [])
}
@noahcoad
noahcoad / readme.md
Last active March 2, 2024 22:02
Code Minecraft with Python on Mac OSX

Code Minecraft with Python on Mac OSX

Here's a step-by-step to get started scripting Minecraft with Python on Mac OSX

@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active June 25, 2024 20:13
Hyperlinks in Terminal Emulators
@ipedrazas
ipedrazas / dump
Created April 22, 2017 04:10
Mongo dump/restore with docker
# 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
@sheerun
sheerun / certgen.rb
Last active April 10, 2022 15:39
Docker TLS certificate generator
# Generates necessary certificates to ~/.docker
#
# Usage:
# bundle install
# ruby certgen.rb <domain>
require 'certificate_authority'
require 'fileutils'
if ARGV.empty?
@jdewit
jdewit / vim74_lua
Last active January 30, 2024 04:57
Installing vim 7.4 with lua on Ubuntu 12.04
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
@laser
laser / _README.md
Last active December 31, 2015 11:59
Modifying sync (and consumer) to handle concurrent stuff

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" -

@JalfResi
JalfResi / revprox.go
Last active June 18, 2024 18:29
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {