Skip to content

Instantly share code, notes, and snippets.

View johnthethird's full-sized avatar

John Lynch johnthethird

View GitHub Profile
@johnthethird
johnthethird / customdomain.rb
Created September 23, 2011 22:23 — forked from dwabnitz/customdomain.rb
rack middleware to resolve a custom domain to an original subdomain in a multi-tenant application
require 'net/dns/resolver'
# Custom Domain
#
# Require net-dns gem
#
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
// FYI this will currently allow you to only import to the same addr you exported from
func (w *Wallet) buildExportTxC2P(srcAddr common.Address, amount uint64, amountPlusFee uint64, nonce uint64) (*evm.UnsignedExportTx, error) {
exportTx := &evm.UnsignedExportTx{
NetworkID: w.ChainConfig.NetworkID,
BlockchainID: w.ChainConfig.CChainID,
DestinationChain: ids.Empty,
Ins: []evm.EVMInput{
{
Address: srcAddr,
Amount: amountPlusFee,
@johnthethird
johnthethird / my_controller.rb
Created April 16, 2013 17:53
Compile an arbitrary string of SCSS code in Rails controller
# widget#custom_css is a string containing CSS or SCSS code
def custom_css
respond_to do |format|
format.css {
# I cant believe there isnt a better way to just compile a sass string. Sheesh.
sprockets_env = Rails.application.assets
opts = sprockets_env.context_class.sass_config
ctx = sprockets_env.context_class.new(sprockets_env, "inmemory", Pathname(sprockets_env.root+"/app/assets/stylesheets"))
opts = opts.merge( :syntax => :scss,
:load_paths => [Rails.root.join("app/assets/stylesheets")],
@johnthethird
johnthethird / gist:ba2ca3cf8287de8f57cfd62616be261a
Created October 6, 2020 00:06
Avalanche Memos As Of 2020-10-05
(base) ❯ cat avm_transactions.json | jq '.[] | select(.memo!="" and .memo!="\u0000\u0000\u0000\u0000") | .memo' | sort | uniq 2.7.1
"0"
"03cf4d640442dd05a5"
"074e7490ad5656f4d4"
"1 Auftrag Binance"
"1"
"10% Cédric"
"10% of 5040 (mainnet day 1 unlock)"
"10% of 5353"
"10% of 996.11"
@johnthethird
johnthethird / http_client_with_cache.coffee
Created September 1, 2010 03:38
HTTPClientWithCache for Titanium in CoffeeScript
###
------> HTTPClientWithCache <------
This class is a wrapper around the standard Titanium.Network.HTTPClient(), but it adds a
few nice features:
* A cache backed by a SQLite database. All HTTPClientWithCache instances use the same database table, with
the primary cache key being a hash of the full URL (and any data parameters in a POST)
* The cache is automatically pruned before each query
* A retry mechanism, so that you can retry a particular query a number of times before failing.
@johnthethird
johnthethird / cap_notify.rb
Created May 4, 2011 20:02 — forked from rtekie/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
@johnthethird
johnthethird / server.log
Created December 3, 2011 03:37
Torquebox error: (LoadError) library `fcntl' could not be loaded: java.lang.NullPointerException
## SOLUTION
I was able to get past the error by putting this line at the top of config/application.rb
require 'fcntl'
##
torquebox-2.0.0.beta1
$ uname -a
Darwin JohnsAir.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
@johnthethird
johnthethird / markdown2json.js
Created March 9, 2018 23:53
Convert directory of Markdown files with front matter to JSON
const fs = require('fs')
const path = require('path')
const glob = require('glob-fs')()
const moment = require('moment')
const matter = require('gray-matter')
const processFile = filename => {
const fileObj = matter(fs.readFileSync(filename, 'utf8'))
const dataObj = {
content: fileObj.content,
@johnthethird
johnthethird / save_restore_dependencies.sql
Created January 30, 2018 22:42 — forked from mateuszwenus/save_restore_dependencies.sql
PostgreSQL: How to handle table and view dependencies
create table deps_saved_ddl
(
deps_id serial primary key,
deps_view_schema varchar(255),
deps_view_name varchar(255),
deps_ddl_to_run text
);
create or replace function deps_save_and_drop_dependencies(p_view_schema varchar, p_view_name varchar) returns void as
$$