Skip to content

Instantly share code, notes, and snippets.

@jotto
jotto / find-defi-assets-and-exchanges.js
Last active January 31, 2022 08:36
prints TSV of defi assets and exchange they're on
// prerequisites: node.js installed on your computer
// step 1: make a directory on your computer called "defi-assets-and-their-exchanges"
// step 2: copy and paste this file into that directory, call it "index.js"
// step 3: npm install --save got
// step 4: paste your messari API key into the empty string below
// step 5: node index.js
const YOUR_PERSONAL_MESSARI_API_KEY = "";
const got = require("got");

Keybase proof

I hereby claim:

  • I am jotto on github.
  • I am jotto (https://keybase.io/jotto) on keybase.
  • I have a public key whose fingerprint is 076D B3E2 8BEB 4B6D C493 70E8 5A06 9D26 BB21 17B8

To claim this, I am signing this object:

// npm install prerendercloud
require('prerendercloud')
.screenshot("https://google.com")
.then(jpgBuffer => fs.writeFileSync("out.jpg", jpgBuffer));
require('prerendercloud')
.pdf("https://google.com")
.then(pdfBuffer => fs.writeFileSync("out.pdf", pdfBuffer));
@jotto
jotto / react-15-and-no-script.html
Created June 29, 2017 06:53
How to make React 15 work with noscript tags and SSR
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>ReactJS 15.5.0 working example for noscript tags and SSR: 2017-06-28</title>
</head>
<body>
<div id='root'></div>
@jotto
jotto / Dockerfile
Created August 8, 2016 21:00
headless dev branch of Chrome Dockerfile
FROM ubuntu:14.04
RUN apt-get -y update
RUN apt-get -y install libnss3 libfontconfig1-dev
COPY ./* /
EXPOSE 9222
ENTRYPOINT ["./headless_shell", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222", "--no-sandbox"]
@jotto
jotto / omron-wellness-to-healthmate-withings-converter.rb
Created June 18, 2016 21:08
Convert ExportReport_CSV.txt from omronwellness.com to a CSV file healthmate.withings.com can read
require 'csv'
# example usage:
# ruby omron-to-withings.rb ExportReport_CSV.txt
# and it outputs a new CSV file that withings can read
if ARGV[0].to_s == ""
puts "first arg must be path to omron csv file for blood pressure readings"
exit(1)
end
@jotto
jotto / verbose_golang_http.go
Created November 30, 2015 15:48
include POST params and/or JSON params in Golang HTTP log output
// just an extension of the default Negroni logger
// https://github.com/codegangsta/negroni/blob/c7477ad8e330bef55bf1ebe300cf8aa67c492d1b/logger.go
// USAGE
// import (
// "github.com/gorilla/mux"
// "github.com/codegangsta/negroni"
// "github.com/kr/pretty"
// )
// router := mux.NewRouter()
@jotto
jotto / paperclip_convert_options_before_transformation.rb
Created March 27, 2013 17:21
https://github.com/thoughtbot/paperclip/issues/1085 this is cheap hack to get the convert_options to happen before transformation so the image size stays as defined even if there are convert options
raise "Expecting Paperclip version 3.3.1 since we are monkey patching it in application.rb" unless Paperclip::VERSION == "3.3.1"
module Paperclip
class Thumbnail < Processor
def make
src = @file
dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
dst.binmode
begin
@jotto
jotto / google_oauth2_access_token.rb
Created June 14, 2012 21:15
ruby command line script for generating google oauth2 access token
# (create oauth2 tokens from Google Console)
client_id = ""
client_secret = ""
# (paste the scope of the service you want here)
# e.g.: https://www.googleapis.com/auth/gan
scope = ""
@jotto
jotto / jotto_backbonejs_model_sugar.coffee
Created March 13, 2012 18:48
handling large forms in a 2-pane backbone.js app without re-painting the form elements
# returns an array of keys formatted like this
# blog[id]
# blog[title]
# blog[user_id]
# blog[admin][pageview]
# blog[admin][metrics][conversion_rate_last_30_days]
Backbone.Model.prototype.flatten_hash = (_attribs = this.attributes, _param_root = [this.paramRoot]) ->
_.flatten(
_(_attribs).map (v, k) =>
if v? && typeof(v) == 'object'