Skip to content

Instantly share code, notes, and snippets.

TASK [dev_server : plenv rehash] ***********************************************
changed: [t1-perl-dev]
TASK [dev_server : set default perl version] ***********************************
ok: [t1-perl-dev]
TASK [dev_server : perl Makefile.PL] *******************************************
changed: [t1-perl-dev]
TASK [dev_server : install shared library dependencies] ************************
# Using database adama_test_20252_1633
Updating template database...
No patches to apply.
Database upgrade successful.
not ok 1 - t21_dsp_permissions_matrix died (insert() - DBD::Pg::st execute failed: ERROR: null value in column "first_name" violates not-null constraint
# DETAIL: Failing row contains (3, 0, t, null, null, null, null, f, null, null, null, null, null, null, null, null, null, null, null, f, f, f, null, 2017-01-31 20:29:36.036922+00, 2017-01-31 20:29:36.036922+00, f, null, f, f, f, f, f, f, f). at /home/dev/src/adama/t/lib/Adama/Test/DB/WithTestObject.pm line 47.
# at /home/dev/src/adama/t/lib/Adama/Test/Advertisers.pm line 553.)
# Failed test 't21_dsp_permissions_matrix died (insert() - DBD::Pg::st execute failed: ERROR: null value in column "first_name" violates not-null constraint
# DETAIL: Failing row contains (3, 0, t, null, null, null, null, f, null, null, null, null, null, null, null, null, null, null, null, f, f, f, null, 2017-01-31 20:29:36.036922+00, 2017-01-31 20:29:36.036922+0
my $user = Adama::DB::Object::User->get_test_object(
username => $username,
password => $password,
type => 'INTERNAL',
role => 'ADMIN',
scope => 'GLOBAL',
);
# ... declare a bunch of scenarios ...
@pytest.fixture()
def unique_parameterized_campaign(request):
def make_campaign(start_date=None, end_date=None):
campaign_parameters = {
'name': 'campaign foo',
'goal_type': 'spend',
'goal_value': 1.00,
'start_date': start_date,
'end_date': end_date,
}
# Reservation grant
# Used to keep track of the status of a given message
reservation_grant = [
"unprocessed",
"reserved-{timestamp}-{process_id}-{thread_id}", # used by a worker to acquire messages for itself
"processed",
]
# Batch ids
# can be used for creating a digest of the same notification type recorded over a time interval
{
'matched_fields': {
'field_1': {
'field_value': 'foobar baz',
'matches': [
{'matched_value': 'foo', 'match_offsets': [(0, 3)]},
{'matched_value': 'bar', 'match_offsets': [(3, 6)]},
{'matched_value': 'ba', 'match_offsets': [(3, 5), (7,9)]},
]
},
def integer_to_bit_string(integer):
return bin(integer)[2:]
def pad_bit_strings(bit_string_1, bit_string_2):
difference = len(bit_string_1) - len(bit_string_2)
if difference < 0:
bit_string_1 = '0' * abs(difference) + bit_string_1
else:
bit_string_2 = '0' * abs(difference) + bit_string_2
return (bit_string_1, bit_string_2)
@philangist
philangist / send_gmail.py
Last active August 29, 2015 14:16
Send email as a gmail user
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
def send(recipient, subject, msg):
return GmailHandler().send(recipient)
@philangist
philangist / delete_stale_branches.sh
Last active August 29, 2015 14:13
Easily delete local and remote references to multiple git branches
#!/bin/sh
function usage
{
echo "usage: ./delete_stale_branches.sh [--help] [--branches [<branch_names>]]"
}
function delete_branch
{
branch_name=$1
@philangist
philangist / permutations_of_sum.py
Created November 10, 2014 16:46
Find all permutations of a list of integers that add up to another integer
def find_two_tuple_permutations(n, k):
n = set(n)
valid_pairs = []
for i in n:
delta = k - i
if delta in n:
valid_pairs.append((i, delta))
return valid_pairs