Skip to content

Instantly share code, notes, and snippets.

@teebu
teebu / vigenere_cipher.py
Created March 8, 2020 05:28
Python class for vigenere cipher
"""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()

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@teebu
teebu / Output Android Icons.jsx
Created March 2, 2019 22:31 — forked from Gamezpedia/Output Android Icons.jsx
Photoshop script to output Android icons (with XXXHDPI, XXHDPI, XHDPI, HDPI, MDPI support)
// 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:
@teebu
teebu / removeblankpages.sh
Created August 2, 2018 02:41
Remove blank pages from PDF
#!/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 ]
@teebu
teebu / imagemagick.bash
Last active July 11, 2020 16:21 — forked from bensie/imagemagick.bash
ImageMagick Static Binaries for AWS Lambda ImageMagick-6.9.10-8 for AWS Lambda
#!/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
@teebu
teebu / delay.js
Created July 6, 2018 05:40 — forked from daliborgogic/delay.js
Node.js Async/Await delay
'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 () {
@teebu
teebu / remove_pdf_password.sh
Created January 12, 2018 21:52 — forked from pstaender/remove_pdf_password.sh
Remove password from protected PDF file with GhostScript
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf
@teebu
teebu / install_python_36_amazon_linux.sh
Created December 22, 2017 01:04 — forked from niranjv/install_python_36_amazon_linux.sh
Install Python 3.6 in Amazon Linux
# 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
@teebu
teebu / gist:4730a3faacbeac3235e2a5f76274d763
Created November 17, 2017 21:40
Setting up Sentry in travis.yml
Set env variables in travis.yml:
```
export SENTRY_AUTH_TOKEN=...
export SENTRY_ORG=organization-slug
```
update_sentry.sh:
```
@teebu
teebu / app.js
Created November 2, 2017 19:09
sample raven event logging
const async = require('async');
const download = require('download');
const fs = require('fs-extra');
const RavenLambdaWrapper = require('serverless-sentry-lib');
const Raven = require('raven')
// Wrap handler for automated error and exception logging
const ravenConfig = {
filterLocal: false,
captureErrors: true, // Don't log error responses from the Lambda ...