Skip to content

Instantly share code, notes, and snippets.

View bgener's full-sized avatar

Borys Generalov bgener

View GitHub Profile
@eddywashere
eddywashere / cloudwatchlogs.js
Created May 1, 2017 17:03
get cloudwatch logs
const _ = require('lodash');
const AWS = require('aws-sdk');
const retry = require('bluebird-retry');
function recursiveReq(request, params, key, items = [], count = 0) {
return request(params).then(data => {
const newItems = items.concat(data[key]);
const lastItem = _.last(newItems);
const nextToken = _.get(data, 'nextToken', null);
@ravikiranj
ravikiranj / postman-hmac-sha512-preq-request.js
Created April 27, 2017 18:05
HMAC SHA512 Authentication Pre-request script for Postman
/* Pre-requisite
==================
1) Create an Environment (if you don't already have on) and enable it for your request
2) Add a new Header with key as "Authorization" and value as "{{hmacAuthHeader}}"
3) Add the following Pre-request Script that computes the hmacAuthHeader variable and adds it to the environment
4) Fill your CLIENT_KEY and SECRET_KEY with valid values
*/
function getPath(url) {
var pathRegex = /.+?\:\/\/.+?(\/.+?)(?:#|\?|$)/;
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation sample template that contains a single Lambda function behind an API Gateway",
"Resources": {
"GreetingLambda": {
"Type": "AWS::Lambda::Function",
"Properties": {
@thornbill
thornbill / .gitlab-ci.yml
Created November 22, 2016 21:29
Example Node GitLab CI Yamlfile
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:6
before_script:
- npm install
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@justinsoliz
justinsoliz / resources.tf
Created August 30, 2016 15:26
Terraform S3 to Lambda notification
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "aws_iam_role" "iam_for_terraform_lambda" {
name = "app_${var.app_env}_lambda"
assume_role_policy = <<EOF
{
@tugberkugurlu
tugberkugurlu / run-tests.ps1
Created August 8, 2016 15:25
Run Mocha PowerShell
$mochaPath = Resolve-Path (Join-Path $PSScriptRoot "..\node_modules\.bin\_mocha.cmd")
$setupPath = Resolve-Path (Join-Path $PSScriptRoot "..\test\setup.js")
$testFiles = Join-Path $PSScriptRoot "..\src\**\*.test.js"
& $mochaPath "$testFiles" --require "$setupPath" --compilers js:babel-register --debug-brk
@hassy
hassy / my-test.yml
Created March 31, 2016 20:17
Example of using processors in Artillery
config:
target: "http://localhost:8080"
phases:
- duration: 60
arrivalRate: 1
processor: "./processor.js"
scenarios:
- name: "Load the options page"
flow:
- get:
@BeanCounterTop
BeanCounterTop / SQSQueueExample.ps1
Created March 3, 2016 01:18
An example for how to use AWS SQS queues in Powershell
$QueueName = "myQueue"
$TopicName = "myTopic"
$Region = "us-west-2"
$SNSUserAccountID = (Get-EC2SecurityGroup -GroupNames "default")[0].OwnerId
$QueueURL = New-SQSQueue -QueueName $QueueName -Region $Region
$QueueARN = (Get-SQSQueueAttribute -QueueUrl $QueueURL -AttributeName QueueArn).Attributes['QueueArn']
$TopicARN = New-SNSTopic -Name $TopicName -Region $Region
$Sid = "Sid" + (Get-Random)
@vasanthk
vasanthk / System Design.md
Last active July 25, 2024 17:47
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?