Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Macnamara nathanmac

View GitHub Profile
View api.js
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 Dec 6, 2018
db debugging lines for lumen
View db-debug.php
\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);
View countries.php
<?php
namespace Acme\Utils;
class Countries
{
/**
* List of all countries
*
* @var array
@nathanmac
nathanmac / logstash.sh
Created Sep 5, 2015
Installing Logstash
View logstash.sh
#!/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 Sep 1, 2015
Installing Kibana
View kibana.sh
#!/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
View .bash_profile
function serve()
{
if [ -z $1 ]; then port=9999 else port=$1 fi
echo "----------------- Starting Server -----------------";
php -S localhost:$port;
}
@nathanmac
nathanmac / progress.py
Last active Aug 29, 2015
ProgressBar Display
View progress.py
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 Jul 31, 2014
Convert an object to an array recursively
View ObjectToArray.php
<?php
/**
* Convert an object to and array recursively
*
* @param Object $object Object to be converted to an array
*
* @return array
*/
private function _objectToArray($object)
{
View LAMP-Setup.sh
#!/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 Aug 29, 2015
Install MailCatcher Ubuntu Vagrant - Section from Vagrant install.sh file
View install-mailcatcher.sh
# 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