Skip to content

Instantly share code, notes, and snippets.

@nivir
nivir / gist:100829b8625999143d5c5705cc6dc250
Created November 2, 2016 15:11 — forked from ptigas/gist:2820165
linked list implementation in python
class Node :
def __init__( self, data ) :
self.data = data
self.next = None
self.prev = None
class LinkedList :
def __init__( self ) :
self.head = None
@nivir
nivir / gist:8a145cbba72b921810e08a9f3a527495
Created November 2, 2016 15:44 — forked from ptigas/gist:1444735
MapReduce example in python
'''
Playing with MapReduce in python
ref.
http://mikecvet.wordpress.com/2010/07/02/parallel-mapreduce-in-python/
'''
from multiprocessing import Pool
def generate_data(A = 90000, B = 20) :
return [ [ [j] for j in range(B)] for i in range(A)]
@nivir
nivir / latex_escape.py
Created November 2, 2016 15:45 — forked from ptigas/latex_escape.py
latex escape
# -*- encoding: utf-8 -*-
def latex_decode( s ) :
'''
A simple function which taks a latex escaping command
and returns the appropriate unicode character according
to this table (via wikipedia):
LaTeX command Sample Description
\`{o} ò grave accent
@nivir
nivir / Django Secret Key Setting
Last active December 6, 2016 21:28
Django Error Secret Key Empty
==>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
execute_from_command_line(sys.argv)
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "//anaconda/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
==>sh medstack.sh init index run
*** Initializing server on www.lvh.me:8080 with medstack.settings.base
*** Running all tests
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
==>sh medstack.sh init index run
*** Initializing server on localhost:8080 with medstack.settings.base
*** Running all tests
Syncing...
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
@nivir
nivir / gist:7e5b6884d7698783ac9fdc8790c58987
Created December 4, 2016 23:19
Django fe_sendauth error
*** Initializing server on localhost:8080 with medstack.settings.base
*** Running all tests
Syncing...
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "//anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
@nivir
nivir / gist:1dd844754e4eba81e3dfa1752a79ec68
Created December 6, 2016 21:26
Django server running
django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
@nivir
nivir / gist:5ab75e2aee816f7cfbfe6b22c60a9fc7
Created December 6, 2016 21:49
Django Error postgresql image not found
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(//anaconda/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.3/lib/libssl.1.0.0.dylib
Referenced from: //anaconda/lib/python2.7/site-packages/psycopg2/_psycopg.so
Reason: image not found