This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Must be run on an Amazon Linux AMI that matches AWS Lambda's runtime | |
# As of Nov 23, 2015, this is Amazon Linux AMI 2014.09.2 x86_64 (ami-0c682c64) | |
# | |
# Lambda includes ImageMagick 6.7.8-9 preinstalled, so you need to prepend PATH | |
# with the folder containing these binaries in your Lambda function to ensure | |
# these newer binaries are used. | |
# | |
# imagemagick binary will be in /var/task/imagemagick/bin/convert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# varnish 4.1 | |
sudo yum -y install autoconf automake jemalloc-devel libedit-devel libtool ncurses-devel pcre-devel pkgconfig python-docutils python-sphinx graphviz | |
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish41/script.rpm.sh | sudo bash | |
wget --content-disposition https://packagecloud.io/varnishcache/varnish41/packages/el/6/varnish-4.1.10-1.el6.x86_64.rpm/download.rpm | |
sudo rpm -Uvh varnish-4.1.10-1.el6.x86_64.rpm | |
/usr/sbin/varnishd -V | |
# varnish 4 | |
sudo yum -y install autoconf automake jemalloc-devel libedit-devel libtool ncurses-devel pcre-devel pkgconfig python-docutils python-sphinx graphviz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def col_print(title, array, term_width=150, pad_size=1): | |
indent = " " * 4 | |
pad = " " * pad_size | |
title += "\n" | |
if not array: | |
return title + indent + "<None>" | |
array = list(map(str, array)) # make every element a string | |
max_item_width = max(map(len, array)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Vigenere cipher""" | |
import string | |
from collections import defaultdict | |
from pprint import pprint | |
class Vigenere(): | |
"""Vigenere class""" | |
def __init__(self, key, message=''): | |
self._MATRIX = self._build_matrix() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Output Android Icons.jsx | |
// 2012 Todd Linkner | |
// License: none (public domain) | |
// v1.0 - base file by Todd Linkner | |
// v1.1 - added support for XXHDPI, XXXHDPI and added PNG to the file selector | |
// | |
// This script is for Photoshop CS6. It outputs Android icons of the | |
// following sizes from a source PSD at least 512px x 512px | |
// | |
// store: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter { | |
grok { | |
match => [ | |
"message", "%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day}[\t]%{TIME:time}[\t](?<x_edge_location>\b[\w\-]+\b)[\t](?:%{NUMBER:sc_bytes}|-)[\t]%{IPORHOST:clientip}[\t]%{WORD:cs_method}[\t]%{HOSTNAME:cs_host}[\t]%{NOTSPACE:cs_uri_stem}[\t]%{NUMBER:sc_status}[\t]%{GREEDYDATA:referrer}[\t]%{GREEDYDATA:agent}[\t]%{GREEDYDATA:cs_uri_query}[\t]%{GREEDYDATA:cookies}[\t]%{WORD:x_edge_result_type}[\t]%{NOTSPACE:x_edge_request_id}[\t]%{HOSTNAME:x_host_header}[\t]%{GREEDYDATA:cs_protocol}[\t]%{INT:cs_bytes}[\t]%{GREEDYDATA:time_taken}[\t]%{GREEDYDATA:x_forwarded_for}[\t]%{GREEDYDATA:ssl_protocol}[\t]%{GREEDYDATA:ssl_cipher}[\t]%{GREEDYDATA:x_edge_response_result_type}[\t]%{GREEDYDATA:cs_protocol_version}" | |
] | |
} | |
geoip { | |
source => "c_ip" | |
} | |
mutate { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IN="$1" | |
OUT="$2" | |
PAGES=$(pdfinfo $IN | grep ^Pages: | tr -dc '0-9') | |
non_blank() { | |
for i in $(seq 1 $PAGES) | |
do | |
# more color spectrum | |
#convert -density 46 "$IN[$((i-1))]" -define histogram:unique-colors=true -format %c histogram:info:- | wc -l | |
if [ $(convert -density 16 "$IN[$((i-1))]" +dither -colors 8 -depth 4 -define histogram:unique-colors=true -format %c histogram:info:- | wc -l) -ne 1 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const timeout = ms => new Promise(res => setTimeout(res, ms)) | |
function convinceMe (convince) { | |
let unixTime = Math.round(+new Date() / 1000) | |
console.log(`Delay ${convince} at ${unixTime}`) | |
} | |
async function delay () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A virtualenv running Python3.6 on Amazon Linux/EC2 (approximately) simulates the Python 3.6 Docker container used by Lambda | |
# and can be used for developing/testing Python 3.6 Lambda functions | |
# This script installs Python 3.6 on an EC2 instance running Amazon Linux and creates a virtualenv running this version of Python | |
# This is required because Amazon Linux does not come with Python 3.6 pre-installed | |
# and several packages available in Amazon Linux are not available in the Lambda Python 3.6 runtime | |
# The script has been tested successfully on a t2.micro EC2 instance (Root device type: ebs; Virtualization type: hvm) | |
# running Amazon Linux AMI 2017.03.0 (HVM), SSD Volume Type - ami-c58c1dd3 | |
# and was developed with the help of AWS Support |