Skip to content

Instantly share code, notes, and snippets.

View davesag's full-sized avatar
:octocat:
Coding

Dave Sag davesag

:octocat:
Coding
View GitHub Profile
@davesag
davesag / 1.development-norms.md
Last active August 9, 2022 10:28
Development Norms

A common set of development norms

Adhering to a common set of developer norms is a vital factor when a team of people is trying to produce high quality, timely, business critical software.

I'm regularly asked to work on codebases that do not conform to any known measure of coding standards.

Issues include, but are not limited to:

  • no linting
  • no, or few, or inadequate levels of automated testing
@davesag
davesag / Fox.js
Created April 24, 2021 11:10
A React wrapper for the MetaMask Fox logo
/**
* uses the @metamast/logo package to provide the core code.
* sometimes it's a bit sticky.
* The underlying code does a bunch of raw DOM manipulation so makes React a bit funny.
* see https://github.com/MetaMask/logo
*
* use <Fox followMouse slowDrift />
*/
import { useRef, useEffect, useMemo } from 'react'
@davesag
davesag / transitioning-to-git-flow.md
Created March 7, 2016 05:20
Transitioning to Git Flow — a primer.

Transitioning to git-flow.

Set up GitHub

  1. create a develop branch
  2. in settings => branches choose develop as the default branch and click update
  3. also in settings => branches choose to protect the master branch.

Udate your clone of your fork

@davesag
davesag / Example Game server with Sinatra and Event Machine.
Last active August 18, 2020 01:51
This is the shell of my Game server built using Sinatra and EventMachine Websockets. I am trying to extract the cookie information that is passed to the Websocket's `onopen` method via the `handshake.headers['Cookie'], but have been unable to work out how to properly decode the cookie. See https://github.com/rack/rack/issues/551 or http://stacko…
#!/user/bin/env ruby
#coding: utf-8
APP_ROOT = File.dirname(__FILE__)
PROJECT_NAME = 'My Fantastic Game'
PROJECT_HOST = '0.0.0.0'
WEB_PORT = 9292
WS_PORT = 8080
COOKIE_KEY = 'my.session.key'
COOKIE_SECRET = 'shh_replace_me_withsomething_moresecret'
@davesag
davesag / iMobilePrivacyPolicy.md
Created August 3, 2019 07:31
irMobile Privacy Policy

Privacy Policy for the irMobile app.

Your data is yours.

The app allows you to enter your personal Independent Reserve API Secret and Key and this data is stored locally in your device.

Your key and secret are used exclusively to access your account information via the Independent Reserve API.

That data is never used for anything else.

@davesag
davesag / ir-sockets-demo.html
Last active July 15, 2019 05:56
Realtime Buy and Sell orders on Independent Reserve
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Independent Reserve WebSockets Demo</title>
<script>
const SORTS = {
buy: (a, b) => b - a,
sell: (a, b) => a - b
}
@davesag
davesag / ir-api-example.js
Last active June 20, 2019 06:56
Work out how much the coins you have in Independent Reserve are worth (in $AUD)
// see https://github.com/davesag/ir-api
const ir = require('ir-api')
const WordTable = require('word-table')
// see https://www.independentreserve.com/api
// To generate an API Key, go to the Settings page, click "API Keys" and then click "generate".
// Select the level of access to grant the key and reenter your password to confirm the creation of the key.
// Ensure that you select the lowest level of access required for your usage, the recommended level being Read-only.
const apiKey = 'put-your-api-key-here'
const apiSecret = 'put-your-api-secret-here'
@davesag
davesag / isValid.js
Created May 14, 2019 05:31
Luhn Algorithm for Luhn validation of credit card number
const isValid = card => {
const value = card ? card.replace(/\D/g, "") : ''
if (!value) return false
let nCheck = 0
let bEven = false
for (let n = value.length - 1; n >= 0; n--) {
const cDigit = value.charAt(n)
let nDigit = parseInt(cDigit, 10)
@davesag
davesag / toc.js
Created June 8, 2018 04:01
A simple script to generate table of contents links for GitHub flavoured markdown docs
/**
* A simple script to generate table of contents links for GitHub flavoured markdown docs
*/
const makeAnchor = val => val.trim().toLowerCase().replace(/[^\w\- ]+/g, '').replace(/\s/g, '-').replace(/\-+$/, '')
// paths that end with / need a trailing -
const wrap = val => val.endsWith('/')
? `[\`${val}\`](#${makeAnchor(val)}-)`
: `[\`${val}\`](#${makeAnchor(val)})`