Skip to content

Instantly share code, notes, and snippets.

### http://www.habnabit.org/twistedex.html
### http://stackoverflow.com/questions/9014630/my-python-twisted-irc-bot-responding-to-commands
import sys
import lxml.html
from twisted.internet import reactor, task, defer, protocol
from twisted.python import log
from twisted.words.protocols import irc
from twisted.web.client import getPage
from twisted.application import internet, service
else: # file has to be deleted
# get the file path by getting it from the query (e.g. '?f=filename.here')
filepath = os.path.join(temp_path, request.GET["f"])
# make sure file exists
# if not return error
if not os.path.isfile(filepath):
return HttpResponseBadRequest("File does not exist")
@esacteksab
esacteksab / gist:2995997
Created June 26, 2012 14:09
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
os.listdir(os.path.join(settings.MEDIA_ROOT, "images"))
url(r'^adm/page/$', ListView.as_view(
model=Page,
template_name="adm-pages.html")),
url(r'adm/page/add/$', CreateView.as_view(
model=Page,
form_class=PageForm,
success_url=('/adm/page'),
template_name="adm-page.html"),
name="createPage"),
url(r'^adm/page/edit/(?P<pk>\d+)/$', UpdateView.as_view(
$ sudo add-apt-repository ppa:nginx/stable -y
$ sudo add-apt-repository ppa:uwsgi/release -y
$ sudo apt-get update
$ sudo apt-get install python-software-properties python2.7-dev libjpeg62 libjpeg62-dev zlib1g zlib1g-dev nginx uwsgi uwsgi-plugin-python uwsgi-plugin-http -y
$ sudo apt-get dist-upgrade -y
https://github.com/esacteksab/conf-files/blob/master/django-uwsgi.ini
https://github.com/esacteksab/conf-files/blob/master/nginx-django-sockets.conf
https://github.com/esacteksab/conf-files/blob/master/uwsgi.conf
@esacteksab
esacteksab / gist:3844939
Created October 6, 2012 13:27
Why VDI Fails
tl;dr
VDI is a buzzword.
Why VDI Fails:
1) Executive/Director/Manager goes to conference,
hears everyone talking about VDI. Comes back, "we need VDI,
VDI is the future, let's get on this train!"
@esacteksab
esacteksab / gist:3998227
Created November 2, 2012 02:07
nginx+uwsgi pef settings
worker_connections are not enough while connecting to upstream
nginx--
worker_processes = 4
worker_connections = 8192
worker_rlimit_nofile 4096
uwsgi --
listen = 4096
system --
net.core.somaxconn = 32768
>>> class A:
... pass
...
>>> class B(object):
... pass
...
>>> class C:
... def __len__(self):
... return 0
...
>>> class A:
... pass
...
>>> class B(object):
... pass
...
>>> class C:
... def __len__(self):
... return 0
...