echo "deb http://www.rabbitmq.com/debian/ testing main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list > /dev/null
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import sys | |
import unittest | |
def flatten(items): | |
"""Generator for thwoing our items from list of lists.""" | |
for x in items: | |
if isinstance(x, list): | |
for sub_x in flatten(x): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout master && git pull origin master && git fetch -p && git branch -d $(git branch --merged | grep master -v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fibonacci(object): | |
"""docstring for Fibonacci""" | |
fib_cache = {} | |
def fib_memoization(self, n): | |
if n in fib_cache: | |
return fib_cache[n] | |
else: | |
if n < 2: | |
fib_cache[n] = n | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack(object): | |
"""docstring for Stack""" | |
def __init__(self): | |
self.stack = [] | |
self.min_stack = [] | |
def push(self, x): | |
if self.isEmpty(): | |
self.stack.append(x) | |
self.min_stack.append(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# n = size of array1 | |
# m = size of array2 | |
def merge(array1, array2, n , m): | |
x = 0 | |
y = 0 | |
result = [] | |
k = 0 | |
while (x < n) and (y < m): | |
if array1[x] > array2[y]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Assuming you have already installed supervisor. | |
If not simply do: | |
sudo pip install supervisor | |
2. create a file under path : /etc/supervisor/conf.d/<filename.conf>/ | |
- sudo touch /etc/supervisor/conf.d/<filename.conf>/ | |
- content | |
[program:myworker] | |
command= /path/to/your/virtualenv/bin/rqworker | |
stdout_logfile = /var/log/redis_log/redis.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install redis-server | |
# Configure redis to use sockets | |
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig | |
# Disable Redis listening on TCP by setting 'port' to 0 | |
sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf | |
# Enable Redis socket for default Debian / Ubuntu path | |
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf |