Skip to content

Instantly share code, notes, and snippets.

@codepreneur
codepreneur / lifecycle-cheat-sheet.md
Created August 24, 2017 15:00 — forked from HyperBrain/lifecycle-cheat-sheet.md
Serverless Lifecycle Cheat Sheet

Serverless plugin author's cheat sheet

This cheat sheet provides a detailed overview of the exposed lifecycle events and available commands (and entrypoints) of the Serverless framework, that can be hooked by plugins (internal and external ones). The document is structured by the commands invoked by the user.

Lifecycle events are shown as the globally available outer events (all providers) and sub lifecycle events that are provider specific in the called order. Currently only the AWS provider is shown. If you have information about the other provider,

@codepreneur
codepreneur / indexAccountsToCloudsearch.js
Created August 1, 2016 22:56 — forked from ryanfitz/indexAccountsToCloudsearch.js
index dynamodb data to cloudsearch using AWS Lambda
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
var cloudsearchdomain = new AWS.CloudSearchDomain({endpoint: 'doc-dev-cinch-accounts-ltmqj5gt5mjb5hg5eyqaf2v5hu.us-east-1.cloudsearch.amazonaws.com'});
var documents = event.Records.map(function(record) {
var data = {id : record.dynamodb.Keys.id.S};
if (record.eventName === 'REMOVE') {
data.type = 'delete'
@codepreneur
codepreneur / serverless.env.yaml
Created July 3, 2016 23:25
serverless framework/cli env variables file
vars: null
stages:
dev:
vars: null
regions:
us-west-2:
vars:
service: sadiavasio
stage: dev
iamRoleArnLambda: [gets generated and added here when you run sls deploy]
@codepreneur
codepreneur / serverless.yaml
Last active October 24, 2016 08:54
serverless framework/cli configuration file
service: "sadiavasio"
provider: "aws"
functions:
sadiavas:
handler: "index.graphql"
include:
- blog/
events:
- http:
path: "blog/graphql"
@codepreneur
codepreneur / lambda-not-anon.js
Last active September 14, 2015 07:38
The distinction between anonymous functions and lambdas in JavaScript.
// TL;DR - Lambda means "function used as data".
// Anonymous function means "function without a name".
// This is one of the relatively few cases where the Wikipedia definition of
// a word, while not entirely wrong, is misleading. Lambdas and anonymous
// functions are distinct ideas.
// These ideas are commonly confused because in many programming languages
// all lambdas are anonymous or vise verse.
// PhantomJS Cheatsheet
$ brew update && brew install phantomjs // install PhantomJS with brew
phantom.exit();
var page = require('webpage').create();
page.open('http://example.com', function() {});
page.evaluate(function() { return document.title; });
@codepreneur
codepreneur / tinder-api-documentation.md
Last active August 29, 2015 14:27 — forked from rtt/tinder-api-documentation.md
Tinder API Documentation

Tinder API documentation

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

Note: this was written in April/May 2014 and the API may have changed since

API Details

// iMacro CheatSheet - Command Reference
// http://wiki.imacros.net/Command_Reference
// iMacros supports 3 types of variables:
// * The macro variables !VAR0 thru !VAR9. They can be used with the SET and ADD command inside a macro.
// * Built-in variables. They contain certain values set by iMacros.
// * User-defined variables. They are defined in-macro using the SET command.
// iMacros Bootstrap - Write your macros with JavaScript.
// Be careful, you need to rename and set the extension of your macro to ".js".
// 1. Variables Initialization.
var variable1, variable2, variable3;
macro = "";

Keybase proof

I hereby claim:

  • I am codepreneur on github.
  • I am codepreneur (https://keybase.io/codepreneur) on keybase.
  • I have a public key whose fingerprint is CF38 14A0 E78A AA1A 0C2D C2D0 FE63 3A62 FDC2 30A2

To claim this, I am signing this object: