Skip to content

Instantly share code, notes, and snippets.

View projectivemotion's full-sized avatar
👽
let's work

Amado Martinez projectivemotion

👽
let's work
View GitHub Profile
@projectivemotion
projectivemotion / flash
Created May 10, 2016 08:00
Flash Terminal Color, Blink Terminal Colors
#!/bin/bash
#
# Author: Amado Martinez - AmadoMartinez.mx
# License: MIT License
# Date: 2016-05-10
#
# Keywords: Flash Terminal Color Shell Color Blink Alert
#
if [ $# -lt 2 ] ; then
@projectivemotion
projectivemotion / i3statusphp
Last active August 10, 2016 12:44
i3 status php wrapper for appending currency rate / bitcoin rate in i3 status bar
#!/usr/bin/env php
<?php
/**
* Author: Amado Martinez
* License: MIT
* Date: 2016-07-22
*
* modify .i3status.conf general section: output_format = "i3bar"
* modify i3 config: status_command i3status -c .i3status.conf | php -f ~/bin/i3statusphp
*
@projectivemotion
projectivemotion / wpbackup.sh
Created August 11, 2016 08:57
Create a full backup of a Wordpress Website in one single step with this bash script.
#!/bin/env bash
#
# Author: Amado Martinez - AmadoMartinez.mx
# License: MIT License
# Date: 2016-08-11
#
# Backup a complete wordpress installation
#
if [ $# -lt 2 ] ; then
@projectivemotion
projectivemotion / i3status.ts
Created August 31, 2016 14:43
Typescript Implementation of a simple node js wrapper which prefixes each i3status line with custom information.
///<reference path="node.d.ts"/>
/**
* Author: Amado Martinez <amadomartinez.mx>
* License: MIT
* Date: 2016-08-31
*
# information. To use it, ensure your ~/.i3status.conf contains this line:
# output_format = "i3bar"
# in the 'general' section.
# Then, in your ~/.i3/config, use:
@projectivemotion
projectivemotion / taskwarrior.js
Last active September 1, 2016 07:48
Example Script to obtain taskwarrior information using node js
/**
* Amado Martinez <amadomartinez.mx>
*
* Example Typescript / Javascript to retrieve taskwarrior data
*/
var execSync = require("child_process").execSync;
var getIds = (filter) => {
let ids = execSync("task " + filter + " _id").toString().split("\n");
ids.pop(); // remove empty line
return ids;
@projectivemotion
projectivemotion / migrate.sh
Created November 2, 2016 05:06
Centos7 Server Migration Script
#!/bin/env bash
#
# Author: Amado Martinez - AmadoMartinez.mx
# License: MIT License
# Date: 2016-11-02
#
# Migrate to CentOS7 Script
# provide newhost argument to transfer data and launch import and init processes to the new machine.
# ssh keys must be setup on remote system.
# use import argument for importing migration data and install services
@projectivemotion
projectivemotion / tinytinyrssdocker.md
Last active November 30, 2016 10:27
Run tiny tiny rss in docker container

Set Up tiny tiny rss in a docker container

Using clue/ttrss image: https://github.com/clue/docker-ttrss

I was having some problem configuring the container using DB_PASS and DB_USER variables. I ended up using DB_ENV_USER and DB_ENV_PASS and was able to get the container up and running;

docker run -d --name ttrssdb -e 'MYSQL_ROOT_PASSWORD=my-secret-pw' mariadb
sleep 20 &amp;&amp; docker run --link ttrssdb:db -p 89:80 -e DB_ENV_USER=root -e DB_ENV_PASS=my-secret-pw -d --name ttrss clue/ttrss
@projectivemotion
projectivemotion / start-service-if-host-unreachable.sh
Created January 11, 2017 10:05
Trigger a systemd service when a host becomes unreachable via ping. Machine can be hostname or ip address.
#!/bin/sh
# add to your crontab?
# 45 * * * * /path/to/start-service-if-host-unreachable.sh
machine="moto"
service="reverse-tunnel"
if [ "$USER" != "root" ] ; then
echo "You are not root. bye."
exit 1;
@projectivemotion
projectivemotion / timewarrior-tags-time-report.sh
Created January 14, 2017 05:21
Create a csv report of how much time was spent on each tag for the current month in TimeWarrior. https://taskwarrior.org/docs/timewarrior/what.html
#!/bin/env bash
# only tags without spaces are counted
#
hash JSON.sh 2>/dev/null || {
echo "https://github.com/dominictarr/JSON.sh is required."
exit 1
}
echo \"Tag\",\"Time\"
timew export :month | JSON.sh | grep -E '\[[0-9]+,"tags",' | cut -f2 | grep -v ' ' | sort | uniq | while read tag ; do
@projectivemotion
projectivemotion / php-unresolved-symlinked-path.php
Last active May 25, 2018 18:45
Get unresolved path of symlinked php file. Does the opposite of realpath().
<?php
/**
* Returns the Symlink (Non-Realpath) of the current script.
* I am not so sure how well this function works from inside include's.
* Use case:
*
* [amado@gravedigger phpcode]$ php -f subdir/mysymlink/subdir/mysymlink/subdir/mysymlink/app.php
* PWD: /tmp/phpcode
* SCRIPT_FILENAME: subdir/mysymlink/subdir/mysymlink/subdir/mysymlink/app.php
* ___FILE__ : /tmp/phpcode/app.php