Skip to content

Instantly share code, notes, and snippets.

View versae's full-sized avatar

Javier de la Rosa versae

View GitHub Profile
@versae
versae / mirror_gephi_graph.py
Created April 26, 2011 15:29
Mirroring by symmetry on axe X (reflection) of a graph in Gephi Script Console
for node in getGraph().nodes:
x, y = getPos(node)
setPos(node, -x, y)
@versae
versae / gist:1381161
Created November 20, 2011 23:36
Parse manifesto files to get positive and negative sentiment.
#!/usr/bin/python
import urllib
import requests
party = "name_of_the_party"
lines = []
for line in open("programa-%s.txt" % party , "r"):
l = line.strip()
try:
int(l)
@versae
versae / gist:1381199
Created November 20, 2011 23:54
Convert JSON files from ViralHeat API into CSV's files
# -*-*- coding: utf-8 -*-
import codecs
import csv
from StringIO import StringIO
from json import loads
# Taken from http://docs.python.org/library/csv.html#csv-examples
class UnicodeWriter(object):
@versae
versae / twitterdino.pde
Created January 30, 2012 02:41
Send the last tweet and sentiment about the message to Arduino
#define GREEN 8
#define RED 12
const int sepToken = 666;
int val = 0;
int lastVal = 0;
void setup() {
pinMode(GREEN, OUTPUT);
pinMode(RED, OUTPUT);
@versae
versae / setup.sh
Created January 31, 2012 00:20
Setup script for virtual machines templates
#!/bin/bash
# Script to add a user to Linux system
# -------------------------------------------------------------------------
read -p "Enter username: " username
read -s -p "Enter password: " password
echo ""
sudo egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
@versae
versae / projectenv.conf
Last active September 30, 2015 05:48
Script to setup an account for cloned template virtual machines with Nginx and uWsgi
server {
listen 80;
#server_name yourdomain.com;
access_log /home/template/log/access.log;
error_log /home/template/log/error.log;
location /static/admin {
alias /home/template/.virtualenvs/projectenv/lib/python2.7/site-packages/django/contrib/admin/media/;
}
location /static {
@versae
versae / fiber_image_signal.py
Created February 14, 2012 00:42
Signal to resize uploaded Fiber images as new thumbnailed images
from os import path
from StringIO import StringIO
from PIL import Image as PILImage
from django.core.files.base import ContentFile
from django.db.models.signals import post_save
from django.dispatch import receiver
from fiber.models import Image
@versae
versae / traversals.py
Created February 26, 2012 16:32 — forked from theladyjaye/traversals.py
Neo4j REST Traversals Approximating embedded syntax for https://github.com/versae/neo4j-rest-client/
# http://docs.neo4j.org/chunked/snapshot/rest-api-traverse.html#rest-api-traversal-returning-nodes-below-a-certain-depth
try:
import simplejson as json
except ImportError:
import json
from neo4jrestclient import client
from neo4jrestclient.request import Request
from neo4jrestclient.request import NotFoundError
@versae
versae / gist:3908447
Created October 17, 2012 21:42
Return the nobmre of nodes for Gython scripting in Gephi
def nodes_length():
return len(g.nodes)
@versae
versae / neighbors.py
Created October 21, 2012 00:18
Neighbors function : problematic
def find_neighbors(n, v, visited=set()):
"""
Finds a node's neighbors to n degrees of seperation.
Param n: degrees of seperation. n > 1
v: node id
Return: a list of neighbors to the nth degree with no duplicates or 'NoneType'
"""
neighbors = set(v.neighbors)