$ brew install gnupg
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 django.db.models import OuterRef | |
weapons = Weapon.objects.filter(unit__player_id=OuterRef('id')) | |
units = Unit.objects.filter(player_id=OuterRef('id')) | |
qs = Player.objects.annotate(weapon_count=SubqueryCount(weapons), | |
rarity_sum=SubquerySum(units, 'rarity')) |
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
cd /path/to/files && | |
for file in *.mp3 *.mp4; do | |
if [[ -f "$file" ]]; then | |
if [[ -f "${file}.md5" ]]; then | |
echo "already exists: ${file}.md5" | |
else | |
md5sum -- "$file" > "${file}.md5"; | |
cat "${file}.md5"; | |
fi | |
fi |
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
# So... I took that as a challenge and displayed all dates that sums 68 from 1900 to 2088 (when I'm going to make 100 years). | |
# Be safe and avoid those dates. =P | |
from datetime import date | |
from datetime import timedelta | |
def sum_date(date): | |
date_str = date.strftime('%d %m %Y') | |
date_str = date_str[:8] + ' ' + date_str[8:] | |
return sum(map(int, date_str.split())) |
As an introduction into Luigi, I am following this tutorial with some modifications, e.g. installation using conda.
The problems and solutions described in the examples below have led to the development of sciluigi,
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 sqlalchemy import create_engine | |
from sqlalchemy.orm import Session | |
from myapp.models import BaseModel | |
import pytest | |
@pytest.fixture(scope="session") | |
def engine(): | |
return create_engine("postgresql://localhost/test_database") |
bin/kafka-topics.sh --zookeeper localhost:2181 --list
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000
... wait a minute ...
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
function count_emails() { | |
var max = 500; | |
var offset = 0; | |
var emails = []; | |
while (true) { | |
var threads = GmailApp.search("in:anywhere", offset, max); | |
emails = searchThreads.concat(threads); | |
if (threads.length < max) { |
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
var ui = SpreadsheetApp.getUi(); | |
function onOpen(e){ | |
ui.createMenu("Gmail Manager").addItem("Get Emails by Label", "getGmailEmails").addToUi(); | |
} | |
function getGmailEmails(){ | |
var input = ui.prompt('Label Name', 'Enter the label name that is assigned to your emails:', Browser.Buttons.OK_CANCEL); | |
NewerOlder