Skip to content

Instantly share code, notes, and snippets.

# OK
Note the 'MM' parameter to date_trunc
In [65]: qry ="""
SELECT
trunc(employees.hire_date, 'MM') AS "employees.hire_date_monthly",
coalesce(sum(employees.salary), 0) AS "employees.salary_sum"
FROM
employees JOIN departments ON employees.department_id = departments.department_id
obfuscated = map( lambda x: int(x, 16), "65 65 65 41 03 11 1c 15".split(" "))
original = map( lambda x: int(x, 16), "00 00 00 24 66 74 79 70".split(" "))
print obfuscated
# [101, 101, 101, 65, 3, 17, 28, 21]
print original
# [0, 0, 0, 36, 102, 116, 121, 112]
# Every place we have a 0 in the original, the obfuscated file has 101. Sounds suspicious... ;)
def deobs_pluralsight(fpath, target_dir):
fname = os.path.basename(fpath)
target_fname = fname.replace('psv', 'mp4')
target_file_path = os.path.join(target_dir, target_fname)
with open(target_file_path, "wb") as ofh:
for byte in bytearray(open(fpath, "rb").read()):
ofh.write(chr(byte ^ 101))
@labeneator
labeneator / postgres_app_madlib
Created July 3, 2018 16:19
Install madlib into Postgres.app on OS
❯ PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.6/bin/ [19:16:16]
# add languages to postgres
❯ psql
CREATE EXTENSION plpythonu;
❯ /usr/local/madlib/bin/madpack -s madlib -p postgres -c postgres@localhost:5432/pypos install -v [19:16:19]
madpack.py: INFO : Arguments: Namespace(command=['install'], connstr=['postgres@localhost:5432/pypos'], keeplogs=False, platform=['postgres'], schema=['madlib'], testcase='', tmpdir='/tmp/', verbose=True)
madpack.py: INFO : Testing database connection...
@labeneator
labeneator / postgres_app_madlib
Created July 3, 2018 16:20
Install madlib into Postgres.app on OS
# Download and install the dmg for postgres.app
# Download the madlib dmg and install it
# Change your version appropriately
❯ PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.6/bin/ [19:16:16]
# add languages to postgres
❯ psql
CREATE EXTENSION plpythonu;
@labeneator
labeneator / etc_cron.d_ubnt_metrics
Created September 18, 2018 08:11
Simple Cron invoked job to send metrics from airmax devices to Carbon-cache (Graphite).
* * * * * root /usr/local/bin/send_metrics.sh
@labeneator
labeneator / _etc_cron.d_apc_metrics
Created January 2, 2019 12:48
Sends APC UPS metrics to graphite by running apcaccess cmd on Linux.
* * * * * root python /usr/local/bin/send_apc_metrics.py --carbon-host metrics.yourcompany.co.ke 2>&1 | logger -t "apc_metrics"
@labeneator
labeneator / etc_cron.d_ubnt_metrics
Last active August 28, 2021 17:40
Script to send SNMP metrics from Ubiquiti devices to graphite.
* * * * * root /usr/local/bin/send_metrics.sh
@labeneator
labeneator / auto_type_kra.au3
Last active July 19, 2019 11:57
Save a csv somewhere in your windows. Download and install autoit, open the scite editor and paste the *auto_type_kra.au3* file below into it. Make sure your csv is store as c:\kra_vat.csv, click run and switch to the excel program
#include <File.au3>
WinWaitActive("Microsoft Excel (Product Activation Failed)")
$file = "c:\kra_vat.csv"
FileOpen($file, 0)
@labeneator
labeneator / README.md
Created April 15, 2021 12:54 — forked from magnetikonline/README.md
BIND - delegate a sub domain for a zone.

BIND - delegate a sub domain for a zone

The scenario:

  • DNS zone myzone.com defined in BIND.
  • Authoritative name server at 123.16.123.1.
  • Subzone sub.myzone.com with an authoritative name server at 123.16.123.10.
  • Wishing to forward sub-zone to authoritative name server.

Config

$ORIGIN myzone.com.