Skip to content

Instantly share code, notes, and snippets.

@dncrews
dncrews / run.ts
Created July 28, 2022 00:59
Add parameters to query from TypeORM
import { readFile, writeFile } from 'fs/promises';
const inputFile = 'input.txt';
const main = async () => {
const input = await readFile(inputFile, 'utf8');
const [queryRaw, parametersRaw] = input.split(' -- PARAMETERS: ');
// console.info({ queryRaw, parametersRaw });
const parameters: string[] = JSON.parse(parametersRaw);
// console.info({ parameters });
@dncrews
dncrews / dwolla-v2.d.ts
Created August 28, 2020 18:50
Dwolla TypeDefs
declare module 'dwolla-v2' {
export class Client {
apiUrl: string;
constructor(args: DwollaClientArgs);
delete(uri: string): Promise<DwollaClientResult>;
get(uri: string): Promise<DwollaClientResult>;
post(uri: string, payload: {}, headers?: DwollaHeaders): Promise<DwollaClientResult>;
}
export interface DwollaAchResult extends DwollaResultBody {
@dncrews
dncrews / productInventoryQuery.graphql
Created January 3, 2020 05:16
Get product inventory v1
query ProductInventory {
product(id: "product-1") {
inventory: {
available
}
}
}
@dncrews
dncrews / order.graphql
Last active January 3, 2020 05:08
Creating Order v1.1.0
type Order {
id: ID!
productsConnection: OrderProductsConnection!
}
input OrderInput {
lineItems: [OrderLineItemInput!]!
paymentToken: String!
}
@dncrews
dncrews / inventory.graphql
Last active January 3, 2020 05:00
Simple E-Commerce v1.0.0
type Inventory {
total: Int!
available: Int!
}
extend type Product @key(fields: "id") {
id: ID! @external
inventory: Inventory!
}
@dncrews
dncrews / .aliases.sh
Last active August 29, 2015 14:21
Annoying Version of `cd`
#######################################################
## Adds some frustration the `cd` command
## https://gist.github.com/dncrews/1ba8919b24b2e4569c2f
## Author: Dan Crews <crewsd@gmail.com>
#######################################################
#!/bin/sh
alias cd=annoyingCD
function annoyingCD () {
var euLocales = [
"de-at", //Austria
"fr-be", //Belgium (French)
"nl-be", //Belgium (Dutch)
"bg", //Bulgaria
"el-cy", //Cyprus
"cs", //Czech Republic
"da", //Denmark
"et", //Estonia
"fi", //Finland (Finnish)
@dncrews
dncrews / .bash_aliases
Last active December 24, 2015 09:59
Alias for foreman to use Procfile.dev if it exists.
alias fs="([[ -a Procfile.dev ]] && foreman start -f Procfile.dev) || foreman start"
@dncrews
dncrews / gist:6544608
Created September 12, 2013 22:19
JS get a cookie
getCookie : function(cookieID) {
var dc = document.cookie, prefix = cookieID + "=", begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0)
return null;
}
else
begin += 2;
var end = document.cookie.indexOf(";", begin);
@dncrews
dncrews / localeCopier.js
Created August 7, 2013 18:26
I'm writing this for the purpose of copying all of my local `locale` files from all of my node projects that are using `strong` translation library (https://github.com/fs-webdev/strong) or (https://github.com/timshadel/strong) to a centralized place so that I can create a "translation memory".
/**
* I'm writing this for the purpose of copying all of my local
* locale files from all of my node projects that are using
* `strong` translation library (https://github.com/fs-webdev/strong)
* or (https://github.com/timshadel/strong) to a centralized place
* so that I can create a "translation memory".
*
* Usage:
*
* node localeCopier.js # from path defaults to "."; to path defaults to "~/Documents/locales"