Skip to content

Instantly share code, notes, and snippets.

View joekiller's full-sized avatar

Joseph Lawson joekiller

View GitHub Profile
@joekiller
joekiller / get.ts
Created December 7, 2021 23:55
https.get typescript nodejs
const data: string = await new Promise((resolve, reject) => {
https.get(targetUrl, (res) => {
res.setEncoding('utf8');
let rawData = '';
res.on('data', (chunk) => {
rawData += chunk;
});
res.on('end', () => {
try {
resolve(rawData);
@joekiller
joekiller / device-farm-action.ts
Last active November 19, 2021 22:15
AWS CDK Device Farm Action for CodePipeline
import codepipeline = require('@aws-cdk/aws-codepipeline');
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/core');
import { ActionCategory } from '@aws-cdk/aws-codepipeline';
import { Action } from '@aws-cdk/aws-codepipeline-actions';
/**
* The OS and type of application you are testing.
*/
export enum DeviceFarmAppType {
@joekiller
joekiller / gtk-firefox.sh
Last active October 21, 2021 04:15 — forked from phstc/gtk-firefox.sh
INSTALL FIREFOX ON AMAZON LINUX X86_64 COMPILING GTK+
#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Joseph Lawson 2012-06-03
# http://joekiller.com
# http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/
# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh
@joekiller
joekiller / enable-xray.sh
Last active June 25, 2020 19:09
Enable Lambda X-Ray on all functions via AWS CLI
#!/bin/bash
fns=($(aws lambda list-functions --query "Functions[].FunctionName" --output text))
GrantWrite () {
aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess --role-name $(ROLE=$(aws lambda get-function --function-name $1 --query "Configuration.Role" --output text);echo ${ROLE##*/})
}
XRay () {
aws lambda update-function-configuration --function-name $1 --tracing-config Mode=Active >/dev/null && echo $1 OK || (GrantWrite $1; aws lambda update-function-configuration --function-name $1 --tracing-config Mode=Active > /dev/null && echo $1 OK || echo $1 FAILED)
}
for f in ${fns[@]}; do XRay $f; done
@joekiller
joekiller / arch-linux-install dell precision 3510
Last active November 7, 2019 14:02 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt, luks, grub-git, nvme
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# This assumes a wifi only system...
wifi-menu
# sync the clock
timedatectl set-ntp true
@joekiller
joekiller / raw_stack.py
Created October 28, 2019 12:51
aws-cdk migrate RawStack to CDK
import yaml
from aws_cdk import core
class RawStack(core.Stack):
def __init__(self, scope: core.Construct, name: str, template_path: str, wrapped_parameters=None,
**kwargs) -> None:
"""import a stack off a path and munge in ssm variables if desired
:param template_path: path to raw stack being imported
:param wrapped_parameters: map of Parameter keys and default values
@joekiller
joekiller / nuke.sh
Created August 21, 2019 14:51
Nuke iam start-pipeline policies
for p in $(aws iam list-policies --query 'Policies[?starts_with(PolicyName, `start-pipeline`) == `true`].Arn' --output text); do
for v in $(aws iam list-policy-versions --policy-arn $p --query 'Versions[?IsDefaultVersion == `false`].VersionId' --output text); do
aws iam delete-policy-version --policy-arn $p --version-id $v
done
aws iam delete-policy --policy-arn $p
done
@joekiller
joekiller / query_timestamp.sql
Created December 20, 2017 14:54
Query alb_logs via time in AWS athena
-- Setup an AWS Athena Application Load Balancer table via
-- http://docs.aws.amazon.com/athena/latest/ug/application-load-balancer-logs.html
-- Use the following to query between timestamps.
SELECT * FROM "sampledb"."alb_logs"
where date_parse(time, '%Y-%m-%dT%H:%i:%s.%fZ')
between TIMESTAMP'2017-12-20 03:00:00' and TIMESTAMP'2017-12-20 05:00:00'
limit 10;
@joekiller
joekiller / README.md
Created July 6, 2017 20:14
nREPL ClojureScript Cursive IDE

Most Cursive IDE nREPL solutions point to the Figwheel approach which good but is a little cumbersome.

You can also use piggieback (which Figwheel also uses).

Update your project.clj as such:

(defproject blah "0.0.1"
  :profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.2"]]}
                   :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}})
@joekiller
joekiller / README.md
Last active May 30, 2017 19:52
Minimal Clojurescript aws x-ray lambda cljs-lambda

The basics here are to make sure you include the externs for advanced compliation and then to wrap the S3 client with an AWSXray capture client.

(def S3 (nodejs/require "aws-sdk/clients/s3"))
(def s3-client (S3. (clj->js {:httpOptions {:timeout 10000}})))

vs

(def S3 (nodejs/require "aws-sdk/clients/s3"))
(def AWSXRay (nodejs/require "aws-xray-sdk"))

(def s3-client (.captureAWSClient AWSXRay (S3. (clj->js {:httpOptions {:timeout 10000}}))))