Skip to content

Instantly share code, notes, and snippets.

View paulbellamy's full-sized avatar

Paul Bellamy paulbellamy

View GitHub Profile
@paulbellamy
paulbellamy / cap-38-changes.markdown
Last active September 1, 2021 15:15 — forked from JakeUrban/sep10-changes
CAP-38 AMM Changes

We've just released v6.0.1, of the SDF Javascript base library.

It includes changes to implement CAP-38, supporting automated market makers.

These changes will be released with the protocol v18 upgrade.

There are some further notes on the changes API endpoints, with mock responses, on this APIary. Further notes on the API changes are available in this document.

  • Each SDK must update to enable depositing, and withdrawing from liquidity pools.
  • SDKs must also update to include the new effect types, as well as new fields on Accounts.
@paulbellamy
paulbellamy / [id].tsx
Created June 3, 2020 12:07
Next.js Apollo graphql page with server-side query
import { ApolloProvider, useQuery } from "@apollo/react-hooks";
import ApolloClient, { InMemoryCache } from "apollo-boost";
import { GraphQLError } from "graphql";
import { GetServerSideProps } from "next";
import { useRouter } from "next/router";
import wrap, { InitApolloClient, WithApolloProps } from "next-with-apollo";
// Add our query here. If we want this in a different file we could use
// graphql-codegen to parse that for us and generate documents and hooks.
import gql from "graphql-tag";
@paulbellamy
paulbellamy / z_selecta.zsh
Created September 14, 2018 13:18
Nice little utility to use selecta with zsh z plugin.
# if selecta is present, set that as the default behaviour of z command
if which ${_Z_CMD:-z} 2>&1 1>/dev/null && which selecta 2>&1 1>/dev/null; then
z_selecta() {
if [ $# -gt 0 ]; then
_z "$@" 2>&1
else
_z "$(_z |& awk '{print $2}' | selecta)" 2>&1
fi
}
alias ${_Z_CMD:-z}='z_selecta'
# ctrl-z on the prompt will resume last
# This means, from vim I can ctrl-z to the shell, and ctrl-z back again.
foreground-last() {
fg %
}
zle -N foreground-last
bindkey '^z' foreground-last
@paulbellamy
paulbellamy / prevdir.zsh
Created September 14, 2018 13:23
zsh widget to flip between last two directories with ctrl-e
prev_dir() {
zle push-line
cd -
zle reset-prompt
echo
zle get-line
}
zle -N prev-dir prev_dir
bindkey '^e' prev-dir
@paulbellamy
paulbellamy / ignores_sub-ssi.html
Created April 19, 2013 08:45
Trying to figure out how to do SSI includes on nginx. The first example renders 503 errors (from Haproxy) into the page, while the second example ignores ssi include statements present in ```/dynamic_partials/header```.
<!--# include virtual="/dynamic_partials/header" set="header" wait="yes" -->
<!--# if expr="$header" -->
<!--# echo var="header" encoding="none" -->
<!--# else -->
{% include logged_out_header.html %}
<!--# endif -->
#!/bin/bash
host=`facter fqdn`
if [[ ! -n "$1" ]]; then
port=8000
else
port=$1
fi
echo "http://$host:$port"
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 2.
{
"title":"foo",
"version":"1.0.0",
"tags":[
"Tag1",
"Tag2"
],
"location":{
"disposition":"fixed",
"ele":"23.0",
#!/usr/bin/ruby
current_dir = File.expand_path(File.dirname(__FILE__))
files_dir = File.join(current_dir, "files")
files = Dir[File.join(files_dir, "*")] + Dir[File.join(files_dir, ".[^\.]*")]
files.each do |file|
command = "ln -sfF #{file} $HOME/."
puts command
`#{command}`
@paulbellamy
paulbellamy / output
Created December 13, 2012 10:29
A static typing system for ruby in ruby
$ ruby types_usage.rb
Fermenting the cheese for 5 days!
Fermenting the cheddar for 0.5 days!
./types.rb:7:in `types': Expected #<Walrus:0x7f7e71bb4328> to be a Cheese, but was a Walrus (ArgumentError)
from types_usage.rb:1:in `each'
from types_usage.rb:1:in `each_slice'
from ./types.rb:5:in `each'
from ./types.rb:5:in `each_slice'
from ./types.rb:5:in `each'
from ./types.rb:5:in `types'