Skip to content

Instantly share code, notes, and snippets.

@sergiobuj
sergiobuj / gist:8962775
Created February 12, 2014 19:29
Clusterpy loves Matplotlib
{
"metadata": {
"name": "clusterpy loves matplotlib"
},
"nbformat": 2,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sergiobuj
sergiobuj / README.md
Last active August 29, 2015 14:01
Working vagrant base box with python dev tools included.

Create custom Vagrant base boxes

About ipyvmbase:

  • Debian 7.5
  • build-essentials and git
  • ipython notebook
  • numpy
  • scipy
  • matplotlib
  • pandas
@sergiobuj
sergiobuj / clusterpysal.ipynb
Last active August 29, 2015 14:02
What if we could use [the amazing] Clusterpy on top of Pysal?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sergiobuj
sergiobuj / solution_for_gs.py
Last active August 29, 2015 14:04
New graph from the SCC
## Tarjan implementation from Wikipedia's pseudocode
def tarjan(graph):
#input: graph G = (V, E)
#output: set of strongly connected components (sets of vertices)
n = len(graph)
sccs = []
index = [0]
indexes = [-1] * n
lows = [float('Inf')] * n
S = []
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sergiobuj
sergiobuj / Palindromize
Created April 5, 2010 03:32
Topcoder problem
Palidromized topcoder
string minAdds(string s) {
string res,a,b,aux;
a=s;b=s;
aux=s;
reverse(aux.begin(),aux.end());
if(s == aux)
return s;
@sergiobuj
sergiobuj / TopCoder emacs tc cc func
Created April 9, 2010 23:18
Function to compile and run g++ Topcoder problems
;; TopCoder .cc compile function. (When using .cpp change -3 -> -4 -two times-)
(defun tc () (interactive)
(compile (concat "g++ " (buffer-name)" -Wall -g -o "(substring (buffer-name) 0 -3)" && ./"(substring (buffer-name) 0 -3)))
)
@sergiobuj
sergiobuj / CC
Created April 22, 2010 03:35
Simple terminal animation in C
// Sergio Botero
// Status:
#include <cstdio>
#include <string>
int main (){
while( 1 ){
for(int i = 0; i < 25; usleep(30000), printf("%s+%s+%s\r", std::string(i++, ' ').c_str(), std::string( 50-(2*i) , ' ').c_str(), std::string(i, ' ').c_str())) fflush(stdout);
for(int i = 25; i >= 0; usleep(30000), printf("%s+%s+%s\r", std::string(i--, ' ').c_str(), std::string( 50-(2*i) , ' ').c_str(), std::string(i, ' ').c_str())) fflush(stdout);