Skip to content

Instantly share code, notes, and snippets.

@atika
atika / checkisup
Created April 4, 2015 10:01
Check until host is up using PING
# Check until host is UP
checkisup () { while (true) do if ping -t 2 -c 1 $1 &>/dev/null; then echo -e " $(date +%T) \\033[1;36m Host $1 is up! \\033[0m\n $(ping -c 1 $1 | head -n2 | tail -n1)"; return 0; else echo -e " $(date +%T) \\033[31m Host $1 is down...\\033[0m"; sleep 1; fi; done; }
@atika
atika / split_quicktime_movie.scpt
Created May 22, 2015 10:15
Split a QuickTime video in multiple part (set cut mark in seconds)
# Split and export a QuickTime Movie
# Create a folder "exports" on the desktop
# Open one movie file in QuickTime
# Configure where you want to cut the video, if you want first and last part and the QuickTime window name (after modification)
# Launch this script and wait
#------------- BEGIN OF CONFIGURATION --------
-- Middle Mark : Set where you want to cut the video (in seconds)
@atika
atika / pushover
Last active October 20, 2023 19:37
Send a pushover notification from Bash
#!/bin/bash
# ./pushover.sh -t "Pushover via Bash" -m "Pushover message sent with bash from $(hostname -f)" -p1 -s siren -u http://www.google.com -n "Google"
USER_TOKEN=YOUR_USER_TOKEN_HERE
# YOUR APPS TOKENS / UPPERCASE NAME WITH _TOKEN (usage: "-a monitor" uses MONITOR_TOKEN)
MONITOR_TOKEN=APP_TOKEN
BACKUP_TOKEN=APP_TOKEN
ALERT_TOKEN=APP_TOKEN
APP_LIST="monitor, backup, alert" # FOR USAGE
@atika
atika / github-open-url.sh
Created October 21, 2015 08:34
Alias to open a GitHub URL from a Git Repo
github-open-url='git remote -v | grep fetch | grep -oE '\''https://github.com/\S+'\'' | xargs -I{} open {}'
@atika
atika / LaunchBar-Theme-Arguments.txt
Last active July 6, 2023 08:40
A non exhaustive list of LaunchBar theme arguments, extracted with grep from bundled themes, to make your custom themes.
defaultBoldFontName
defaultDimmedTextColor
defaultEmphasizedFontName
defaultFontName
defaultSelectedTextShadowColor@1x
defaultSelectedTextShadowColor@2x
defaultShadowOffset
defaultTextColor
defaultTextShadowColor
defaultTextShadowColor@2x
@atika
atika / verify_programs.sh
Last active October 22, 2018 04:19
Verify if programs exits on system before executing a shell script
verify_programs() {
local programs="$1"
local ccyan="\\033[1;36m"
local cnormal="\\0033[0;39m"
abort=0
for p in $programs; do
type $p >/dev/null 2>&1 || { echo -e >&2 " ${ccyan}${p}${cnormal} required but it's not installed. Aborting."; abort=1; }
done
if [[ $abort -eq 1 ]]; then
exit 1;
@atika
atika / alias_stats.txt
Last active April 9, 2016 14:56
Statistics of shell aliases usage and optional search for a specific command (change to .bash_history for Bash Shell)
alias_stats() {
local search="$1"
list=""; for c in $(alias | grep "$search" | cut -d'=' -f1); do count=$(grep -Ec ";$c" ~/.zsh_history); list="${list}\n${count} ${c}"; done; echo -e $list | sort -n | grep -Ev "^0"
}
@atika
atika / generate_nginx_vhosts_puphpet.php
Last active January 15, 2016 12:36
Generate Vagrant/PuPHPet Nginx vhosts configuration for multiples sites
<?php
$websites = [
["uid" => "mywebsite01", "name" => "mywebsite01.dev", "alias"=>"www.mywebsite01.dev", "root" => "/var/www/mywebsite01/www"],
["uid" => "mywebsite02", "name" => "mywebsite02.dev", "alias"=>"", "root" => "/var/www/mywebsite02/www"]
];
$template =
" nxv__UID_:
@atika
atika / FloatToDecimalStringExtension.swift
Last active March 10, 2016 09:50
Format a float value with desired numbers after the comma to a string. Doesn't display the comma if the number is a round value.
// Format a float value with desired numbers after the comma to a string. Doesn't display the comma if the number is a round value.
import Foundation
extension Double {
func toDecimalString(decimals: Int = 0) -> String {
let format = (self % 1 > 0 && decimals > 0) ? "%.\(decimals)f" : "%.0f"
return String(format:format, self)
}
@atika
atika / SecondsToDaysHoursMinutesSeconds.swift
Created March 10, 2016 09:55
Convert seconds to days, hours, minutes, seconds in Swift
let seconds = 86400*4 + 3600*2 + 65
print(String((seconds / 86400)) + " days")
print(String((seconds % 86400) / 3600) + " hours")
print(String((seconds % 3600) / 60) + " minutes")
print(String((seconds % 3600) % 60) + " seconds")