This file contains hidden or 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
| class FilterLowercase(BaseMongoEngineFilter): | |
| def apply(self, query, value): | |
| flt = {'%s__icontains' % self.column: value} | |
| return query.filter(**flt) | |
| def operation(self): | |
| return gettext('contains') | |
| class FilterLowercaseNot(BaseMongoEngineFilter): | |
| def apply(self, query, value): |
This file contains hidden or 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
| #!/usr/bin/env python | |
| def str_to_hex(string): | |
| return "-".join("{:02x}".format(ord(c)) for c in str(string)) | |
| def chunks(s, n): | |
| for start in range(0, len(s), n): | |
| yield s[start:start+n] | |
| delimiter = '%-12345X@PJL' |
This file contains hidden or 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
| ModelView | |
| --------- | |
| # field1 (->Model1), field2 (->Model2) filtered by field1 values | |
| column_filter_by = ('field2') | |
| form_widget_args = { | |
| 'field2': { | |
| 'data-filter-by': 'field1', | |
| } | |
| } |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| """ | |
| This is a 100% self-contained script to facilitate automated creation of bidirectional UDP pinholes. | |
| It should work as a non-root user assuming you use a high port number. | |
| All that is necessary is an SSH server with a Python environment. | |
| This script is ran on the client, and then the client runs it on the server dynamically. | |
| No permanent changes are made to the server. | |
| Basically we just open UDP connection from both ends, to the same port, and then exchange some tokens to verify connectivity. |
This file contains hidden or 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 eventlet.green import socket | |
| from helpers import dict_merge | |
| SOH = u'\u0001' | |
| ETX = u'\u0003' | |
| alarm_category_code_mapping = dict( | |
| name = 'alarm/warning category', | |
| len = 2, | |
| format = 'AA', |
This file contains hidden or 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
| """ | |
| We are trying to determine which offenses can be matched to a candidate. Candidates names' often do not match exactly to criminal records, but still represent the candidate. We are given a JSON file of possible criminal offenses and a candidate's aliases. We use a point system to judge how well a record matches to a candidate. | |
| The point system starts out at 100 (100% accurate) being an exact match. We can do 4 edit types to a record name to get to an exact match of one of the candidate's aliases. | |
| Edits: | |
| A middle name swapped with a first name subtracts 7 points | |
| A first name nickname swap subtracts 5 points | |
| A middle name nickname swap subtracts 3 points |
This file contains hidden or 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
| #!/usr/bin/env python | |
| import itertools | |
| import unittest | |
| def primeGenerator(): | |
| """ | |
| Yields an array of primes. | |
| """ |
This file contains hidden or 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
| #!/usr/bin/env python | |
| import unittest | |
| from sympy import sieve | |
| import numpy as np | |
| def generatePrimes(num_primes): | |
| """ | |
| Returns an array of primes. |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import unittest | |
| def flattenIntArray(arr): | |
| '''Yield flattened elements from input array''' | |
| for element in arr: | |
| try: | |
| yield from flattenIntArray(element) |
This file contains hidden or 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
| -- When using aws_s3.query_export_to_s3, on Aurora Postgres, version 11, data is reliably and predictably corrupted at certain positions of the payloads that land in s3. | |
| -- It seems that when data falls over a certain byte length, it is reset and resent mid-stream to s3. | |
| -- We have been able to reproduce this positively, as well as reproduce a negative as well; ensuring that data falls at powers of 2 on even byte lengths seems to prevent this issue from occurring. | |
| -- As the length of data increases, as does the frequency of the corruption. For small data sets, it may never surface. | |
| -- You will see upon running this SQL that it occurs once in 100,000 records with 128+9 byte length records, twice for 256+9, and 4 times for 512+9, and so-on, where each record looks like {"A":""}\n where \n is a new line control character, amounting to 9 extra bytes on top of the value in the JSON objects. | |
| -- these queries will result in broken json in s3 | |
| select * from aws_s3.query_export_to_s3( | |
| 'select row_to_json(test) fr |
OlderNewer