Skip to content

Instantly share code, notes, and snippets.

@chappjc
chappjc / user-matches-snippets.go
Created October 5, 2020 14:39
user-matches-snippets.go
const (
// TallyInactiveUserMatches gets a tally of inactive matches for a user,
// grouped by match status. This excludes cancel order matches with
// "takerSell IS NOT NULL". MatchComplete is inferred by "bRedeemTime IS NOT
// NULL" so the MatchComplete integer value need not be a query argument.
TallyInactiveUserMatches = `SELECT COUNT(*), status, makeraccount=$1 AS isMaker, takeraccount=$1 AS isTaker
FROM %s
WHERE takerSell IS NOT NULL
AND (takerAccount = $1 OR makerAccount = $1)
AND (NOT active OR bRedeemTime IS NOT NULL)
@chappjc
chappjc / dcrdex-swap.md
Last active April 7, 2020 23:33
dcrdex testnet DCR-BTC swap

The Trade

Maker sell 42 DCR for 0.42 BTC (0.01 BTC/DCR):

Taker sell, perfect match:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<div id="updates"></div>
<script src="https://alpha.dcrdata.org/js/socket.io.slim.js"></script>
<script>
var socket = io('https://alpha.dcrdata.org', {path: '/insight/socket.io', transports: ['websocket'], upgrade: false});
@chappjc
chappjc / socket.html
Created May 18, 2018 22:58 — forked from oluwandabira/socket.html
Test page that connects to the insight socket.io backend and logs new transactions and blocks.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<script src="http://localhost:7777/js/socket.io.slim.js"></script>
<script>
var socket = io('http://localhost:7777', {path: '/insight/socket.io', transports: ['websocket'], upgrade: false});
//var socket = io('https://mainnet.decred.org/')

Keybase proof

I hereby claim:

  • I am chappjc on github.
  • I am chappjc (https://keybase.io/chappjc) on keybase.
  • I have a public key whose fingerprint is 761D 6A0B EB28 6C9B 6A65 DD05 3F85 7EEA 746C 64D1

To claim this, I am signing this object:

@chappjc
chappjc / handler.go
Created March 23, 2017 00:40 — forked from rjz/handler.go
Handle Github webhooks with golang
// Now available in package form at https://github.com/rjz/githubhook
package handler
// https://developer.github.com/webhooks/
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
@chappjc
chappjc / jsonarray2csv.sh
Created February 24, 2017 00:29
convert JSON array to CSV
#!/bin/bash
in=`tee`
# echo $in
echo $in | jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' > $1
#!/bin/sh
/usr/local/letsencrypt/certbot-auto renew --noninteractive --standalone \
--pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx" \
--renew-hook "touch /etc/nginx/ssl/certsrenewed" --quiet --no-self-upgrade
EXITVAL=$?
if [ $EXITVAL -ne 0 ]; then
/usr/bin/logger -t certbot "certbot-auto exited abnormally with $EXITVAL"
exit $EXITVAL
fi
@chappjc
chappjc / c_cpp_properties.json
Created January 17, 2017 23:25
VS Code C++ project properties for VS 2015 w/ Windows SDK 10.0
{
"configurations": [
{
"name": "Mac",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},