Skip to content

Instantly share code, notes, and snippets.


Guy Smoilovsky guysmoilov

View GitHub Profile
guysmoilov / named_pipes_test.go
Last active Sep 1, 2021
Simple example of using named pipes in go for IPC
View named_pipes_test.go
import (
func TestFifo(t *testing.T) {
guysmoilov / Git pre-commit hook for large
Last active Jul 22, 2022
Git pre-commit hook for large files
View Git pre-commit hook for large

Git pre-commit hook for large files

This hook warns you before you accidentally commit large files to git. It's very hard to reverse such an accidental commit, so it's better to prevent it in advance.

Since you will likely want this script to run in all your git repos, a script is attached to add this hook to all git repos you create / clone in the future.

Of course, you can just download it directly to the hooks in an existing git repo.

If you find this script useful, you might enjoy our more heavy-duty project FastDS, which aims to make it easier to work with versioning in data science projects.

guysmoilov / .gitconfig
Last active Feb 11, 2021
My git aliases. Work in progress.
View .gitconfig
br = branch
sh = show
rb = rebase
rbi = rebase -i
st = status
ci = commit
cim = commit -m
co = checkout
rs = reset
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort -nrk2 \
| cut -c 1-12,41-
guysmoilov /
Created Feb 28, 2019
Bash script to download large zip files from google drive while confirming the virus scan warning
# Usage: gdrive_download 123-abc ./
function gdrive_download () {
CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "$1" -O- | sed -En 's/.*confirm=([0-9A-Za-z_]+).*/\1/p')
wget --load-cookies /tmp/cookies.txt "$CONFIRM&id=$1" -O $2
rm -f /tmp/cookies.txt
import java.util.Comparator;
import java.util.List;
public class Mystery<T extends Comparable<? super T>> implements Comparator<List<T>> {
public int compare(List<T> l1, List<T> l2) {
guysmoilov / save-js-blob.js
Last active Jul 30, 2017
Saves an octet-stream returned from a REST call as a file
View save-js-blob.js
var toSend = {};
var xmlhttp = new XMLHttpRequest();"POST", "", true);
xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.onload = function() {
guysmoilov /
Last active May 7, 2018
Java lexicographical comparator for lists
import java.util.Comparator;
import java.util.List;
* Compares {@link Comparable} list instances lexicographically.
* Assumes that the lists are not null, that they contain no null elements, and that they are optimized for random access!
* <p>
* Created by Tolstoyevsky on 08/02/2017.
* </p>
guysmoilov / TopicChangingMirrorMakerMessageHandler.scala
Created Nov 30, 2016
Topic transforming Kafka mirror maker handler
View TopicChangingMirrorMakerMessageHandler.scala
import java.util
import java.util.Collections
import kafka.consumer.BaseConsumerRecord
import org.apache.kafka.clients.producer.ProducerRecord
import scala.util.matching.Regex
guysmoilov /
Created Aug 23, 2016
Watch command for long-term monitoring
echo "Watching $1 command"
while sleep 1; do
CURRENT=`eval $1`
if [ "$CURRENT" != "$PREV" ]; then
echo "[`date`]: $CURRENT"