Skip to content

Instantly share code, notes, and snippets.

View vortec's full-sized avatar

Fabian Kochem vortec

View GitHub Profile
@vortec
vortec / gist:5378491
Created April 13, 2013 13:52
How to recursively unzip a file in Objective C using ZipZap. self.course_data is a NSData object that holds the zip file, coming from a NSURLConnection callback. This is stuff you can ignore.
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
self.progressLabel.text = @"Unpacking...";
connection = nil;
// Save to disk, release memory
NSString *temp_file_path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"/temp.zip"];
[self.course_data writeToFile:temp_file_path atomically:YES];
self.course_data = nil;
// Unzip
fkochem at WK-6 in ~/workspace/code/sentry/bin exited 1 workon sentry
$ ./sentry --config=/home/fkochem/.sentry/sentry.conf.py createsuperuser
Traceback (most recent call last):
File "./sentry", line 9, in <module>
load_entry_point('sentry==5.4.1', 'console_scripts', 'sentry')()
File "/home/fkochem/workspace/code/sentry/local/lib/python2.7/site-packages/sentry/utils/runner.py", line 191, in main
initializer=initialize_app,
File "/home/fkochem/workspace/code/sentry/local/lib/python2.7/site-packages/logan/runner.py", line 155, in run_app
management.execute_from_command_line([runner_name, command] + command_args)
File "/home/fkochem/workspace/code/sentry/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
@vortec
vortec / gist:4709504
Created February 4, 2013 20:31
.strftime('%s') is locale-aware
from pytz import timezone
from datetime import datetime
# From http://en.wikipedia.org/wiki/Eastern_Time_Zone
# "Places that use Eastern Standard Time (EST) when observing standard time (autumn/winter)
# are 5 hours behind Coordinated Universal Time (UTC−05:00)."
us = timezone('US/Eastern')
# GMT during the winter is exactly UTC if I'm not mistaken
uk = timezone('Europe/London')
# BeautifulSoup 3.2.0
>>> from BeautifulSoup import BeautifulSoup, CData
>>> s = BeautifulSoup("<div></div>")
>>> n = s.find('div')
>>> n.append(CData('<b>bleh</b>'))
>>> n
<div><![CDATA[<b>bleh</b>]]></div>
>>>
-------------
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from BeautifulSoup import BeautifulSoup, Tag, CData
>>> s=BeautifulSoup("")
>>> s=BeautifulSoup("<div></div>")
>>> n=s.find('div')
>>> n
<div></div>
>>> n.append(CData('<b>bleh</b>'))
FK-MBP:Debug fabian$ mono test2.exe
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.gui.QApplication ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.core.QCoreApplication ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.core.QObject ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.QtJambiObject ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.QtJambi_LibraryInitializer ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.Utilities ---> System.TypeLoadException: A type load exception has occurred.
at com.trolltech.qt.Utilities..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at com.trolltech
from pdb import set_trace
def wrap1(name):
print('wrap 1: {}'.format(str(locals())))
def inner(): ## no reference to name in inner function
set_trace()
inner()
def wrap2(name):
beep -f 659 -l 460 -n -f 784 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 880 -l 230 -n -f 659 -l 230 -n -f 587 -l 230 -n -f 659 -l 460 -n -f 988 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 1047-l 230 -n -f 988 -l 230 -n -f 784 -l 230 -n -f 659 -l 230 -n -f 988 -l 230 -n -f 1318 -l 230 -n -f 659 -l 110 -n -f 587 -l 230 -n -f 587 -l 110 -n -f 494 -l 230 -n -f 740 -l 230 -n -f 659 -l 460
<html>
<head>
<title>HTML5 File example</title>
<STYLE TYPE="text/css">
<!--
TD{font-family: Arial, Helvetica, sans-serif; font-size: 8pt;}
--->
</STYLE>
drwx------ 2 www-data root 4096 Sep 7 15:55 nginx-cache
drwx------ 2 www-data root 4096 Sep 7 15:55 nginx-temp