Skip to content

Instantly share code, notes, and snippets.

View patriciogonzalezvivo's full-sized avatar

Patricio Gonzalez Vivo patriciogonzalezvivo

View GitHub Profile
@patriciogonzalezvivo
patriciogonzalezvivo / dd.md
Last active August 29, 2015 14:01
DiskImage Backup and restore

Backup

diskutil list
sudo dd if=/dev/disk1 of=~/Desktop/diskImg.dmg

Restore

@patriciogonzalezvivo
patriciogonzalezvivo / php-webhook-script.md
Last active August 29, 2015 14:03
Highly insecure way to auto update a repo in a website using WebHooks
<?php
{
    $output = shell_exec("cd /var/www/html/; git pull origin master;");
    echo "<pre>$output</pre>";
}
die("done " . mktime());
?>

First :

git submodule add ...

Then:

git clone ...
git pull && git submodule init && git submodule update && git submodule status
git submodule foreach git checkout master

Simple Quad

glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
glTexCoord2f(width, 0); glVertex3f(width, 0, 0);
glTexCoord2f(width, height); glVertex3f(width, height, 0);
glTexCoord2f(0,height);  glVertex3f(0,height, 0);
glEnd();
@patriciogonzalezvivo
patriciogonzalezvivo / ubuntu.md
Last active August 29, 2015 14:19
Ubuntu post-installs

Sysadmin

sudo apt-get install nmap iptraf tcpdump dstat ngrep mtr nc lftp irssi iotop

IDE station

sudo apt-get install git-core tmux mc htop vim zsh lsof
// Author: @patriciogv ( patricio.io )
#include <stdio.h> // standard input / output functions
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string.h> // string function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
@patriciogonzalezvivo
patriciogonzalezvivo / AutoReLoad Scrip
Created April 27, 2013 15:24
Re loads an app after it crash
#!/bin/sh
while : ;
do /path/app;
sleep 30;
done
@patriciogonzalezvivo
patriciogonzalezvivo / SmoothEdgeApp.md
Last active December 16, 2015 17:59
Smooth edges on OSX
ofAppGlutWindow window;
#if defined (TARGET_OSX) 
window.setGlutDisplayString("rgba double samples>=4 depth"); 
#endif

ofSetupOpenGL(&window, 1280,1024, OF_WINDOW);
@patriciogonzalezvivo
patriciogonzalezvivo / csv.md
Last active December 27, 2015 19:39
Reading a CSV on OF
ofBuffer buffer = ofBufferFromFile(_file);

while(!buffer.isLastLine()) {
	string temp = buffer.getNextLine();
        
    if(temp.length() != 0) {
        vector<string> values = ofSplitString(temp, ",");
            
 // ofToInt(value[0]);
@patriciogonzalezvivo
patriciogonzalezvivo / tripMaker.py
Last active May 13, 2016 15:11
Make a GeoJson line from point A to point B using mapzen's Valhalla routing engine
#!/usr/bin/env python
import requests, json, sys
import geojson
#six degrees of precision in valhalla
inv = 1.0 / 1e6;
#decode an encoded string
def decode(encoded):