Skip to content

Instantly share code, notes, and snippets.

#fix git to work behind a firewall
git config --global url.https://github.com/.insteadOf git://github.com/
@dwerbam
dwerbam / bashrc
Last active January 9, 2024 19:47
mcd alias, to create a directory and cd into it immediately
alias mcd='function _mcd(){ mkdir -p "$1"; cd "$1"; };_mcd'
@dwerbam
dwerbam / inject_jquery.js
Created March 11, 2017 12:42
inject jquery bookmark
// create a browser bookmark, on the link url paste the following..
javascript: (function(e, s) { e.src = s; e.onload = function() { jQuery.noConflict(); console.log('jQuery injected'); }; document.head.appendChild(e); })(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js')
@dwerbam
dwerbam / change_lid_action.sh
Created November 5, 2017 11:51
ubuntu change lid action: ignore, suspend, hibernate
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
replace_var_in_file() {
VAR=$1
VALUE=$2
FILENAME=$3
@dwerbam
dwerbam / steganos.ipynb
Created June 30, 2019 07:32
Steganos with cryptography.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dwerbam
dwerbam / README.md
Created June 30, 2019 08:16
open steganos + cryptography in binder

Binder

@dwerbam
dwerbam / sapo.ps1
Created March 19, 2020 10:59
SAP analysis for office automation
# CONFIGURE
## set environment variables SAP_ANALYSIS_USER and SAP_ANALYSIS_PASS
# TO ENABLE EXECUTION (if you see SecurityError:UnauthorizedAccess)
## 1. open a powershell console as Administrator
## 2. run "set-executionpolicy remotesigned"
# TO RUN
## 1. open powershell
## 2. run "./sapo.ps1 -file FULL_PATH_TO_EXCEL.xlsx"
@dwerbam
dwerbam / loglapse.py
Last active October 4, 2021 08:16
calculates the time difference between the log lines and writes the 'next' line with the prefixed time lapse
## calculates the time difference between the log lines
## and writes the 'next' line with the prefixed time lapse
## use: python3 logplapse.py some.log > ts.log
from datetime import datetime
import re
import sys
FMT = '%Y-%m-%d %H:%M:%S'
TS_REGEXP = '\[([0-9:\- ]+)\]'
SPACER = "| ".rjust(10)
@dwerbam
dwerbam / case_when_raw.r
Last active October 8, 2021 06:40
spark case_when raw implementation
dfletters <- data.frame(letter=letters)
sparkletters <- sdf_copy_to(sc, dfletters, 'sometable', overwrite=T)
# or using sdf_register(name='sometable')
sparkletters
df2 <- sdf_sql(sc, "select letter as A1,
CASE WHEN letter = 'b' OR letter='d'
THEN 'itsBorD'
ELSE
CASE WHEN letter = 'c'
@dwerbam
dwerbam / RayParallelExec.py
Created October 9, 2021 23:29
example of how to use ray.io to execute multiple OS processes in parallel (something like GNU parallel is doing)
# example of how to use ray.io to execute multiple
# OS processes in parallel (even in multiple machines)
# (something like GNU parallel is doing)
pip install -U "ray[default]"
import ray
import os
import time