I just joined thrilld.com!
(Source: phosphorescene)
This is a simple Debian init.d script for my self-hosted Django/Gunicorn websites. Note that it runs inside a virtualenv (my installed Django versions are different in each virtualenv). If you have questions: comment this post!
#!/bin/sh
### BEGIN INIT INFO
# Provides: seismic_web
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Gunicorn processes for seismic_web
### END INIT INFO
# www-data is the default www user on debian
USER=www-data
NAME="seismic_web"
GUNICORN_RUN="gunicorn_django"
# Confdir: the Django project inside the virtualenv
CONFDIR="/home/thomas/seismic_web/seismic_web"
VENV_ACTIVATION=". ../bin/activate"
RETVAL=0
# PID: I always name my gunicorn pidfiles this way
PID="/tmp/gunicorn_"$NAME".pid"
# source function library
. /lib/lsb/init-functions
start()
{
echo "Starting $NAME."
cd $CONFDIR;
su -c "$VENV_ACTIVATION; $GUNICORN_RUN" $USER && echo "OK" || echo "failed";
}
stop()
{
echo "Stopping $NAME"
kill -QUIT `cat $PID` && echo "OK" || echo "failed";
}
reload()
{
echo "Reloading $NAME:"
if [ -f $PID ]
then kill -HUP `cat $PID` && echo "OK" || echo "failed";
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
reload
;;
reload)
reload
;;
force-reload)
stop && start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL
I just release the first version of Ticky, a free, simple and unobtrusive OS X application which helps you to manage your daily tasks. As it’s my first complete ObjC/Cocoa application, I will probably write some posts on problems I have encountered.
By default, Wordpress only allows you to write your posts in HTML (in the case you have not noticed the built-in WYSIWYG editor creates and renders HTML). However, there are many ways to mark up your texts on the web (HTML is not the only one). My favorite is Markdown.
*Yeah I finally wrote my March post.*
I’m a regular reader of TechCrunch. I’ve just read “Apple, There’s Pornography On My iPhone The App Is Called Safari. You made it.” by MG Siegler (by the way I’m a big fan of this guy, I really like what he writes). This article exactly reflects my point of view concerning recent Apple’s decisions. I advise you to take a look at it.
Note: If you think that I missed a really nice disctration-less text editor, or that one of my comment is groundless, feel free to drop me an email.
Competitors:
Ommwriter is developed because of an internal need at Herraiz Soto
Here is my implementation of Dijkstra’s algorithm (also known as the shortest path) in Python. I wrote it for a project at school and put it there for memory only.
Note:
* I don’t test the graph.
* Graph is oriented. If you want a non-oriented graph, you need to add vertices twice in your graph.
* May be improved (time).
Here is the source ([on Friendpaste](http://friendpaste.com/7ml2pWDYzgr0I0ZOiTU6nq)):
def dijkstra(graph, start, end):
“”“
Dijkstra’s algorithm Python implementation.
Arguments:
graph: Dictionnary of dictionnary (keys are vertices).
start: Start vertex.
end: End vertex.
Output:
List of vertices from the beggining to the end.
Example:
»> graph = {
… ‘A’: {‘B’: 10, ‘D’: 4, ‘F’: 10},
… ‘B’: {‘E’: 5, ‘J’: 10, ‘I’: 17},
… ‘C’: {‘A’: 4, ‘D’: 10, ‘E’: 16},
… ‘D’: {‘F’: 12, ‘G’: 21},
… ‘E’: {‘G’: 4},
… ‘F’: {‘H’: 3},
… ‘G’: {‘J’: 3},
… ‘H’: {‘G’: 3, ‘J’: 5},
… ‘I’: {},
… ‘J’: {‘I’: 8},
… }
»> dijkstra(graph, ‘C’, ‘I’)
[‘C’, ‘A’, ‘B’, ‘I’]
“”“
D = {} # Final distances dict
P = {} # Predecessor dict
# Fill the dicts with default values
for node in graph.keys():
D[node] = -1 # Vertices are unreachable
P[node] = “” # Vertices have no predecessors
D[start] = 0 # The start vertex needs no move
unseen_nodes = graph.keys() # All nodes are unseen
while len(unseen_nodes) > 0:
# Select the node with the lowest value in D (final distance)
shortest = None
node = ”
for temp_node in unseen_nodes:
if shortest == None:
shortest = D[temp_node]
node = temp_node
elif D[temp_node]