Skip to content

Instantly share code, notes, and snippets.

View elvisciotti's full-sized avatar

Elvis Ciotti elvisciotti

View GitHub Profile
@elvisciotti
elvisciotti / coinMarketCap.googleSpreadsheet.js
Last active August 14, 2022 06:51
Google spreadsheet function to calculate the value of a CryptoCurrency using coinmarketcap API
/**
* Return a cryptocurrency value in USD using coinmarketcap API
*
* @param string currency e.g. BTC, ETH
*
* @return float value
*/
function coinmarketcap(currency)
{
var body = UrlFetchApp.fetch("https://api.coinmarketcap.com/v1/ticker/");
@elvisciotti
elvisciotti / wakeUpSpotify.scpt
Last active September 9, 2018 13:21
Apple script tolaunch spotify and increase volume gradually
# To install as alarm, add this to crontab (crontab -e)
#30 8 * * 1-5 /usr/bin/osascript /Users/elvis/Documents/wakeUpSpotify.scpt
set volume 3
# morning playlist
open location "spotify:user:elvispm83:playlist:5D8fO5FikywbgjOOeICk2e"
delay 5
tell application "Spotify"
set the sound volume to 20
@elvisciotti
elvisciotti / treesize.bash
Last active August 14, 2022 06:50
Bash function to display directories from the biggest ones at the top
#/bin/bash
function treesize() {
du -k -d 1 $1 | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while ($1 >= 1024) {
@elvisciotti
elvisciotti / phpstormRamDiskCreate.bash
Last active August 14, 2022 06:39
Bash script to create ram disk to be used to speed up IntelliJ
#!/bin/bash
ramDiskCreate ()
{
if [ ! -d /Volumes/RAMDisk/intellij-cache/ ]; then
diskutil erasevolume HFS+ 'RAMDisk' `hdiutil attach -nomount ram://1024288`;
else
echo RAMDisk already created;
fi;
mkdir -p /Volumes/RAMDisk/intellij-caches;
@elvisciotti
elvisciotti / cloudflareSecurityLevel.bash
Last active August 14, 2022 06:38
Bash script to change Cloudflare security level via RESTful API. Could be used in a cronjob to disable the website during high load
#!/bin/bash
#
# Toggles cloudflare security_settings base on system load
# Only prints output when the setting is changed to a different one
# Needs "jq" installed
#
# e.g. essentially_off, low, medium, high, under_attack
USERNAME=$1
@elvisciotti
elvisciotti / adBlockerDetect.html
Created November 7, 2018 16:47
ad blocker detect.html
#https://stackoverflow.com/questions/4869154/how-to-detect-adblock-on-my-website
# ads.js
var canRunAds = true;
# site template after <body>
<script>
if( window.canRunAds === undefined ){
// adblocker detected, show fallback
@elvisciotti
elvisciotti / 01 - student.ts - source
Last active March 6, 2019 12:57
typscript class and interface compile example
class Student {
fullName: string;
constructor(public firstName: string, public middleInitial: string, public lastName: string) {
this.fullName = firstName + " " + middleInitial + " " + lastName;
}
}
interface Person {
firstName: string;
lastName: string;
@elvisciotti
elvisciotti / launch.sh
Last active August 14, 2022 06:37
Python sample script to import not-normalised CSV data into MySQL tables, resolving FK values in memory
# create mysql_latest container
docker run --name mysql57_abc \
-e MYSQL_ROOT_PASSWORD=pass \
-e MYSQL_DATABASE=abc \
-e MYSQL_USER=abc \
-e MYSQL_PASSWORD=abc \
-p 3306:3306 \
-d mysql:5.7
# launch if already created
docker start mysql57_abc
@elvisciotti
elvisciotti / dockertags.sh
Last active August 14, 2022 06:36
Script to fetch docker tags for an image e.g. "dockertags busybox cli"
#!/bin/bash
if [ $# -lt 1 ]
then
cat << HELP
dockertags -- list all tags for a Docker image on a remote registry.
EXAMPLE:
- list all tags for ubuntu:
@elvisciotti
elvisciotti / README.md
Created May 8, 2020 22:29 — forked from astamicu/Remove videos from Youtube Watch Later playlist.md
Script to remove all videos from Youtube Watch Later playlist

UPDATE 17.10.2019

Only works on old youtube skin.

//added "&disable_polymer=true" after playlist link

Also, saw this now, there is a "remove watched" button.

  1. Open your watch later playlist on youtube.
  2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )