Skip to content

Instantly share code, notes, and snippets.

Daniel Hnyk hnykda

View GitHub Profile
View gist:7b2a2828bf03b40eda66a9c09841969f
apiVersion: batch/v1
kind: Job
metadata:
labels:
app: pyxecutor
dan: test
name: orchestra-core-q1-2019-20190420-080653
namespace: pyxecspawner-jobs
spec:
backoffLimit: 1
View gist:cd043402cb4abe52d6664755eb317d46
louvre-d-# \d gallery_release
Table "public.gallery_release"
Column | Type | Collation | Nullable | Default
------------+--------------------------+-----------+----------+---------------------------------------------
id | integer | | not null | nextval('gallery_release_id_seq'::regclass)
created_at | timestamp with time zone | | not null |
updated_at | timestamp with time zone | | not null |
label | character varying(60) | | not null |
namespace | character varying(20) | | not null |
creator_id | integer | | not null |
View gist:655f8ef89a3fa40c9e26b1835b0ff795
from multiprocessing.pool import Pool
import os
def process_one_file(filename):
print("processing ", filename)
return filename
pool = Pool(4)
p = pool.imap_unordered(process_one_file, os.listdir(), chunksize=10000)
@hnykda
hnykda / revolut2wallet.py
Last active Apr 21, 2019
Python snippet to convert Revolut export to Wallet
View revolut2wallet.py
import argparse
import datetime
import pandas as pd
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('input', help='Input revolut export file')
parser.add_argument('--output', default="rev2wall-{CURRENCY}-{TIMESTAMP}.csv", help='Input Revolut file')
return parser.parse_args()
View boot.log
-- Logs begin at Sat 2017-10-07 14:26:40 CEST, end at Sun 2019-01-13 09:46:32 CET. --
Jan 13 09:45:51 think460s kernel: Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC 2018
Jan 13 09:45:51 think460s kernel: Command line: initrd=\initramfs-linux.img initrd=\intel-ucode.img root=PARTUUID=8d411a1d-fd6b-4916-b21f-f745a70a39d3 rw intel_iommu=off
Jan 13 09:45:51 think460s kernel: KERNEL supported cpus:
Jan 13 09:45:51 think460s kernel: Intel GenuineIntel
Jan 13 09:45:51 think460s kernel: AMD AuthenticAMD
Jan 13 09:45:51 think460s kernel: Hygon HygonGenuine
Jan 13 09:45:51 think460s kernel: Centaur CentaurHauls
Jan 13 09:45:51 think460s kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
Jan 13 09:45:51 think460s kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
View gist:574cb98e176abd1432d099bd504e53fa
Dec 02 11:20:45 think460s audit[2167]: ANOM_ABEND auid=1000 uid=1000 gid=1000 ses=1 pid=2167 comm="chromium" exe="/usr/lib/chromium/chromium" sig=4 res=1
Dec 02 11:20:45 think460s kernel: BUG: unable to handle kernel paging request at 0000000000020008
Dec 02 11:20:45 think460s kernel: PGD 0 P4D 0
Dec 02 11:20:45 think460s kernel: Oops: 0000 [#1] PREEMPT SMP PTI
Dec 02 11:20:45 think460s kernel: CPU: 3 PID: 19433 Comm: rescuetime Tainted: G OE 4.19.4-arch1-1-ARCH #1
Dec 02 11:20:45 think460s kernel: Hardware name: LENOVO 20FAS0FD07/20FAS0FD07, BIOS N1CET59W (1.27 ) 08/31/2017
Dec 02 11:20:45 think460s kernel: RIP: 0010:rb_next+0x27/0x50
Dec 02 11:20:45 think460s kernel: Code: 1f 40 00 48 8b 0f 48 39 cf 74 38 48 8b 47 08 48 85 c0 74 22 48 8b 50 10 48 85 d2 74 0c 48 89 d0 48 8b 50 10 48 85 d2 75 f4 c3 <48> 3b 79 08 75 12 48 8b 09 48 89 d7 48 83 e1 fc 48 89 ca 48 89 c8
Dec 02 11:20:45 think460s kernel: RSP: 0018:ffffbae98d4dbd40 EFLAGS: 00010206
Dec 02 11:20:45 think460s kernel: RAX: 00000000000200
View gist:79db90398af36408eb520c12758e1e20
def migrate_data(apps, schema_editor):
Tracker = apps.get_model('campaign', 'Tracker')
Syncer = apps.get_model('campaign', 'Syncer')
Key = apps.get_model('attribute', 'Key')
for k in Key.objects.all():
c = k.parent_campaign
if c.campaign_type == 'Panel':
new_camp = Syncer.objects.get(cid=c.cid)
else:
new_camp = Tracker.objects.get(cid=c.cid)
View gist:01df49d3a23b6e9e9ececf82f174a2dc
worker_1 | 20180625 15:52:42:urllib3.connectionpool:DEBUG http://es:9200 "POST /q4_2016/_doc/_update_by_query HTTP/1.1" 404 351
worker_1 | 20180625 15:52:42:elasticsearch:WARNING POST http://es:9200/q4_2016/_doc/_update_by_query [status:404 request:0.038s]
worker_1 | 20180625 15:52:42:elasticsearch:DEBUG > {"query":{"bool":{"should":[{"exists":{"field":"asked.test-project"}},{"exists":{"field":"test-project"}}],"minimum_should_match":1}},"script":{"source":"\n def fields = new ArrayList(ctx._source.keySet());\n if (params.fresh_sample_fields.containsAll(fields)){\n ctx.op = 'delete';\n } else {\n ctx._source.remove(params.project_id);\n ctx._source.asked.remove(params.project_id);\n }\n ","lang":"painless","params":{"not_exist_project_id":"invalid_project","project_id":"test-project","fresh_sample_fields":["a
View gist:0099d0629f8ba45ace50c3e8896a2fb2
In [24]: %time df.loc[:, 'cc'] = np.full(df.shape[0], pd.np.nan, dtype='float16')
CPU times: user 286 µs, sys: 5.47 ms, total: 5.75 ms
Wall time: 4.41 ms
In [25]: %time df.loc[:, 'ccc'] = np.full(df.shape[0], pd.np.nan, dtype='float16')
CPU times: user 24.5 ms, sys: 19.2 ms, total: 43.7 ms
Wall time: 39.5 ms
In [26]: %time df.loc[:, 'cccc'] = np.full(df.shape[0], pd.np.nan, dtype='float16')
CPU times: user 492 ms, sys: 1.2 s, total: 1.69 s
@hnykda
hnykda / convert.py
Created Feb 21, 2018
Quick and dirty conversion of ZSH history into fish
View convert.py
# run as `python conver.py <path-to-your-zsh-history-file>
import sys
output_file = 'fish_converted_history'
zsh_history_file = sys.argv[1]
with open(zsh_history_file, 'r', errors='ignore') as ifile:
result = []
for cmd in ifile:
You can’t perform that action at this time.