Skip to content

Instantly share code, notes, and snippets.

View Geekfish's full-sized avatar
🐝
... 🐝 ... 🐝 ... 🐝 ... 🐝

Eleni Lixourioti Geekfish

🐝
... 🐝 ... 🐝 ... 🐝 ... 🐝
View GitHub Profile
@Geekfish
Geekfish / handler.py
Last active January 7, 2019 14:30
DjangoRQ Transaction aware job decorator
from jobs import send_welcome_email
# ...
def register_user():
user = do_the_registration()
send_welcome_email.transaction_aware_delay(user.id)
# or
# send_welcome_email.request_aware_delay(user.id)
@Geekfish
Geekfish / tasks.py
Created October 31, 2017 15:20
Transaction Aware Celery Task - SQLAlchemy
# Based on Django version found here:
# https://gist.github.com/tapanpandita/a84938354d32b0f12423d69259e06c2c
from celery import Task
from sqlalchemy import event
from some_module import DBSession
class TransactionAwareTask(Task):
"""
@Geekfish
Geekfish / Contract Killer 3.md
Created July 12, 2017 15:54 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

Tiny Content Framework

About the project

This is a tiny content strategy framework focused on goals, messages, and branding. This is not a checklist. Use what you need and scrap the rest. Rewrite it or add to it. These topics should help you get to the bottom of things with clients and other people you work with.

Give me feedback on Twitter (@nicoleslaw) or by email (nicole@nicolefenton.com).

Contents

@Geekfish
Geekfish / merge_pdfs.py
Created January 31, 2017 16:07
pyPDF2 merge 2 pdf pages into one
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.pdf import PageObject
reader = PdfFileReader(open("invoice.pdf",'rb'))
invoice_page = reader.getPage(0)
sup_reader = PdfFileReader(open("supplement.pdf",'rb'))
sup_page = sup_reader.getPage(1) # We pick the second page here
translated_page = PageObject.createBlankPage(None, sup_page.mediaBox.getWidth(), sup_page.mediaBox.getHeight())
@Geekfish
Geekfish / translation_utils.py
Last active October 21, 2016 11:11
Django Lazy translation format
from django.utils.functional import allow_lazy
def _lazy_format(lazy_text, format_params):
return lazy_text % format_params
lazy_format = allow_lazy(_lazy_format, unicode)
@Geekfish
Geekfish / pre-commit.py
Last active September 21, 2016 13:53
Pre-commit hook with flake8 and auto-named migrations
#!/usr/bin/env python
import sys, subprocess, collections
from flake8.hooks import git_hook, get_git_param
# `get_git_param` will retrieve configuration from your local git config and
# then fall back to using the environment variables that the hook has always
# supported.
# For example, to set the complexity, you'll need to do:
# git config flake8.complexity 10
COMPLEXITY = get_git_param('FLAKE8_COMPLEXITY', 10)
@Geekfish
Geekfish / bookmarklets.js
Last active September 26, 2016 13:22
Trello Card bookmarklets
// Get Card's last URL segment (eg 4468-fix-the-login-page):
javascript:(function(s){try{s=document.selection.createRange().text}catch(_){s=document.getSelection()}prompt('', window.location.href.split("/").pop().split("#")[0])})()
// Get Card's full hash (eg 5731b92ef660293533517de9) :
javascript:(function(s){try{s=document.selection.createRange().text}catch(_){s=document.getSelection()}$('.js-more-menu').click(); prompt('', $('.js-export-json').attr('href').split("/")[2]); $('.js-more-menu').click();})()
// Get Card's unique id (board-independent, eg rKBmQeOk) :
javascript:(function(s){try{s=document.selection.createRange().text}catch(_){s=document.getSelection()}$('.js-more-menu').click(); prompt('', $('.js-short-url').attr('value').split("/").slice(-1)[0]); $('.js-more-menu').click();})()
@Geekfish
Geekfish / pycharm_scopes.md
Created April 21, 2016 10:50
PyCharm Scopes

If you want to include/exclude directories from your search only (not the project), you can add a Custom Scope. This can be found in Preferences -> Appearance & Behavior -> Scopes.

For example, a scope that excludes migrations:

!file[*]:*/migrations/*

And the reverse scope that will only include migrations:

@Geekfish
Geekfish / hipchat_room_message.sh
Created December 8, 2015 17:36
Hipchat - Send message to room
#!/bin/bash
###############################################################################
#
# ./hipchat_room_message
#
# A script for sending a system message to a room.
#
# Docs: http://github.com/hipchat/hipchat-cli
#