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
# -*- coding: utf-8 -*- | |
import smtplib | |
from email.mime.text import MIMEText | |
from email.header import Header | |
import urllib.request as urllib | |
from bs4 import BeautifulSoup | |
from random import choice | |
def randomWikipediaPage(): |
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 | |
# coding: utf-8 | |
# This launches a webserver listening on HTTP_HOST and a IRC client to display the messages. | |
# Configuration using capital variables below. | |
# Dependencies: Python 3, pypeul (Python 3 branch) | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
from pypeul import IRC, Tags | |
import json |
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 re | |
import unicodedata | |
import difflib | |
import urlparse | |
def slugify(value): | |
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') | |
value = re.sub('[^\w\s-]', '', value).strip().lower() | |
return re.sub('[-\s]+', '-', value) |
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 | |
#-*- encoding: utf-8 -*- | |
# ircbot_url_title.py | |
# Simple bot which displays urls titles | |
# | |
# Copyright (c) 2010 Mick@el and Zopieux | |
# Copyright (c) 2014 gustavi | |
# | |
# This program is free software: you can redistribute it and/or modify |
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
def do_work(i): | |
# do something very time-consuming here | |
print("computing stuff for i =", i) | |
return i < 2 | |
# Test with lists | |
print( all( [ do_work(i) for i in range(6) ] ) ) | |
# computing stuff for i = 0 | |
# computing stuff for i = 1 | |
# computing stuff for i = 2 |
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 python | |
# Usage: python srtko.py <input.srt> <output.txt> | |
from __future__ import print_function | |
try: | |
from itertools import zip_longest | |
except ImportError: | |
from itertools import izip_longest as zip_longest | |
def grouper(iterable, n, fillvalue=None): |
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
def messageToBytes(type, body=None): | |
data = {'type': type} | |
if body is not None: | |
data['body'] = body | |
try: | |
return json.dumps(data).encode('ascii') + b"\n" | |
except ValueError: | |
raise ValueError("message could not be JSON-encoded") | |
except UnicodeEncodeError: | |
raise UnicodeEncodeError("JSON could not be converted to bytes") |
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
# Example with Contacts API | |
import atom.http_core | |
import gdata.contacts.client | |
import gdata.gauth | |
auth_kwargs = { | |
'client_id': 'clielnt-id-xxx.apps.googleusercontent.com', # CHANGEME (see API auth console) | |
'client_secret': 'client-secret-xxx', # CHANGEME (see API auth console) | |
'scope': 'https://www.google.com/m8/feeds', # CHANGEME (see API reference) |
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
In - line 15: | |
TEXTDOMAIN='pacaur' | |
^-- SC2034: TEXTDOMAIN appears unused. Verify it or export it. | |
In - line 16: | |
TEXTDOMAINDIR='/usr/share/locale' | |
^-- SC2034: TEXTDOMAINDIR appears unused. Verify it or export it. |
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
function compress() { | |
this="$0" | |
function usage() { | |
echo "Usage: $this file.{zip,tgz,tbz2,xz,7z,exe} target [target ...]" >&2 | |
} | |
test $# -lt 2 && ( usage; return 1 ) | |
name="$1" | |
shift | |
case "$name" in | |
*.exe) |
OlderNewer