Skip to content

Instantly share code, notes, and snippets.

View nathanmac's full-sized avatar

Nathan Macnamara nathanmac

View GitHub Profile
var request = require("request");
var options = {
method: 'GET',
url: 'https://api.meltwater.com/v1/analytics/8285607',
qs: {
start: '2019-09-10T10:00:00',
end: '2019-09-11T10:00:00',
tz: 'America/Los_Angeles',
source: 'twitter'
@nathanmac
nathanmac / db-debug.php
Last active December 6, 2018 17:12
db debugging lines for lumen
\DB::listen(function($sql) {
if ($sql instanceof Illuminate\Database\Events\QueryExecuted) {
\Log::info($sql->sql);
\Log::info(json_encode($sql->bindings));
}
});
DB::listen(
function ($query) {
Log::info($query->sql);
@nathanmac
nathanmac / countries.php
Created November 30, 2015 11:43
Countries Class
<?php
namespace Acme\Utils;
class Countries
{
/**
* List of all countries
*
* @var array
@nathanmac
nathanmac / logstash.sh
Created September 5, 2015 21:26
Installing Logstash
#!/usr/bin/env bash
echo ">>> Installing Logstash"
# Set some variables
LOGSTASH_VERSION=1.5.4-1_all # Check https://www.elastic.co/downloads/logstash for latest version
# Install prerequisite: Java
# -qq implies -y --force-yes
sudo apt-get update
@nathanmac
nathanmac / kibana.sh
Created September 1, 2015 10:24
Installing Kibana
#!/usr/bin/env bash
echo ">>> Installing Kibana"
# Set some variables
KIBANA_VERSION=4.1.1 # Check https://www.elastic.co/downloads/kibana for latest version
sudo mkdir -p /opt/kibana
wget --quiet https://download.elastic.co/kibana/kibana/kibana-$KIBANA_VERSION-linux-x64.tar.gz
sudo tar xvf kibana-$KIBANA_VERSION-linux-x64.tar.gz -C /opt/kibana --strip-components=1
@nathanmac
nathanmac / progress.py
Last active August 29, 2015 14:12
ProgressBar Display
def updateProgress(position, total = 100, length = 10):
progress = int((position/float(total))*100)
print '\r[{0}] {1}%'.format('#'*(progress/length), progress)
@nathanmac
nathanmac / ObjectToArray.php
Created July 31, 2014 15:48
Convert an object to an array recursively
<?php
/**
* Convert an object to and array recursively
*
* @param Object $object Object to be converted to an array
*
* @return array
*/
private function _objectToArray($object)
{
@nathanmac
nathanmac / LAMP-Setup.sh
Last active August 29, 2015 14:04
LAMP Stack
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@nathanmac
nathanmac / install-mailcatcher.sh
Last active August 29, 2015 14:03
Install MailCatcher Ubuntu Vagrant - Section from Vagrant install.sh file
# Install MailCatcher (Vagrant)
# Install RVM (ruby)
sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh
env | grep rvm
\curl -L https://get.rvm.io | bash -s stable --ruby --autolibs=enable --auto-dotfiles --gems=mailcatcher
source /usr/local/rvm/scripts/rvm
# Start Mailcatcher for testing email
@nathanmac
nathanmac / .bash_profile
Created August 27, 2015 08:41
Serve Function
function serve()
{
if [ -z $1 ]; then port=9999 else port=$1 fi
echo "----------------- Starting Server -----------------";
php -S localhost:$port;
}