Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
"Simplicity is prerequisite for reliability." Edsger W. Dijkstra

Anton Ivanov antivanov

💭
"Simplicity is prerequisite for reliability." Edsger W. Dijkstra
View GitHub Profile
@antivanov
antivanov / free.docker.space.sh
Last active Feb 5, 2020
Useful commands to free Docker space
View free.docker.space.sh
# Stop and remove all containers
docker rm -f $(docker ps -a -q)
# Remove all images
docker rmi $(docker images -a -q)
# Remove other unused docker data, i.e. networks
docker system prune
# Remove all the unused docker volumes (frees lots of space!)
@antivanov
antivanov / launch.json
Created Aug 22, 2019 — forked from constantm/launch.json
Get VSCode debug and breakpoints to work with Vue Cli and Jest
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vue-cli-service-tests",
"request": "launch",
"env": {
"NODE_ENV": "test"
},
@antivanov
antivanov / bash_function_to_kill_processes_on_port.sh
Last active Aug 13, 2019
Bash function to kill the processes using a particular port
View bash_function_to_kill_processes_on_port.sh
# Add the function below to ~/.bashrc to make it available from command line
#
# Usage:
# $ free_port 8080
free_port() {
kill -9 $(lsof -t -i:$1)
}
@antivanov
antivanov / list_map_fold.scm
Created Oct 8, 2018
map and fold implementation for lists in Scheme
View list_map_fold.scm
; Maps function over list
; f - function of one argument, returns transformed argument
; l - list
(define (map f l)
(if (> (length l) 0)
(cons
(f (car l))
(map f (cdr l))
)
()
@antivanov
antivanov / create_bootable_drive.sh
Created Sep 24, 2018
Command to create bootable USB with progress displayed using dd, pv
View create_bootable_drive.sh
sudo dd if=./some.linux.iso | pv -s 2G | sudo dd of=/dev/sdb bs=8192
@antivanov
antivanov / akka_stream_example.scala
Created Mar 11, 2018
Simple example of a stream in Akka: source -> flow -> sink
View akka_stream_example.scala
import akka.actor.ActorSystem
import akka.stream.scaladsl._
import akka.stream._
object AkkaStreamExample extends App {
implicit val system = ActorSystem("MyActorSystem")
implicit val materializer = ActorMaterializer()
val source = Source(1 to 5)
val square = Flow[Int].map(x => x * x)
@antivanov
antivanov / install_python3.6_opensuse42.3.sh
Last active Aug 20, 2020
Installing Python 3.6 on OpenSUSE Leap 42.3
View install_python3.6_opensuse42.3.sh
# !/bin/bash
# Step 1. Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
source ~/.bashrc
@antivanov
antivanov / terminate.sh
Last active Aug 19, 2018
Better 'killall' command in Bash, analogous to 'kill -9' usage: 'terminate.sh java'
View terminate.sh
#!/bin/bash
pids_to_kill=$(ps aux|grep $1|grep -v grep|grep -v terminate.sh |awk '{print $2}')
[[ ! -z $pids_to_kill ]] && kill -9 $pids_to_kill
@antivanov
antivanov / bash_find_large_directories.sh
Last active Aug 15, 2018
Bash command that finds subdirectories of the current directory that are larger than 1Gb
View bash_find_large_directories.sh
du -h | grep '^[0-9]\.*[0-9]*G'
@antivanov
antivanov / browser_text_mode.js
Created May 17, 2017
Remove images, videos and backgrounds from the web page to leave only the text content
View browser_text_mode.js
(function() {
function toArray(arrayLike) {
return [].slice.call(arrayLike);
}
function $(cssSelector) {
return toArray(document.querySelectorAll(cssSelector));
}
You can’t perform that action at this time.