Skip to content

Instantly share code, notes, and snippets.

@Ahmed
Ahmed / processify.py
Last active August 29, 2015 14:23 — forked from schlamar/processify.py
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Coding:
http://jobs.readwriteweb.com/ # supports RSS to get jobs
http://angel.co/jobs # supports APIs to get jobs
http://startuply.com/ # supports RSS to get jobs
http://jobs.37signals.com/ # supports RSS to get jobs
http://www.dice.com/ # supports RSS and JSON to search for jobs
http://jobs.github.com/ # supports RSS
http://www.craigslist.org # supports RSS and XML to post and read jobs
http://www.reddit.com/ # supports posting posts through bots, and reading RSS
http://news.ycombinator.com/jobs # supports RSS for reading jobs
# from: http://stackoverflow.com/questions/1228299/change-one-character-in-a-string-in-python
#
# TypeError: 'str' object does not support item assignment
# If you have a string in python and you want to replace a char by index, you will get that error.
# I searched online and a lot of people have spammed the search results with answers that are not really related.
# I found the answer on StackOverFlow, and I decided to write a small functon to implement it
# Note: it creates a new string everytime you call it.
# in [4]: replaceByIndexString(0,'@','foobar')
# Out[4]: '@oobar'
# In [5]: replaceByIndexString(1,'@','foobar')
@Ahmed
Ahmed / prime.py
Last active December 15, 2015 21:59
Prime Number Checker
# by Ahmed Hassan
import random
from math import log
def powerMod(a,n,m):
num_roots_operation = int(log(n)/log(2))
all_roots_calc =[]
all_roots_calc.append(a)