Skip to content

Instantly share code, notes, and snippets.

View nicolascb's full-sized avatar
🇵🇸
Working from home

Nicolas Barbosa nicolascb

🇵🇸
Working from home
View GitHub Profile
@nicolascb
nicolascb / sqlite_query.sh
Created March 7, 2018 19:11
SQLite SELECT using shell script
#!/bin/bash
hosts="$(
sqlite3 backup.db \
'select ip from hosts' \
)"
for host in $hosts; do
echo $host
done
@nicolascb
nicolascb / countdaysofmonth.js
Created March 5, 2018 13:49
JavaScript = Count days of month
var getDaysInMonth = function(month,year) {
// Here January is 1 based
// //Day 0 is the last day in the previous month
return new Date(year, month, 0).getDate();
// // Here January is 0 based
// // return new Date(year, month+1, 0).getDate();
};
@nicolascb
nicolascb / getdaysofmonth.php
Created March 5, 2018 13:44
PHP - Get days of month
function GetDaysOfMonth($year, month){
$start_date = "01-".$month."-".$year;
$start_time = strtotime($start_date);
$end_time = strtotime("+1 month", $start_time);
for($i=$start_time; $i<$end_time; $i+=86400) {
$list[] = date('Y-m-d', $i);
}
return $list;
@nicolascb
nicolascb / install_asterisk.sh
Created January 19, 2018 11:13
How to install Asterisk on Ubuntu/Debian - Shellscript
#!/bin/bash
cd /opt/ && wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar -xvzf asterisk-13-current.tar.gz
cd asterisk-13*
apt install build-essential -y
apt install libxml2-dev -y
apt install libncurses5-dev libreadline-dev libreadline6-dev -y
apt install libssl-dev -y
apt install uuid-dev -y
apt install libjansson-dev -y