Skip to content

Instantly share code, notes, and snippets.

@fluxynet
fluxynet / common_test.go
Last active July 14, 2021 17:45
Helpful functions to deal with http requests
package web
import (
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
@fluxynet
fluxynet / url_querybuilder.js
Last active February 19, 2020 12:36
Chainable URL Query Builder
function QueryBuilder(url) {
return {
state: {
sort: {},
limit: -1,
offset: -1,
filters: {}
},
sort(field, asc = true) {
this.state.sort[field] = asc;
@fluxynet
fluxynet / pricingTable.js
Created October 3, 2017 17:59
Calculate the cost of a service having a volume tier pricing table
/**
* Snippet to calculate the cost of a service having a volume tier pricing table
*/
((volume, pricingTable, pricingPerRemaining) => {
let item = pricingTable.reduce((p,v) => {
let total = 0;
if (p.volume === 0) {
total = 0;
} else if (p.volume < v.amount) {