Skip to content

Instantly share code, notes, and snippets.

View yanivmo's full-sized avatar

Yaniv Mordekhay yanivmo

View GitHub Profile
@yanivmo
yanivmo / Brewfile
Last active March 23, 2025 08:18
Bootstrap your dev Mac — friendly and ergonomic Brewfile for software developers
#----------------------------------------------------------------------------
# Friendly Brewfile to bootstrap a development Mac
#
# Step 1: Install brew
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Step 2: Download and apply this Brewfile (or modify its contents before, of you do not want everything):
# brew bundle --file ./Brewfile
#
# Or be bold and do it one go:
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && curl --fail --location https://bit.ly/my-new-mac | brew bundle --file=-
@yanivmo
yanivmo / plantuml.sh
Created November 2, 2020 19:06
Edit PlantUML diagram definition locally and see the changes on the fly
#!/bin/bash
# The only argument is the diagram definition file
test -z "$1" && (echo "Expected one filename argument"; exit 1)
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# plantuml.jar is the PlantUML distribution as downloaded from https://plantuml.com/download
java -jar ${script_dir}/plantuml.jar $1
@yanivmo
yanivmo / bokeh-boxplot.py
Last active April 18, 2017 14:40
Example of a box-and-whiskers diagram with a global average span, using Bokeh.BoxPlot and Pandas.DataFrame.
import bokeh.charts as bch
import pandas as pn
from bokeh.models import CrosshairTool, PanTool, ResetTool, WheelZoomTool, Span
# Input data as a list of tuples
data = [
(1, -3),
(1, 1),
(1, 2),
(1, 3),
@yanivmo
yanivmo / blame-haim
Created October 27, 2016 08:16
Automatically detect how haimzardous your source is
#!/bin/bash
total=$(git blame $1 | wc -l)
haim=$(git blame $1 | grep -i Haim | wc -l)
if [ "$total" -eq "0" ]; then
echo "Cannot blame"
exit -1
fi
@yanivmo
yanivmo / ReadAndroidContacts.java
Last active September 28, 2015 08:38
Read Android contacts
// The flow starts in onReadClick
import android.app.LoaderManager;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.provider.ContactsContract;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
@yanivmo
yanivmo / ParseCsvC++03.cpp
Last active December 14, 2015 00:09
Parse a string of comma separated values using C++03 Standard Library only
std::set<std::string> CMService::getDirContents(const std::string& path)
{
RepositoryService repository;
//RepositoryService::getDirContents returns CSVs in a string
std::stringstream contentsCsv(repository.getDirContents(path));
std::string entry;
std::set<std::string> entries;
while (std::getline(contentsCsv, entry, ',')) {