Skip to content

Instantly share code, notes, and snippets.

View lucarin91's full-sized avatar

Luca Rinaldi lucarin91

View GitHub Profile
@lucarin91
lucarin91 / sendlog
Created April 20, 2020 13:25
Simple sh script to send out log to a telegram chat.
#!/bin/sh
#####################################################
# CONFIGURATION #
#####################################################
TOKEN=1233445ASDKLSJDASASDDASBJHBEUBSAÀÒBDFASOFADBSDF
CHAT_ID=12312354
#####################################################
@lucarin91
lucarin91 / nextcloud_backup.sh
Created May 24, 2019 09:47
Simple script for backup Nextcloud data.
#!/bin/sh
set -x
NC_PATH="/var/www/nextcloud"
DST_PATH="/tmp"
DATE=$(date +"%Y%m%d")
# start maintenance
sudo -u www-data php "$NC_PATH/occ" maintenance:mode --on
@lucarin91
lucarin91 / install-omzfish.sh
Created September 11, 2018 16:31
Install oh-my-zsh with fish-like plugins.
#!/bin/sh
set -ex
## install oh-my-zsh ##
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
## install fish-like plugins ##
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
@lucarin91
lucarin91 / sync.sh
Last active December 20, 2022 14:09
Synchronize a local folder with a remote server in a bidirectional way.
#!/bin/sh
set -e
### Configuration ###
SERVER=luca@example.com
REMOTE_FOLDER=my_folder
REMOTE_RESULTS=results
EXCLUDE_FILES="--exclude=.*\
--exclude=build/"
@lucarin91
lucarin91 / .inputrc
Last active August 28, 2018 08:44
The .inputrc configuration file to enable a zsh-like completion mechanism in bash.
##
# The .inputrc configuration file to enable a zsh-like completion mechanism in bash.
# Features:
# - Press tab to cycle throw all possible completions in a case-insensitive fashion.
# - Use the up and down arrow to search throw the history for all matches of the typed string.
#
# DISCLAIMER: Use only when you cannot install zsh :)
#
# Put together by lucarin91.
##
@lucarin91
lucarin91 / tsend
Last active November 3, 2018 16:50
Send a telegram message when something happens on a remote server
#!/bin/sh
###
# Send message to your telegram chat when something happens to a remote server.
# Before use the sript update the TOKEN and CHAT_ID variable with your data.
#
# Usage:
# tsend 'ALL DONE!'
# cat myfile.txt | tsend
#
# license: MIT
@lucarin91
lucarin91 / hot_change.erl
Created May 31, 2018 15:46
A simple example of an Erlang server that can dynamically change the code to process new requests.
-module(hot_change).
-export([start/0, send/1, update_code/1]).
start() ->
F = fun(Str) -> string:lowercase(Str) end,
register(hot_change_server, spawn(fun () -> loop(F) end)).
loop(F) ->
receive
{request, Pid, Q} ->
@lucarin91
lucarin91 / sleep.js
Created May 6, 2018 14:56
A simple JavaScript implementation of sleep using the yield command.
/* jshint esversion:6 */
function * main (){
console.log('Every time you need a sleep, you can yield the number of seconds that you want to wait..');
yield 5;
console.log('..this will be executed 5 seconds later');
yield 1.5;
console.log('[long wait]');
yield 10;
console.log('..and, this after 10 seconds.\n');
@lucarin91
lucarin91 / get_abs_path.sh
Last active August 11, 2020 10:17
Shell command to retrive the absolute of the script
abs_path=$(cd "$(dirname "$0")" && pwd)
@lucarin91
lucarin91 / example_group.completed.yaml
Created September 27, 2017 15:23
example toskeriser
tosca_definitions_version: tosca_simple_yaml_1_0
description: "TOSCA simple profile with wordpress, web server and mysql on the same\
\ server.\n"
repositories:
docker_hub: https://registry.hub.docker.com/
imports:
- tosker: ../tosker-types.yaml