Skip to content

Instantly share code, notes, and snippets.

View jsam's full-sized avatar
🦁

sam jsam

🦁
View GitHub Profile
@jsam
jsam / chat example error
Created August 21, 2012 00:07
django-gevent-sockeiot chat example error
Listening on http://127.0.0.1:9001 and on port 843 (flash policy server)
DEPRECATION WARNING: use `namespace` instead of `resource`
FAILED to start flash policy server: [Errno 13] Permission denied: ('0.0.0.0', 843)
Traceback (most recent call last):
File "/home/sam/.virtualenvs/socketio/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 438, in handle_one_response
self.run_application()
File "/home/sam/.virtualenvs/socketio/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 424, in run_application
self.result = self.application(self.environ, self.start_response)
File "/home/sam/.virtualenvs/socketio/src/django/django/core/handlers/wsgi.py", line 239, in __call__
signals.request_finished.send(sender=self.__class__)
@jsam
jsam / django_tornado_handler.py
Created August 21, 2012 13:30 — forked from bdarnell/django_tornado_handler.py
django_tornado_handler.py
# NOTE: This code was extracted from a larger class and has not been
# tested in this form. Caveat emptor.
import django.conf
import django.contrib.auth
import django.core.handlers.wsgi
import django.db
import django.utils.importlib
import httplib
import json
import logging
@jsam
jsam / sg
Created August 22, 2012 03:06
socketio and gevent
Traceback (most recent call last):
File "/home/sam/.virtualenvs/web_chat/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 438, in handle_one_response
self.run_application()
File "/home/sam/.virtualenvs/web_chat/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 425, in run_application
self.process_result()
File "/home/sam/.virtualenvs/web_chat/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 414, in process_result
for data in self.result:
File "sock.py", line 60, in serve_file
with open(path) as fp:
IOError: [Errno 21] Is a directory: '/home/sam/dev/web_chat_test/public'
@jsam
jsam / is it bug
Created August 23, 2012 08:46
gcrack bug?
(gcrack)sam@inflames:/home/sam/dev/github/myprojects/gcrack$ python2.7 gcrack.py testhashes
[+] Hashes loaded, using google_attack to crack them
md5(qwerty) d8578edf8458ce06fbc5bb76a58c5ca4
md5(alkali) f7f41ad5328d528a751c55fa2fcf7273
md5(password09) 8350513a8aff1d5bc1534dbd90747bb8
sha1(security) 8eec7bc461808e0b8a28783d0bec1a3a22eb0821
md5(admin) 21232f297a57a5a743894a0e4a801fc3
sha1(crypto) 44a9713350e53858f058463d4bf7f1e542d9ca4b
[+] Found 6 of 8
@jsam
jsam / help('modules')
Created August 23, 2012 15:36
python gtk2 binding broken
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
from gtk import _gtk
** (python:3139): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
@jsam
jsam / zeromq error
Created August 23, 2012 15:46
zeromq error
>>> import zmq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "zmq.py", line 2, in <module>
from gevent_zeromq import zmq
File "/home/sam/.virtualenvs/gevent/local/lib/python2.7/site-packages/gevent_zeromq/__init__.py", line 23, in <module>
from zmq import devices
ImportError: cannot import name devices
@jsam
jsam / gist:3476043
Created August 26, 2012 08:08
bin search
bool BinSearch( float P[ ], float K, int i, int j )
{
if ( j - i <= 0 )
if ( i == j && P[ i ] == K )
return true;
else
return false;
else
{
int k = ( i + j ) / 2;
@jsam
jsam / bin_search.cpp
Created August 26, 2012 12:07
Binary Search of words
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool BinSearch( string P[], string K, int i, int j )
{
if ( j - i <= 0 )
if ( i == j && P[ i ] == K )
@jsam
jsam / mwha
Created August 27, 2012 11:49
vector remove duplicate template
template<typename T>
void removeDuplicates(std::vector<T>& vec)
{
std::sort(vec.begin(), vec.end());
vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
}
@jsam
jsam / heroku logs --tail
Created September 8, 2012 10:04
heroku log
2012-09-08T09:34:29+00:00 app[web.1]: 2012-09-08 04:34:29 [2] [INFO] Handling signal: term
2012-09-08T09:34:29+00:00 app[web.1]: Traceback (most recent call last):
2012-09-08T09:34:29+00:00 app[web.1]: File "/app/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
2012-09-08T09:34:29+00:00 app[web.1]: result = self._run(*self.args, **self.kwargs)
2012-09-08T09:34:29+00:00 app[web.1]: File "/app/lib/python2.7/site-packages/socketio/virtsocket.py", line 389, in _watcher
2012-09-08T09:34:29+00:00 app[web.1]: File "/app/lib/python2.7/site-packages/gevent/hub.py", line 79, in sleep
2012-09-08T09:34:29+00:00 app[web.1]: gevent.sleep(1.0)
2012-09-08T09:34:29+00:00 app[web.1]: SystemExit: 0
2012-09-08T09:34:29+00:00 app[web.1]: switch_result = get_hub().switch()
2012-09-08T09:34:29+00:00 app[web.1]: <Greenlet at 0x3372730: <bound method Socket._watcher of <socketio.virtsocket.Socket object at 0x34ec9d0>>> failed with SystemExit