Skip to content

Instantly share code, notes, and snippets.

View tarasowski's full-sized avatar
:electron:

Dimitri (Dimi) Tarasowski tarasowski

:electron:
View GitHub Profile
@KylePalko
KylePalko / lambda-api-gateway-cloudformation-example.yaml
Created September 12, 2017 15:41
An example CloudFormation Template for Lambda/API Gateway
Resources:
AccountsRestApi:
Type: "AWS::ApiGateway::RestApi"
Properties:
Name: "AccountsRestApi"
FailOnWarnings: "true"
AccountsResource:
Type: "AWS::ApiGateway::Resource"
Properties:
ParentId:
@tomodian
tomodian / firehose-to-athena.js
Created February 28, 2017 15:22
Firehose to Athena
'use strict';
const aws = require('aws-sdk');
const s3 = new aws.S3({ apiVersion: '2006-03-01' });
exports.handler = (event, context, callback) => {
const key = decodeURIComponent(event.Records[0].s3.object.key);
const meta = key.split('/');
@ericelliott
ericelliott / promise-chaining.js
Last active April 3, 2020 02:13
Promise chaining behaviors
const wait = time => new Promise(
res => setTimeout(() => res(), time)
);
wait(200)
// onFulfilled() can return a new promise, `x`
.then(() => new Promise(res => res('foo')))
// the next promise will assume the state of `x`
.then(a => a)
// Above we returned the unwrapped value of `x`
@kn9ts
kn9ts / aws4_signing.py
Last active March 4, 2023 06:19
AWS V4 signing example in python
# AWS Version 4 signing example
#
# Example:
# Authorization: AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7
# Formulae:
# CanonicalRequest =
# HTTPRequestMethod + '\n' +
# CanonicalURI + '\n' +
# CanonicalQueryString + '\n' +
@montanaflynn
montanaflynn / CONCURRENCY.md
Last active April 20, 2024 17:00
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

" Add this to your vimrc to get a minimalist autocomplete pop
" Or use as a plugin : https://github.com/maxboisvert/vim-simple-complete
" Minimalist-TabComplete-Plugin
inoremap <expr> <Tab> TabComplete()
fun! TabComplete()
if getline('.')[col('.') - 2] =~ '\K' || pumvisible()
return "\<C-P>"
else
@jesstelford
jesstelford / event-loop.md
Last active May 10, 2024 01:23
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

@mikepfeiffer
mikepfeiffer / gist:4d9386afdcceaf29493a
Created March 19, 2016 22:54
EC2 UserData script to install CodeDeploy agent
#!/bin/bash
yum install -y aws-cli
cd /home/ec2-user/
aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1
yum -y install codedeploy-agent.noarch.rpm
@subfuzion
subfuzion / curl.md
Last active May 31, 2024 09:45
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@treyhunner
treyhunner / time_dict_merge.py
Last active November 3, 2023 08:13
Test performance of different dictionary merging functions in Python
"""
Results:
multiple_update: 33 ms
copy_and_update: 27 ms
dict_constructor: 29 ms
kwargs_hack: 33 ms
dict_comprehension: 33 ms
concatenate_items: 81 ms
union_items: 81 ms