Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
shaybensasson / bash_script_with_try_catch.sh
Last active November 9, 2022 09:04
bash_script_with_try_catch.sh
#!/bin/bash
# see https://stackoverflow.com/a/46597567/1640414
echo "started"
function a() {
# do some stuff here
echo "a()"
ls *.sh
}
@shaybensasson
shaybensasson / transfer.sh
Last active October 17, 2022 07:45
Bash script that uploads a file or a zipped directory to keep.sh
#!/bin/sh
# A script with functions to add to .bashrc
# Uploads a file or a zipped directory to `keep.sh`
# see https://free.keep.sh
# usage: transfer hello.txt
# requirements: curl
# based on transfer.sh old, not-working anymore script.
# A free bucket is provided by keep.sh for public use. Files are limited to 500MB and are deleted 24 hours after upload.
transfer() {
@shaybensasson
shaybensasson / custom_shell_functions.sh
Created June 6, 2022 09:48
Some useful bash functions
#!/bin/sh
# A script with functions to add to .bashrc
# Uploads a file to transfer.sh
# see https://transfer.sh/
# usage: transfer hello.txt
# requirements: curl
transfer() {
if [ $# -eq 0 ]; then
echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2
@shaybensasson
shaybensasson / install.sh
Created April 15, 2022 11:29
Installing bat (cat with wings) on ubuntu < 20
curl -s https://api.github.com/repos/sharkdp/bat/releases/latest \
| grep "browser_download_url.*amd64.deb" \
| grep "bat-musl_" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -P "$TempFileDirectory" -qi - &&
sudo dpkg -i bat-musl*_amd64.deb
@shaybensasson
shaybensasson / render_json.py
Created April 13, 2022 08:06
Render JSON (great for hierarchical dicts) for jupyter notebooks
# https://stackoverflow.com/a/37124230/1640414
# https://caldwell.github.io/renderjson/
import uuid
from IPython.display import display_javascript, display_html, display
import json
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict):
@shaybensasson
shaybensasson / logging_to_console.py
Last active March 12, 2022 13:08
~One liner logging to console
import logging
logging.basicConfig(level="DEBUG", style="{",
format='[{asctime:s}] {levelname:7s} | {process:5d} | {name:s} | {message:s}')
_logger = logging.getLogger(__name__)
@shaybensasson
shaybensasson / config.json
Created July 14, 2021 10:32
Alfred/Watson config at ~/.config/powerline-shell/config.json
{
"mode": "flat",
"theme": "default",
"segments": [
"virtual_env",
"hostname",
"ssh",
"cwd",
"git",
"hg",
@shaybensasson
shaybensasson / install-obsidian.sh
Created July 10, 2021 07:02
Installing Obsidian (an advanced markdown editor) on Ubuntu
#!/usr/bin/env bash
# see https://forum.obsidian.md/t/gnome-desktop-installer/499
set -euo pipefail
icon_url="https://cdn.discordapp.com/icons/686053708261228577/1361e62fed2fee55c7885103c864e2a8.png"
#dl_url=${1:-}
dl_url=$( curl -s https://api.github.com/repos/obsidianmd/obsidian-releases/releases/latest \
| grep "browser_download_url.*AppImage" | tail -n 1 | cut -d '"' -f 4 )
@shaybensasson
shaybensasson / install_lyx_hebrew.sh
Created November 12, 2020 16:09 — forked from mickey946/install_lyx_hebrew.sh
Installation script for LyX to work with Hebrew on Ubuntu.
#!/bin/sh
sudo apt-get install lyx culmus culmus-fancy texlive-lang-other
wget https://sourceforge.net/projects/ivritex/files/culmus-latex/culmus-latex-0.7/culmus-latex_0.7-1_all_fixed.deb/download -O culmus-latex_0.7-1_all_fixed.deb
sudo dpkg -i culmus-latex_0.7-1_all_fixed.deb
sudo apt-get install -f
rm -f culmus-latex_0.7-1_all_fixed.deb
@shaybensasson
shaybensasson / docker-compose.yml
Created November 6, 2020 08:20 — forked from adamelliotfields/docker-compose.yml
Docker Compose Mongo with Mongo Express
version: "3.5"
services:
mongo:
image: mongo:latest
container_name: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports: