Skip to content

Instantly share code, notes, and snippets.

@Arqentum
Arqentum / pyenv_create_alias_pyver.sh
Last active November 3, 2023 19:05
#Python #PYENV create alias activate version
PYENV_PYTHON_VERSION=3.8.18
VENV_NAME=revrec-airflow-3.8
pyenv install $PYENV_PYTHON_VERSION
pyenv virtualenv $PYENV_PYTHON_VERSION $VENV_NAME
pyenv activate $VENV_NAME
#Switch between Python versions
#To select a Pyenv-installed Python as the version to use, run one of the following commands:
pyenv shell <version> -- select just for current shell session
@Arqentum
Arqentum / bq_in_datagrip.txt
Created October 10, 2023 17:52
#Datagrip auth to #BigQuery
Application Default Credential option in login options on connection setup step
make sure to
> gcloud auth application-default login
before
@Arqentum
Arqentum / airflow_custom_execution_schedule.py
Created October 5, 2023 17:45
#Airflow custom dag execution schedule
def _skipcondition(execution_date, **_):
first_valid_friday = datetime(2021, 4, 9)
return (execution_date - first_valid_friday).days % 14 == 0
with DAG(dag_id='fortnightSchedule',default_args = default_args, schedule_interval = "0 17 * * 5", catchup=False) as dag:
check_valid_friday = ShortCircuitOperator(
task_id="check_if_correct_friday",
python_callable=_skipcondition,
provide_context=True,
)
@Arqentum
Arqentum / airflow_task_branching.py
Created October 3, 2023 17:50
#Airflow task branching
month_mid = DummyOperator(task_id='month_mid')
month_end = DummyOperator(task_id='month_end')
def choose_branch(execution_date, **_):
if execution_date.day == 15:
return month_mid.task_id
else:
return month_end.task_id
branching_step = BranchPythonOperator(
@Arqentum
Arqentum / rollup_example.sql
Created September 25, 2023 23:10
#SQL rollup example
with
tt1 as (
select *
from
(values
(1, 'USD', 'website', 10),
(2, 'USD', 'website', 11),
(3, 'EUR', 'website', 24),
@Arqentum
Arqentum / mac_set_mouse_speed_above_ui_limit.sh
Last active May 7, 2025 17:43
#MacOS set mouse speed above UI limit
defaults write -g com.apple.mouse.scaling -float 5.0
@Arqentum
Arqentum / airflow_test_dag.py
Created September 7, 2023 20:59
#Airflow test dag
# Just add at the bottom which will create a green arrow in pycharm to run
if __name__ == "__main__":
dag.test()
@Arqentum
Arqentum / revrec_python_version_clang_error.txt
Created August 28, 2023 15:54
Revrec Python version 3.6 can't be installed clang++
https://github.com/pyenv/pyenv/issues/2112#issuecomment-1096478446
@Arqentum
Arqentum / last_value_ignore_nulls.sql
Created July 27, 2023 23:06
#PSQL #SQL last_value_ignore_nulls
do $transaction$
begin
create function coalesce_r_sfunc(state anyelement, value anyelement)
returns anyelement
immutable parallel safe
as
$$
select coalesce(value, state);
$$ language sql;
@Arqentum
Arqentum / mongo_scratch.sh
Last active July 18, 2023 00:18
#mongo random query scratch
show dbs
use Squarespace
show collections
var ids = ['602c5dc0efc2030d4291df0e','6035fd5c059eee439eee882f','6053c6d1f3355c535cc04e47','606215248057bd618dc5137c','60d601576bb37e5d3102137d','60ff11d5155ac81fd7cede37','611319535be1890a2749144e','6114c313c704e77895eae698','6115739f891a354cbc85def6','6115e81b7d61344c77941fb9','611abff9d530264ea5b6c353','611ae1240c2b7a3390599093','611c9d511ec44d5e09be2598','611cabc1715c1d61add3fa41','612535abfe57af7f21a9f803','6126707751522312c45ac2ba','6127bfb2e9b1fe462df174b2','61280966b9f95f36f0c60930','618075b4b792b8323a9055cb','6192abdeee3a4c569ef3acbe','619bea082fc3722e487a3c43','61ae4815d286a539078721f7','61b7cd55af4dd61e505f9190','6216cbe4d7ece475a9343c12','6216d3b676f316501d2f2301','6234fca9462c9b2961eb6fa9','6267337a1302cb2a51f6515f','62ac173ba76f8c56e8f32e26','62c86f4ac28ac55affa62799','62defe33b3112e1aa5672257','62fbf079911b8f7a11ec628a','637d23212c138a54a671b4f3','639cba22559adc69f295c8e7','63b6160b1d8a170788c801b8','63c7238082514a3fc0f76e7a','63ca53dac1078a7e5bf3022