Skip to content

Instantly share code, notes, and snippets.

View ajokela's full-sized avatar

A.C. Jokela ajokela

View GitHub Profile
@jolexa
jolexa / invalidate-all.py
Created October 24, 2018 14:07
Invalidate CloudFront Cache with boto3
from time import time
import sys
import boto3
client = boto3.client('cloudfront')
# Uncomment this to pass a URL to the script
#def get_id(url):
# print("get_id args: {0}".format(url))
# # url: asdf.cloudfront.net
# # return: E2134123ASDF
@evz
evz / README.md
Created October 7, 2012 21:43
S3 Publisher for Hyde (static site generator written in Python)

How to use

  • Add the s3.py file to your project. As an example, put it inside a folder called publishers.
  • The folder where s3.py resides must be a Python package, so add an empty __init__.py file to that folder also.
  • Add the following configuration to your site.yaml and modify it as needed:
publisher:
    s3:
 type: publishers.s3.S3 # here, publishers is the folder where the s3.py file was placed
@ajokela
ajokela / gist:1845100
Created February 16, 2012 14:08
Split a large file with tar
Splitting the File
The two extra command line options you need to use over and above the standard syntax are -M (--multi-volume) which tells Tar you want to split the file over multiple media disks. You then need to tell Tar how big that media is, so that it can create files of the correct size. To do this you use the --tape-length option, where the value you pass is number x 1024 bytes.
The example below shows the syntax used. Lets say the largefile.tgz is 150 Meg and we need to fit the file on two 100 Meg Zip drives.
tar -c -M --tape-length=102400 --file=disk1.tar largefile.tgz
The value 102400 is 1024 x 100, which will create a 100 Meg file called disk1.tar and then Tar will prompt for volume 2 like below :-
Prepare volume #2 for disk1.tar and hit return:
@ajokela
ajokela / imgscalr.rb
Created October 7, 2011 19:40 — forked from mchung/imgscalr.rb
imgscalr in jruby
require "imgscalr-lib" # https://github.com/thebuzzmedia/imgscalr
require "jruby"
java_import "javax.imageio.ImageIO"
ImageIO.write(
com.thebuzzmedia.imgscalr.Scalr.resize(
ImageIO.read(java.io.File.new("iss.jpg")),
250),
"jpg",
java.io.File.new("iss_new.jpg"))