Skip to content

Instantly share code, notes, and snippets.

View lastmjs's full-sized avatar

Jordan Last lastmjs

View GitHub Profile
@gane5h
gane5h / dsr-deposit-volumes.sql
Created January 22, 2020 00:46
Week-on-week DSR deposit volumes
select
date_trunc('week', act_at) as act_at_week,
sum(amount / 1e18) as volume
from (
select
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
treshugart / server-side-rendering-web-components.md
Last active April 19, 2019 04:41
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.

'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
JanMiksovsky / realTemplate.html
Created October 2, 2015 21:49
Create a Polymer element using a real <template>, not a <dom-module>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="import" href="../components/polymer/polymer.html">
<template id="test-element">
Hello, <content></content>.
</template>
@foxxyz
foxxyz / nginx.conf
Last active March 3, 2024 10:42
Serve current directory via nginx
# 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
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* 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
leonderijke / svgfixer.js
Last active May 26, 2023 11:22
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* 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:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
@branneman
branneman / better-nodejs-require-paths.md
Last active April 8, 2024 00:22
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

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