Skip to content

Instantly share code, notes, and snippets.

View Nihhaar's full-sized avatar
🎯
Focusing

Nihhaar_RC Nihhaar

🎯
Focusing
View GitHub Profile
@Nihhaar
Nihhaar / .gitlab-ci.yml
Last active October 19, 2021 14:55
Gitlab CI DinD + ECR
image: docker
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
services:
- docker:dind
@Nihhaar
Nihhaar / DAGFactory.py
Last active September 16, 2021 12:52
DAG factory to load dags from other directories and show load errors on the Airflow UI
import os
import sys
import traceback
from airflow.models import DagBag
from airflow.utils.session import provide_session
from airflow.dag_processing.processor import DagFileProcessor
DAG_DIRS = ['<path/to/dir1>', '<path/to/dir2>', ...]
@Nihhaar
Nihhaar / logger.py
Created August 27, 2021 04:20
PySpark logging
import os
import logging
import sys
class YarnLogger:
@staticmethod
def setup_logger():
if not 'LOG_DIRS' in os.environ:
sys.stderr.write('Missing LOG_DIRS environment variable, pyspark logging disabled')
return
@Nihhaar
Nihhaar / sql-dask.py
Last active September 21, 2020 18:49 — forked from quasiben/sql-dask.py
SQL and Dask
"""
conda install -c conda-forge postgresql psycopg2 sqlalchemy
initdb -D /tmp/dask_db
postgresql -D /tmp/dask_db
pg_ctl -D /tmp/dask_db -l logfile start
createuser --encrypted --pwprompt dask
createdb --owner=dask dask_db
"""
@Nihhaar
Nihhaar / vscode-settings.json
Created August 2, 2020 17:55
VSCode Settings Config
{
"workbench.colorTheme": "Default Light+",
"workbench.iconTheme": "material-icon-theme",
"workbench.sideBar.location": "right",
"editor.fontFamily": "'Dank Mono', 'Fira Code', 'Operator Mono Lig Book', 'FantasqueSansMono Nerd Font Mono'",
"editor.fontLigatures": true,
"editor.fontSize": 15,
"editor.detectIndentation": false,
"editor.tabSize": 4,
"[javascript]": {
@Nihhaar
Nihhaar / to_redshift.py
Created March 4, 2020 13:58 — forked from TomAugspurger/to_redshift.py
to_redshift.py
# see also https://github.com/wrobstory/pgshift
import gzip
from io import StringIO, BytesIO
from functools import wraps
import boto
from sqlalchemy import MetaData
from pandas import DataFrame
from pandas.io.sql import SQLTable, pandasSQL_builder
@Nihhaar
Nihhaar / LetsDestroyC.md
Created January 31, 2020 06:24 — forked from shakna-israel/LetsDestroyC.md
Let's Destroy C

Let's Destroy C

I have a pet project I work on, every now and then. CNoEvil.

The concept is simple enough.

What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?


@Nihhaar
Nihhaar / s3_multipart_upload.py
Last active January 11, 2020 19:50
Upload content (bytes) to aws s3 using multipart upload api
from datetime import datetime
# Usage:
# with S3MultipartUpload(client=boto3.client('s3'), destination_bucket, destination_key) as s3upload:
# # Do something
# s3upload.upload(content)
# # Do something
# s3upload.upload(content)
# # Do something
# s3upload.flush()
@Nihhaar
Nihhaar / S3 buckets copy.md
Created January 10, 2020 09:57 — forked from ushu/S3 buckets copy.md
Copy between S3 buckets w/ different accounts

This is a mix between two sources:

basically the first resource is great but didn't work for me: I had to remove the trailing "/*" in the resource string to make it work. I also noticed that setting the policy on the source bucket was sufficient. In the end these are the exact steps I followed to copy data between two buckets on two accounts

Basically the idea there is:

  • we allowe the destination account to read the source bucket (in the console for the source account)
  • we log as the destination and start the copy
@Nihhaar
Nihhaar / config.plist
Created January 7, 2020 15:17
OpenCore config.plist SAMPLE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ACPI</key>
<dict>
<key>Add</key>
<array>
<dict>
<key>Comment</key>