Skip to content

Instantly share code, notes, and snippets.

View mogetutu's full-sized avatar

Isaak Mogetutu mogetutu

View GitHub Profile
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@mogetutu
mogetutu / csv.export.1.php
Created May 20, 2014 19:56
Larave CSV export
public function get_export()
{
$table = Cpmreport::all();
$file = fopen('file.csv', 'w');
foreach ($table as $row) {
fputcsv($file, $row->to_array());
}
fclose($file);
return Redirect::to('consolidated');
}
class ArrayToXML
{
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
* @return string XML
@mogetutu
mogetutu / replace.sql
Last active August 29, 2015 14:01
replace string-part in mysql
UPDATE table SET fieldname=REPLACE(fieldname, 'MB', '')
@mogetutu
mogetutu / gwijie.sh
Created June 9, 2014 11:26
Meteor Quick Script
$ curl https://install.meteor.com | /bin/sh
$ meteor create ~/my_cool_app
$ cd ~/my_cool_app
$ subl .
@mogetutu
mogetutu / fix_mysql_osx.sh
Created June 17, 2014 18:53
Fix mysql permission on OS X
sudo chown -R mysql /usr/local/mysql/data/
@mogetutu
mogetutu / database.php
Last active August 29, 2015 14:02
database_Question
<?php
/**
* Database Query Result Set
* @param string $query SQL Statement eg "SELECT * FROM students"
* @return array array from database result
*/
public function db_query($query)
{
// Run the $query using $this->connection() which
// is the database connection in the previous function
@mogetutu
mogetutu / index.html
Created June 26, 2014 13:20
ajax with class changing
<!DOCTYPE html>
<html>
<head>
<title>Brck</title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
setInterval(function(){
$.ajax({ url: "http://localhost:9000/sim.php", success: function(data){
//Update your dashboard gauge
console.log(data);
/* Taken zigmob's (http://forums.macrumors.com/showthread.php?t=1742566) workaround a step further
And added some triggers to clean up these dodgy character combinations (ff, fi, fl).
Still crashes on initial message read but saves having to manually run the sql query eve time a message contains the character combinations */
-- Working well for me so far --
/*
Kane Lai 2014-07-13
Improved by updating only the affected row in the trigger.
Also, supplied the restore script too.
*/
@mogetutu
mogetutu / .vimrc
Last active August 29, 2015 14:06 — forked from JeffreyWay/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15