Skip to content

Instantly share code, notes, and snippets.

View orf's full-sized avatar

Tom Forbes orf

View GitHub Profile
@orf
orf / README.md
Last active November 18, 2020 19:54

Unfuck S3

Use this script if you've managed to make wide-scale modifications to lots of S3 objects and you need to roll them all back to their earliest versions.

Pray you never need this, but be thankful it's here if you do.

It finds all the versions of objects under a specific prefix and deletes all but the earliest one.

@orf
orf / mbox.py
Last active October 30, 2020 11:33
import mailbox
import pathlib
import email
import tqdm
output_mbox = mailbox.mbox(path="output.mbox")
files = list(pathlib.Path("django-developers/mbox/").iterdir())
for path in tqdm.tqdm(files):
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django.utils.autoreload': {

Keybase proof

I hereby claim:

  • I am orf on github.
  • I am orf (https://keybase.io/orf) on keybase.
  • I have a public key ASDhMngynt-WpbRYA3jmSLM-dlRS4_6Ha6IRFb4oBzWqAwo

To claim this, I am signing this object:

@orf
orf / travis-secure-redefine.py
Last active October 15, 2017 02:26 — forked from simon-weber/travis-secure-redefine.py
Python script to allow use of TravisCI secure arg variables that would normally be defined on each line of a build matrix, but are too large for the key size when combined.See https://github.com/travis-ci/travis-ci/issues/1736 for motivation. If you just need to secure a lot of sample data, do something like https://github.com/travis-ci/travis/i…
#!/usr/bin/env python
from __future__ import print_function
"""
./%s 'cmd' <id-argname> <redef-argname> [<redef-argname>...]
Given the current environment:
IDARG=1
FOO1=foovalue
BAR1=barvalue
FOO2=foo-unused
import Ember from 'ember';
import fetch from 'fetch';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
noDnsFailed: null,
noDnsFailedRealFetch: null,
SSLFailed: null,
SSLFailedRealFetch: null,
import Ember from 'ember';
export default Ember.Controller.extend({
options: ['testtesttesttesttesttesttesttesttesttesttesttest'],
selected: null
});
@orf
orf / test.py
Last active April 23, 2017 18:24
x = open('test.csv', 'w')
stream_labels = list(Stream.objects.order_by('label').values_list('label', flat=True))
x.write('Timestamp,' + ','.join(stream_labels) + '\n')
for timestamp in Data.objects.values_list('timestamp', flat=True):
data_values = Data.objects.filter(timestamp=timestamp, stream__label__in=stream_labels).order_by('stream__label).values_list('data', flat=True)
x.write(str(timestamp) + ',' + ','.join(data_values) + '\n')
@orf
orf / models.py
Last active April 26, 2016 15:46 — forked from malgorath/models.py
trying to get {{ t.start_stamp }} to display as a date, its saved as a Unix EPOC timestamp
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
from django.db import models
from datetime import datetime
@orf
orf / recurse.sql
Created September 20, 2015 20:59
WITH RECURSIVE recursetree(id, parent_id) AS (
SELECT id, parent_id FROM comments WHERE parent_id = post_id
UNION
SELECT t.id, t.parent_id
FROM comments t
JOIN recursetree rt ON rt.id = t.parent_id
)