This file contains 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
#!/usr/bin/env python2 | |
# just give this script a document id (as in `$ python get_wordcloud.py 1`, for example) | |
# and it will download the wordcloud from PyPLN. | |
# | |
# Replace PYPLN_URL by the desired host. | |
import base64 | |
import sys | |
import pypln.api |
This file contains 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
#!/usr/bin/env python3 | |
import json | |
def get_session_from_file(filename): | |
with open(filename, 'r') as fp: | |
session = json.load(fp) | |
return session | |
def get_tabs_from_session(session): | |
return session['windows'][0]['tabs'] |
This file contains 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
[2015-06-25 18:20:55,521: ERROR/MainProcess] Task pypln.backend.workers.elastic_indexer.ElasticIndexer[76b5682a-660b-480f-b533-48f619246362] raised unexpected: SerializationError({u'mimetype': 'application/pdf', u'upload_date': datetime.datetime(2015, 6, 25, 16, 20, 54, 169000), u'forced_decoding': False, u'language': 'un', u'text': u'This is a minimal pdf.\n1', u'filename': u'minimal_pdf.pdf_1435249254.17', u'length': 12876, u'file_id': '558c2a66798ebd634b0b249f', u'file_metadata': {'UserProperties': 'no', 'Tagged': 'no', 'Form': 'none', 'Producer': 'pdfTeX-1.40.15', 'Creator': 'TeX', 'Encrypted': 'no', 'JavaScript': 'no', 'Suspects': 'no', 'Optimized': 'no', 'PDF version': '1.5', 'ModDate': 'Thu Jun 25 18:17:25 2015', 'Page size': '612 x 792 pts (letter)', 'CreationDate': 'Thu Jun 25 18:17:25 2015', 'Pages': '1', 'Page rot': '0'}, u'contents': '%PDF-1.5\n%\xd0\xd4\xc5\xd8\n3 0 obj\n<<\n/Length 105 \n/Filter /FlateDecode\n>>\nstream\nx\xda%\x8c\xbb\n\x800\x0c\x00\xf7~E\xc6vh$\xe9{\x15tp\xce&\x0e\x82\x8 |
This file contains 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 glob | |
from celery import Celery | |
import pymongo | |
import pypln.api | |
import settings | |
app = Celery('tasks', backend="mongodb") | |
client = pymongo.MongoClient() | |
database = client["send_to_pypln"] |
This file contains 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
int ledPin = 13; | |
int fib(int n){ | |
return (n <= 1) ? 1 : (fib(n-1) + fib(n-2)); | |
} | |
void blink(int interval){ | |
digitalWrite(ledPin, HIGH); | |
delay(interval); | |
digitalWrite(ledPin, LOW); |
This file contains 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
# Implementation of the sieve of Eratostenes. | |
# Calculates all the prime numbers in a range up to the specified limit. | |
import math | |
import sys | |
def process(squareRoot, list): | |
"""This function calculates all the prime numbers in a range (from 2 to the | |
limit you specify). | |
Takes as arguments: | |
squareRoot - the square root of the highest number rounded down |
This file contains 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
#!/usr/bin/python | |
import math | |
import sys | |
def is_prime(n): | |
""" | |
Tells if a number is a prime | |
This uses the fact that prime numbers greater than 2 and 3 can always | |
be written in the form 6k+1 or 6k-1. That is, they are always 'next' |
This file contains 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
#!/usr/bin/python3 | |
#-*- coding: utf-8 -*- | |
import sys | |
import re | |
import urllib.request | |
from html.parser import HTMLParser | |
def usage(): | |
sys.stderr.write("usage: {0} <url>\n".format(sys.argv[0])) |
This file contains 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
find . -type d | while read DIR | |
do | |
echo "$DIR" | |
find "$DIR" -maxdepth 1 -type f -exec wc -l {} \; | awk '{loc += $1} END {print loc}' | |
done |
OlderNewer