Skip to content

Instantly share code, notes, and snippets.


Jordan Last lastmjs

View GitHub Profile
gane5h / dsr-deposit-volumes.sql
Created Jan 22, 2020
Week-on-week DSR deposit volumes
View dsr-deposit-volumes.sql
date_trunc('week', act_at) as act_at_week,
sum(amount / 1e18) as volume
from (
e.block_signed_at as act_at,
'0x' || encode(e.tx_hash, 'hex') as tx_hash,
live.hex_to_int(encode(e.topics[4], 'hex')) as amount,
'DSR_DEPOSIT' as act
from live.block_log_events e
treshugart /
Last active Apr 19, 2019
Server-side rendering web components in Electron

To render a component:

electron server.js --html "<x-app></x-app>" --scripts ./entry-point

Where --html is the HTML that you want to render and --scripts is the entry point that will be loaded prior to rendering the HTML. The entry point should contain all your component definitions that you need for the HTML to be rendered.

View nodejs-secure-web-server-with-websockets.js
'use strict';
const Fs = require('fs');
const Https = require('https');
const WebSocketServer = require('ws').Server;
const httpsServer = Https.createServer({
key: Fs.readFileSync(process.env.KEY),
cert: Fs.readFileSync(process.env.CERT)
const wss = new WebSocketServer({
JanMiksovsky / realTemplate.html
Created Oct 2, 2015
Create a Polymer element using a real <template>, not a <dom-module>
View realTemplate.html
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="import" href="../components/polymer/polymer.html">
<template id="test-element">
Hello, <content></content>.
foxxyz / nginx.conf
Last active Aug 26, 2020
Serve current directory via nginx
View nginx.conf
# Extremely basic development setup to serve the current directory at http://localhost:9001
# Start nginx in this directory with `nginx -p . -c nginx.conf`
# Stop nginx with `nginx -p . -s stop`
events {}
http {
# Serve files with correct mimetypes on OSX
# location may have to be adjusted depending on your OS and nginx install
include /usr/local/etc/nginx/mime.types;
mikelehen / generate-pushid.js
Created Feb 11, 2015
JavaScript code for generating Firebase Push IDs
View generate-pushid.js
* Fancy ID generator that creates 20-character string identifiers with the following properties:
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
leonderijke / svgfixer.js
Last active Dec 24, 2020
Fixes references to inline SVG elements when the <base> tag is in use.
View svgfixer.js
* SVG Fixer
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
* More info:
* -
* -
branneman /
Last active Feb 26, 2021
Better local require() paths for Node.js

Better local require() paths for Node.js


When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions