Skip to content

Instantly share code, notes, and snippets.

View cristianradulescu's full-sized avatar
🤓

Cristian Radulescu cristianradulescu

🤓
View GitHub Profile
@cristianradulescu
cristianradulescu / git-diff-index.sh
Created April 7, 2023 13:49
Find staged PHP files which are [A]dded or [M]odified and are not in the "tests" dir
git diff-index --cached HEAD --name-only --diff-filter=AM ':*.php' ':!tests*'
@cristianradulescu
cristianradulescu / pip_upgrade.sh
Created January 9, 2023 07:29
Bulk upgrade PIP packages
#!/usr/bin/env bash
# Save outdated packages to a local file since the upgrade process might have to be repeated due to missing deps
sudo pip list -o --format=json > pip_outdated.json
# Do the upgrade
sudo pip install -U $(cat pip_outdated.json | jq -r ".[].name" | tr "\n" " ")
@cristianradulescu
cristianradulescu / vpn.sh
Last active October 17, 2022 13:21
Connect to VPN from CLI using Tunnelblick scripts
#!/usr/bin/env bash
#set -ex
OVPN_CONFIG=config.ovpn # get it after import in TB from "/Library/Application Support/Tunnelblick/Users/$USER/$TBLK_CONFIG/Contents/Resources/config.ovpn"
TBLK_CONFIG=Config.tblk # will be the name of the VPN in TB after import
CLIENT_SCRIPT_PASS=qwertyuiop
# Use openvpn bundled with Tunnelblick on MacOS
/Applications/Tunnelblick.app/Contents/Resources/openvpn/openvpn-2.5.4-openssl-1.1.1l/openvpn \

Keybase proof

I hereby claim:

  • I am cristianradulescu on github.
  • I am cristianrd (https://keybase.io/cristianrd) on keybase.
  • I have a public key ASBxEobETo-I428NF-W-QO_9QDX58vvXNV7tbccind7bsgo

To claim this, I am signing this object:

@cristianradulescu
cristianradulescu / PHPArray-Groovy.php.js
Last active August 30, 2022 08:15
DataGrip / PHPStorm - PHP array data extractor script
// Click on data extractors select box then choose "Go to scripts directory"; add this file in the "extractors" directory
function eachWithIdx(iterable, f) { var i = iterable.iterator(); var idx = 0; while (i.hasNext()) f(i.next(), idx++); }
function mapEach(iterable, f) { var vs = []; eachWithIdx(iterable, function (i) { vs.push(f(i));}); return vs; }
var NEWLINE = "\n";
var INDENT = " "
function output() { for (var i = 0; i < arguments.length; i++) { OUT.append(arguments[i]); } }
function outputRow(rowName, items) {
@cristianradulescu
cristianradulescu / vault-multi-login.sh
Created August 3, 2022 07:34
HashiCorp Vault multiple logins
#!/usr/bin/env bash
ENV=$(echo $1 | tr '[:upper:]' '[:lower:]')
case $ENV in
test)
TOKEN=t3st.t0k3n
;;
uat)
TOKEN=u4t.t0k3n
@cristianradulescu
cristianradulescu / restart-docker-sync.sh
Last active August 3, 2022 08:18
MacOS restart docker sync
#!/usr/bin/env bash
DOCKER_SYNC_CONTAINER_NAME=m2_app_code
DOCKER_SYNC_CMD="make dev-up-docker-sync"
brew services restart consul && \
docker ps --format '{{.ID}}' --filter name="$DOCKER_SYNC_CONTAINER_NAME" | xargs docker rm -f && \
$DOCKER_SYNC_CMD
# On receiver:
nc -l -p 1234 -v | pv > file.txt
# On sender:
nc -w 2 <ip_of_receiver> 1234 < file.txt
@cristianradulescu
cristianradulescu / macos-remove-quarantine.sh
Last active September 19, 2022 06:05
MacOS remove quarantine attr
#!/usr/bin/env bash
### Error:
# “CopyQ.app” cannot be opened because the developer cannot be verified.
# macOS cannot verify that this app is free from malware.
# Homebrew Cask downloaded this file today at 08:58.
### Run:
# macos-remove-quarantine.sh /Applications/CopyQ.app
@cristianradulescu
cristianradulescu / samsung-debloat.sh
Last active October 17, 2022 13:23
Debloat Samsung phone
#!/usr/bin/env bash
set -x
##############################
# Last tested on Galaxy S20! #
##############################
# Bixby
adb shell pm disable-user --user 0 com.samsung.android.bixby.wakeup