Skip to content

Instantly share code, notes, and snippets.

View balkian's full-sized avatar
🏠
Working from home

J. Fernando Sánchez balkian

🏠
Working from home
View GitHub Profile
@balkian
balkian / checkdic.py
Last active August 29, 2015 14:16
Check if key and value from template are present in indic
def check_dict(indic, template):
return all(item in indic.items() for item in template.items())
@balkian
balkian / setup.py
Created March 13, 2015 22:25
Load the requirements from requirements.txt into your setup.py
from pip.req import parse_requirements
# parse_requirements() returns generator of pip.req.InstallRequirement objects
install_reqs = parse_requirements("requirements.txt")
# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]
@balkian
balkian / copyMongo.js
Last active August 29, 2015 14:17
Copy one collection from a database to another in the same MongoDB
db.<collection_name>.find().forEach(function(d){ db.getSiblingDB('<new_database>')['<collection_name>'].insert(d); });
@balkian
balkian / tweeply.py
Created March 18, 2015 23:25
Python property that mirrors the content of a dictionary. To convenienty add to a subclass of dict and then do: my_object.my_property
class MessageProperty(property):
def __init__(self, path, *args, **kwargs):
property.__init__(self, *args, **kwargs)
self.path = path
def _target(self, dic):
path = self.path
dest = dic
lastkey = path[-1]
for p in path[:-1]:
@balkian
balkian / kemsirve.py
Last active September 19, 2015 12:17
Get a notification when a kemsirve/kimsufi server is available
from __future__ import print_function
import requests
try:
import Tkinter as tk
import tkMessageBox as tkm
except Exception:
import tkinter as tk
from tkinter import messagebox as tkm
@balkian
balkian / Makefile
Last active August 29, 2015 14:17
Some automation to submit to a journal (e.g. Elsevier). It detects the main latex file and eps files used.
# Some automation to submit to a journal (e.g. Elsevier).
# It detects the main latex file and eps files used.
# Author: @balkian
# TODO: Only import the tex files used in the main file, and their images.
AUX_DIR=.aux
LATEX=$(basename $(shell grep -l '\\begin{document' *.tex))
LETTER=letter
COVER=cover
HIGHLIGHTS=highlights
{% set f=open_file("xls") %}
{% set sheet=f.sheet_by_index(0) %}
{% if not baseuri %}
{% set baseuri="default" %}
{% endif %}
{
"@context": [
"http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld",
{
"@base": "{{ baseuri }}",
FROM ubuntu:14.04
RUN apt-get update -y
RUN apt-get install -y curl
RUN apt-get install -y diffstat
RUN apt-get install -y git
RUN apt-get install -y python
RUN apt-get install -y python3
RUN apt-get install -y tmux
RUN apt-get install -y vim
mashable big_picture theonion time breakingnews bbcbreaking espn harvardbiz gizmodo techcrunch wired smashingmag wsj whitehouse rollingstone cnn whitehouse tweetmeme peoplemag foxnews huffingtonpost newsweek slate reuters incmagazine eonline usatoday good gawker msnbc_breaking life latimes telegraphnews abc7 bbc_world washingtonpost msnbc guardiannews
@balkian
balkian / convert
Created April 13, 2015 19:09
convert json to jsonb in postgres
alter table t alter column j type jsonb using j::text::jsonb;