Skip to content

Instantly share code, notes, and snippets.

View transitive-bullshit's full-sized avatar
👋
hacking in paradise

Travis Fischer transitive-bullshit

👋
hacking in paradise
View GitHub Profile
{
"openapi": "3.0.2",
"info": {
"title": "Fast API",
"version": "0.1.0"
},
"paths": {
"/stylecloud": {
"post": {
"responses": {
GRPC_TRACE=all GRPC_VERBOSITY=DEBUG node benchmark-multiple-gets.js
D0326 16:48:14.918318000 4490681792 dns_resolver.cc:294] Using native dns resolver
I0326 16:48:14.918674000 4490681792 timer_manager.cc:88] Spawn timer thread
I0326 16:48:14.918704000 4490681792 init.cc:164] grpc_init(void)
I0326 16:48:14.918728000 123145542873088 timer_manager.cc:250] timers not checked: expect another thread to
I0326 16:48:14.918742000 123145542873088 timer_manager.cc:197] sleep until kicked
I0326 16:48:14.919055000 4490681792 completion_queue.cc:504] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
using gRPC via @google-cloud/firestore
I0326 16:48:15.248755000 4490681792 ssl_credentials.cc:130] grpc_ssl_credentials_create(pem_root_certs=(null), pem_key_cert_pair=0x0, verify_options=0x7ffeefbfe520, reserved=0x0)
I0326 16:48:15.256503000 4490681792 plugin_credentials.cc:250] grpc_metadata_credentials_creat
const axios = require('axios');
async function main () {
const getImg = (url) => {
return axios.get(url, { responseType: 'arraybuffer' });
}
const url = 'https://octodex.github.com/images/original.png';
const original = await getImg(url);
console.log('original', { status: original.status, size: original.data.length });
const axios = require('axios');
async function main () {
const url = 'https://octodex.github.com/images/original.png';
const optimized = await axios.post('https://ssfy.sh/dev/imagemin/optimizeImageUrl', { url }, {
responseType: 'arraybuffer'
});
console.log('optimized', { status: optimized.status, size: optimized.data.length });
const crypto = require('crypto')
const hash = (d) => {
const buffer = Buffer.isBuffer(d) ? d : Buffer.from(d.toString())
return crypto.createHash('sha256').update(buffer).digest('hex')
}
const hasha = require('hasha')
const hash = (input) => hasha(input, { algorithm: 'sha256' })
const pick = require('lodash.pick')
const stableStringify = require('fast-json-stable-stringify')
const data = pick(myData, ['keyFoo', 'keyBar'])
const fingerprint = hash(stableStringify(data))
@transitive-bullshit
transitive-bullshit / ghost-injection-head.html
Created September 6, 2019 20:37
Custom styles for self-hosted Ghost Blog
<style>
.gist {
width: 100%;
max-width: 680px;
}
.gist-file {
margin-bottom: 0 !important;
}
.gist + figcaption {
margin-top: 1em;
const isProd = (process.env.NODE_ENV === 'production')
/**
* Small utility for storing both live and test stripe IDs in a mongoose schema,
* but only publicly surfacing the active ID depending on the current
* environment.
*/
module.exports = (id, type = String, opts = { }) => {
const testId = `_${id}Test`
const liveId = `_${id}Live`