Skip to content

Instantly share code, notes, and snippets.

View jg75's full-sized avatar

James Garner jg75

  • Amber Engine
  • Michigan
View GitHub Profile
interface Greeter {
greet: ()=>string
}
var helloWorld:Greeter = {
greet: ():string =>{return "Hello World"}
}
console.log(helloWorld.greet())
@jg75
jg75 / search.ts
Created June 26, 2018 20:39
another typescript example
function search(text:string, pattern:string): number {
let i:number = 0
let j:number = 0
for (i = 0; i < text.length; i++) {
for (j = 0; j < pattern.length && i + j < text.length; j++) {
if (text.charAt(i + j) != pattern.charAt(j)) {
break
}
}
"""A silly test."""
import argparse
import inspect
import timeit
def parse_args(args=None, description=__doc__):
"""Parse input arguments."""
parser = argparse.ArgumentParser(description=description)
"""Get a bunch of products from the API."""
import json
import os
import requests
from requests.auth import HTTPBasicAuth
class APISession:
"""An API session."""
#! /bin/bash
api='https://api.amberengine.com'
auth='<your email>:<your password>'
split-array() {
awk '{
gsub(/^\[/, "")
gsub(/\]$/, "")
gsub(/ /, "")
const https = require('https');
function getProductsByBrand(brand, limit, offset) {
let params = '?limit=' + limit.toString() + '&offset=' + offset.toString();
let path = '/brands/' + brand + '/products' + params;
let options = {host: host, path: path, auth: auth}
https.get(options, (response) => {
data = '';
@jg75
jg75 / Dockerfile
Last active July 16, 2018 21:30
How to install Chrome in Debian (Jessie)
FROM debian:jessie
RUN apt-get update -qq \
&& apt-get install -qqy \
apt-transport-https \
curl \
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub \
| apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
&& echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list.d/jessie-backports.list \
"""AWS SWF domains stuff."""
import argparse
import boto3
def get_swf_domains(client=boto3.client("swf"), **parameters):
"""Get AWS SWF domain names."""
paginator = client.get_paginator("list_domains")
for response in paginator.paginate(**parameters):
@jg75
jg75 / sample_workflow.py
Last active January 19, 2020 09:58
SWF Sample Workflow
"""
This is a sample workflow that includes a manual task.
Activities:
1. get_contact_activity
Get a subscription address.
2. subscribe_topic_activity
Create an SNS topic and subscribe the provided endpoints to the topic.
"""Convert number (0 indexed) to Excel spread sheet column."""
import string
def number_to_column(number):
"""Convert number (0 indexed) to Excel spread sheet column."""
if number < 0:
return ""
elif number < 26:
return string.ascii_uppercase[number]