Skip to content

Instantly share code, notes, and snippets.

View Kwpolska's full-sized avatar

Chris Warrick Kwpolska

View GitHub Profile
import codecs
xmlfile = 'xml.xml'
with codecs.open('ancient', 'w', 'iso-8859-2') as finalxml:
with codecs.open(xmlfile, 'r', 'utf-8') as f:
for line in f:
result = robj.sub(lambda m: dict[m.group(0)], line)
result = '\t\t\t' + result
finalxml.write(result.encode('iso-8859-2'))
@Kwpolska
Kwpolska / -
Created February 24, 2014 18:29
try:
with open('filename') as fh:
contents = fh.read()
except IOError as e:
print('stuff went wrong')
print(e)
From 53ee55296e2e23016f9229644bc8dd6a3c2eac92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chris=20=E2=80=9CKwpolska=E2=80=9D=20Warrick?=
<kwpolska@gmail.com>
Date: Thu, 23 Jan 2014 19:07:26 +0100
Subject: [PATCH] Add an install_bs3 command for Debian.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
[uwsgi]
emperor = true
socket = 127.0.0.1:3031
stats = 127.0.0.1:3130
chdir = /var/flask/
master = true
threads = 5
binary-path = /var/flask/bin/uwsgi
virtualenv = /var/flask
module = %n
server {
listen 80;
server_name kwpolska.dyndns.org;
root /var/flask/kwlh;
location / { try_files $uri @kwlh; }
location @kwlh {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
diff -ur /home/kwpolska/git/nikola/tests/data/baseline/galleries/demo/rss.xml output/galleries/demo/rss.xml
--- /home/kwpolska/git/nikola/tests/data/baseline/galleries/demo/rss.xml 2014-03-11 17:11:11.768384495 +0100
+++ output/galleries/demo/rss.xml 2014-03-11 17:13:17.564280131 +0100
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
-<rss version="2.0"><channel><title>Nikola Tesla</title><link>http://getnikola.com/galleries/demo/rss.xml</link><description></description><language>en</language><lastBuildDate>Wed, 01 Jan 2014 00:00:00 GMT</lastBuildDate><generator>http://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Tesla conducts lg</title><link>http://getnikola.com/galleries/demo/tesla_conducts_lg.jpg</link><enclosure url="http://getnikola.com/galleries/demo/tesla_conducts_lg.jpg" length="18755" type="image/jpeg"></enclosure><guid isPermaLink="false">galleries/demo/tesla_conducts_lg.jpg</guid><pubDate>Fri, 03 Jan 2014 16:19:12 GMT</pubDate></item>
import os
import sys
import time
pid = os.fork()
if pid == 0:
print('This is the child.')
time.sleep(1)
print('Time to die!')
(nikola-py2)[kwpolska@kw-cassandra n]% pip install git+https://github.com/FedericoCeratto/shoebill.git /tmp/n 1
Downloading/unpacking git+https://github.com/FedericoCeratto/shoebill.git
Cloning https://github.com/FedericoCeratto/shoebill.git to /tmp/pip-FAvqVQ-build
Running setup.py egg_info for package from git+https://github.com/FedericoCeratto/shoebill.git
Downloading/unpacking Beaker>=1.6.3 (from shoebill==0.1)
Downloading Beaker-1.6.4.tar.gz (54kB): 54kB downloaded
Running setup.py egg_info for package Beaker
Requirement already satisfied (use --upgrade to upgrade): Bottle>=0.10.11 in /home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages (from shoebill==0.1)
[kwpolska@kw-cassandra /tmp]% virtualenv3 new-env /tmp 0
Using base prefix '/usr'
New python executable in new-env/bin/python3
Also creating executable in new-env/bin/python
Installing setuptools, pip...done.
[kwpolska@kw-cassandra /tmp]% cd new-env /tmp 0
[kwpolska@kw-cassandra new-env]% source bin/activate /tmp/new-env 0
(new-env)[kwpolska@kw-cassandra ~VIRTUAL_ENV]% python --version
### Use input as formula and create an output of listed table.
### Ex: Input: 5*x ---> Output: 0 5 10 15 20 25
import math
#from sympy import *
from colorama import Fore, Back
def table():
x_min, x_max, formula = raw_input("\n[x_min] [x_max] [formula] = ").split(' ', 2)
print("\n")