Skip to content

Instantly share code, notes, and snippets.

@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 / pet-snippet.toml
Last active April 14, 2024 08:01
description
[[snippets]]
description = "edit pet configs and snippets"
command = "code ~/.config/pet/snippet.toml"
tag = ["pet"]
output = ""
[[snippets]]
description = "edit snippets_menu jupyter plugin configuration"
command = "code ~/.local/share/jupyter/nbextensions/snippets_menu/my_snippets.js"
tag = ["python", "jupyter"]
@shaybensasson
shaybensasson / SpikeRateUsingGaussian.matlab
Created March 7, 2015 16:24
create firing rate from spike train using Gaussian kernel
%https://www.mathworks.com/matlabcentral/newsreader/view_thread/243177
clear all
clc
figure(1);clf
%y=[ 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1]; % spike train
SPIKE_TRAIN_LENGTH = 100;
y=double(logical(rand(SPIKE_TRAIN_LENGTH,1)<0.5));
plot(y)
hold on
@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 / my_snippets.js
Last active June 14, 2022 17:54
My Jupyter nbextension "Snippets Menu" json configuration
var MY_SNIPPETS = {
'name': 'Snippets',
'sub-menu': [
{
'name': 'config file',
'snippet': ['!cat ~/.local/share/jupyter/nbextensions/snippets_menu/my_snippets.js']
},
'---',
{
'name': 'Header',
@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__)