This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymongo | |
import logging | |
import sys | |
from sqlalchemy.exc import IntegrityError | |
from pymongo import MongoClient | |
from tweeply.models import TweeplyMessage, Credential, User, Database | |
from tweeply.utils import update_config | |
logging.basicConfig() | |
logger = logging.getLogger(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# \r is carriage return, writes the following text to the beginning of the line | |
sys.stdout.write('\r<And your message>') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*) AS C, payload->'retweeted_status'->>'id' AS cat, payload->'retweeted_status'->>'text' AS Tweet FROM messages WHERE jsonb_typeof(payload) = 'object' and payload->>'text' not like '%http%' GROUP BY cat, Tweet ORDER BY C DESC; | |
# Works just fine | |
SELECT count(*) AS C, payload->'retweeted_status'->>'id' AS cat, payload->'retweeted_status'->>'text' AS Tweet, payload->'retweeted_status'->'User'->>'screen_name' AS User FROM messages WHERE jsonb_typeof(payload) = 'object' and payload->>'text' not like '%http%' GROUP BY cat, Tweet, User ORDER BY C DESC; | |
# Doesn't work | |
# ------------ | |
# ERROR: column "messages.payload" must appear in the GROUP BY clause or be used in an aggregate function | |
# LINE 1: ...t, payload->'retweeted_status'->>'text' AS Tweet, payload->'... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alter table t alter column j type jsonb using j::text::jsonb; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 }}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]: |