Skip to content

Instantly share code, notes, and snippets.

View jashmenn's full-sized avatar

Nate Murray jashmenn

View GitHub Profile
@jashmenn
jashmenn / s3-upload-node.js
Created March 23, 2020 15:13
Simple example of uploading to S3 from the filesystem with Node.js - If you're trying to learn how to do this, checkout Fullstack Node.js https://newline.co/fullstack-nodejs
const fs = require('fs')
const AWS = require('aws-sdk')
const { promisify } = require('util')
const s3 = new AWS.S3()
s3.uploadP = promisify(s3.upload)
const params = {
Bucket: 'fullstack-printshop',
Key: 'profile-photos/thedude.jpg',
Body: fs.createReadStream('thedude.jpg')
}
@jashmenn
jashmenn / generatePath.js
Last active March 6, 2020 03:35
Deconstruction of the curves on @Wattenberger's Thinking in Hooks Post
// This code is from: https://github.com/Wattenberger/Wattenberger-2019/blob/07024a820011988f5fbefed21161b1111f38e710/src/components/Blog/posts/Hooks/Hooks.jsx#L451-L470
// It generates the SVG path for the curve between two lines on the post "Thinking in React Hooks", located here: https://wattenberger.com/blog/react-hooks
//
// It's a good idea to pull up the documentation on SVG paths here: https://www.w3.org/TR/SVG/paths.html
//
// As you may know, SVG paths are specified by a string where a
// letter is the "command" and the numbers following are the "arguments"
//
// We'll be using 4 commands:
//
FROM: https://people.xiph.org/~greg/signdemo.txt
With Bitcoin 0.7 it's possible to keep your private keys
entirely offline without third party software.
In this example we have two hosts [offline] which is
totally offline and without a copy of the blockchain
and [online] which is a regular online node, both
running bitcoin 0.7.
@jashmenn
jashmenn / irbrc.rb
Created June 26, 2013 18:03
put in ~/.irbrc
# vim: set ft=ruby
#
# Nate Murray's ~/.irbrc
#
# Can be found at:
# http://gist.github.com/6626
# git clone git://gist.github.com/6626.git gist-6626
#
# Include colorization
require 'rubygems'
# Raw transaction API example work-through
# Send coins to a 2-of-3 multisig, then spend them.
#
# For this example, I'm using these three keypairs (public/private)
# 0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86 / 5JaTXbAUmfPYZFRwrYaALK48fN6sFJp4rHqq2QSXs8ucfpE4yQU
# 04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a986818a7cb624532f062c1d1f8722084861c5c3291ccffef4ec6874 / 5Jb7fCeh1Wtm4yBBg3q3XbT6B525i17kVhy3vMC9AqfR6FH2qGk
# 048d2455d2403e08708fc1f556002f1b6cd83f992d085097f9974ab08a28838f07896fbab08f39495e15fa6fad6edbfb1e754e35fa1c7844c41f322a1863d46213 / 5JFjmGo5Fww9p8gvx48qBYDJNAzR9pmH5S389axMtDyPT8ddqmw
# First: combine the three keys into a multisig address:
./bitcoind createmultisig 2 '["0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86","04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a9
@jashmenn
jashmenn / redirect-url-s3.sh
Created September 27, 2018 17:52
Use S3 as a url short-linker / redirection service
#!/bin/bash -x
if [[ $# -eq 0 ]] ; then
echo 'Usage: cmd <s3 path> <redirect-location>'
echo 'e.g.'
echo 'redirect-url-s3.sh www.fullstackreact.com/r/react-from-zero-satisfaction https://nate177.typeform.com/to/PTJ9ZI'
exit 0
fi
S3_PATH=$1
@jashmenn
jashmenn / extract-text.clj
Created December 1, 2010 20:56
extract the text from a webpage using jericho html parser in clojure
;; lein dep: [net.htmlparser.jericho/jericho-html "3.1"]
(ns foo.preprocess
(:import
[java.io File BufferedInputStream FileInputStream]
[net.htmlparser.jericho Source TextExtractor]))
(def filename "data/raw-html/cosmetiquemedspa.com/index.html")
(def file (java.io.File. filename))
(def source (Source. (BufferedInputStream. (FileInputStream. file))))
(def tex (TextExtractor. source))
@jashmenn
jashmenn / github-operator-mono-dark.css
Last active March 9, 2018 19:58
Stylish Chrome Extension for Github Operator Mono Dark Theme
.markdown-body .highlight pre,
table.highlight,
.blob-code-inner {
font-family: "Operator Mono";
font-weight: 400;
line-height: 1.5em;
font-size: 14px;
}
.markdown-body .highlight pre,
table.highlight {
@jashmenn
jashmenn / print_jung_graph_spec.rb
Created August 17, 2011 20:22
print a tree in ruby
require 'spec_helper'
describe "GraphExperiments" do
JungGraph = Java::EduUciIcsJungGraph
before(:each) do
n = LazyList[1..Infinity]
@tree = JungGraph::DelegateTree.new
@tree.setRoot("root")
@tree.addChild(n.next, "root", "a")
@jashmenn
jashmenn / geth-and-remix.scpt
Created November 16, 2017 17:48
open geth and remix in tabs via applescript
-- osascript services.scpt
tell application "iTerm 3"
activate
set myterm to (create window with default profile)
tell myterm
set mysession to (current session)
tell mysession
set name to "geth"
write text "cd ~/projects/fs/newline/newline-content-internal/fullstack-web3/private-net"
write text "./bin/geth --datadir=./datadir --nodiscover --rpc --rpcapi \"db,personal,eth,net,web3,debug\" --rpccorsdomain='*' --rpcaddr=\"localhost\" --rpcport 8545 --ws --wsapi \"db,personal,eth,net,web3,debug\" --wsorigins='*' --wsaddr=\"localhost\" --wsport 8546 console"