Skip to content

Instantly share code, notes, and snippets.

View cbertelegni's full-sized avatar

Cristian Bertelegni cbertelegni

View GitHub Profile
@cbertelegni
cbertelegni / README.md
Last active December 25, 2015 00:39
Este es el modelo del json que se va a poder descargar desde la app.

Modelo de datos DDJJ

@cbertelegni
cbertelegni / README.md
Last active August 29, 2015 13:56
Merge entre objetos Javascript // obj_merge

Function Javascript to make merges between two or more objects

Example:

html

In <head> put this script.

``

jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@cbertelegni
cbertelegni / cookies.js
Created August 4, 2014 20:28
Get and Set Cookies.
/*
Get and Set Cookies.
http://jquery-howto.blogspot.com.ar/2010/09/jquery-cookies-getsetdelete-plugin.html
*/
function setCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
@cbertelegni
cbertelegni / README.md
Created September 30, 2014 22:21
Extend Array prototype for export to csv.

Extend Array prototype for export to csv.

Example:

var a = [];
a.push(["Nombre", "Apellido", "Edad"]);
a.push(["Juan", "Lopez", 35]);
a.push(["Gas", "De la Llana", 32]);
a.push(["Cristian", "Bertelegni", 33]);
@cbertelegni
cbertelegni / fabfile.py
Created November 11, 2014 17:40
example fabfile.py
from fabric.api import *
from fabric.colors import green, red
env.hosts = [ 'localhost']
def deploy():
path = "/path/to/root/app/"
print(red("Beginning Deploy:"))
@cbertelegni
cbertelegni / models.py
Created November 20, 2014 20:38
ejemplo de como queda el inspectdb de django
class Bien(models.Model):
# id = models.IntegerField(primary_key=True) # AutoField?
# tipo_bien_id = models.IntegerField(blank=True, null=True)
# nombre_bien_id = models.IntegerField(blank=True, null=True)
tipo_bien_s = models.CharField(max_length=255, blank=True)
nombre_bien_s = models.CharField(max_length=255, blank=True)
descripcion = models.CharField(max_length=255, blank=True)
direccion = models.CharField(max_length=255, blank=True)
barrio = models.CharField(max_length=255, blank=True)
localidad = models.CharField(max_length=255, blank=True)
@cbertelegni
cbertelegni / search_twitter.php
Created January 26, 2015 18:50
Search de twitter con php. Usando la libreria : TwitterAPIExchange
<?php
ini_set('display_errors', 1);
require_once('lib/TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
require "conf.php";
define("LAST_METADATA_SEARCH_FILE", "app/data/last_metadata_search.txt");
define("TUITS_FILE", "app/data/tuits_nisman.txt");
@cbertelegni
cbertelegni / search_twitter.py
Created January 26, 2015 18:59
Search all results and save into file.
#!/usr/bin/python
from twitter import * # need install twitter.py: `pip install twitter`
import json
import time
from urlparse import urlparse, parse_qs
"""SETTINGS"""
from twitter_keys import OAUTH_TOKEN, OAUTH_SECRET, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET
@cbertelegni
cbertelegni / csv_to_json.py
Last active August 29, 2015 14:14
Export with Python a json from csv file.
#! python
import csv, json
path = "app/data"
csv_path = "%s/nisman.csv" % path
data_out_path = "%s/data.json" % path
reader = csv.DictReader(open(csv_path))