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
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()) |
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
import imp | |
from functools import partial | |
from mock.mock import _patch, _get_target, DEFAULT | |
class PatchWithReload(_patch): | |
def __init__(self, module_to_reload, *args, **kwargs): | |
self.module_to_reload = module_to_reload | |
super(PatchWithReload, self).__init__(*args, **kwargs) |
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
<p></p><script src="https://www.bookingmood.com/js/embed.js"></script> | |
<div data-bm="calendar/<REPLACE-WITH-CALENDAR-ID>" data-bm-layout="popup" data-bm-label="Έλεγχος διαθεσιμότητας" data-bm-background-color="#2563eb" data-bm-color="#fff" data-bm-width="#50" class="wp-bookingmood-widget"></div> |
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
defmodule ExMachina.Sequence.Formatters do | |
@moduledoc false | |
@latin_letters 26 | |
@codepoint_start 65 | |
@spec to_alpha_code(integer(), integer()) :: String.t() | |
@doc """ | |
Converts an integer (like a sequence counter) to an n-letter uppercase code. | |
Examples: |
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
javascript:(function(){document.getElementsByClassName("graph-outline-icon icon")[0].parentElement.parentElement.parentElement.click(); Array.from(document.getElementsByTagName("button")).forEach(function(button) {if(button.innerText == "Retire Review") { button.click();}});})(); |
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
""" | |
This is to allow grabing a random set of rows, | |
in a repeatable way (for example, if you need to ensure that | |
a user always sees the same "random" set of results). | |
Method one sets the seed in Postgres. | |
It's using order by RANDOM(), so it can be extremely slow | |
for large querysets. | |
Method two is significantly faster, as we are generating |
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
/** | |
* This bookmarklet makes it possible to transfer words from Leo Trainer to Anki. | |
* It only works for fr-de translations. Contact me for other languages. | |
* | |
* Prerequisites: | |
* - a Leo account (http://www.leo.org/) with a few words saved in the trainer | |
* - an Anki account (https://ankiweb.net/account/register) | |
* | |
* 1. Crunch the following code and add it to your bookmarks http://ted.mielczarek.org/code/mozilla/bookmarklet.html | |
* 2. Run the bookmarklet on this page https://dict.leo.org/trainer/manageFolder.php?lp=frde&lang=de |
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
$ python3 | |
Python 3.7.0 (default, Jul 23 2018, 20:24:19) | |
[Clang 9.0.0 (clang-900.0.39.2)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> class C(): | |
... def __init__(self, i): | |
... print(f"contructing {i}") | |
... self.i = i | |
... def __del__(self): | |
... print(f"deleting {self.i}") |
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
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) | |
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
docker ps -q | xargs -I '{}' docker inspect {} | jq '.[] | {container_id: .Id, image: .Config.Image, mounts: .Mounts}' |
NewerOlder