Skip to content

Instantly share code, notes, and snippets.

@lrakai
lrakai / lambda-aws-ssm-run-command-on-ec2-instance.py
Last active January 9, 2024 16:29
Run commands on EC2 instances using Lambda and Systems Manager (SendCommand)
import boto3
import botocore
import time
def handler(event=None, context=None):
client = boto3.client('ssm')
instance_id = 'i-07362a00952fca213' # hard-code for example
response = client.send_command(
@jwieringa
jwieringa / aws_inspector.md
Last active November 15, 2019 07:09
Exploring running AWS Inspector on CoreOS Container Linux

AWS Inspector Support in a Containerized environment

Summary

  • If behavioral analysis is required, then the kernel module is required
  • The inspector agent cannot be compiled for container linux because the source code is not open
  • The inspector agent is dynamically linked and therefore must be run on a supported filesystem/OS
  • Therefore, the inspector agent must be run inside of a container
  • Once the inspector agent in the container needs to have the correct mounts and capabilites to scan the host systems
@markerikson
markerikson / ampersand-shims.js
Created December 12, 2017 16:10
Backbone / Ampersand compatibility shims
// Ampersand-State doesn't mix in Underscore methods the way Backbone.Model does.
// Technically it could also be done as a standalone mixin, but we'll do that here.
var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit'];
// Mix in each Underscore method as a proxy to `Model#attributes`.
_.each(modelMethods, function(method) {
State.prototype[method] = function() {
var args = [].slice.call(arguments);
args.unshift(this.attributes);
@markerikson
markerikson / usage.js
Last active January 30, 2020 00:48
Backbone/React Interop
import {viewFromComponent} from "viewUtilities";
class MyListComponent extends React.Component {
render() {
// serialized Backbone collection
const {items = [] } this.props;
// do stuff with items
}
}
import pytesseract
import sys
import argparse
try:
import Image
except ImportError:
from PIL import Image
from subprocess import check_output
@alexkrolick
alexkrolick / webpack.config.js
Last active July 13, 2017 04:11
Webpack Config for Webpack-Rails + CDN for production (Webpack 1.x - some minor differences may be encountered for Webpack 2+)
const CDN = process.env['CDN_HOST'] || '';
/**
* Webpack configuration for integrating Webpack with Rails via the webpack-rails gem
* (https://github.com/mipearson/webpack-rails)
*
* Cache-Busting Strategy:
* Development: Change query string of resource when content MD5 hash changes,
* rewriting the asset in place but triggering rewrite of the manifest.
* Production: Use MD5 hash of asset as filename, writing new assets and manifest
@joepie91
joepie91 / sessions.md
Last active October 9, 2024 15:34
Introduction to sessions

While a lot of Node.js guides recommend using JWT as an alternative to session cookies (sometimes even mistakenly calling it "more secure than cookies"), this is a terrible idea. JWTs are absolutely not a secure way to deal with user authentication/sessions, and this article goes into more detail about that.

Secure user authentication requires the use of session cookies.

Cookies are small key/value pairs that are usually sent by a server, and stored on the client (often a browser). The client then sends this key/value pair back with every request, in a HTTP header. This way, unique clients can be identified between requests, and client-side settings can be stored and used by the server.

Session cookies are cookies containing a unique session ID that is generated by the server. This session ID is used by the server to identify the client whenever it makes a request, and to associate session data with that request.

*S

@Pierstoval
Pierstoval / pre-receive.bash
Last active September 9, 2021 07:46
Git pre-receive example to use a bare repo to deploy an ap
#!/bin/bash
########################################################################
################################ README ################################
########################################################################
#
# This script is here to allow the use of "git push prod v1.2.3" commands or similar.
#
# Push a tag to a bare repository having this file as pre-receive hook,
# and you'll be able to deploy directly from command line in your local environment,
// simpler, faster, version that will throw a TypeError if the path is invalid
// by yorick
function extract(obj, key){
return key.split('.').reduce(function(p, c) {return p[c]}, obj)
}
extract
// for example: