This project enables a user to first download historical financial data from Yahoo Finance. Then, using that data, or any other data source, to test stock trading strategies. The user can choose conditions for buying and selling stocks based on many variables. The code is available for viewing, downloading, and forking on my GitHub here.
Regex used to select and replace URLs in plain text with clickable links
$regex = '(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.%-=#~\@!]*(\?\S+)?)?)?)'; $text = mb_ereg_replace($regex, '<a href="\\1">\\1</a>', $text);
The following is two methods to get the duration either as a colon separated value, or in seconds, of a given media file using FFmpeg.
If you have ever needed to verify, create, or update database schema then you will probably like this snippet (ok, it is a little long to call a snippet). This code assumes that you have a class with a shared PDO.
The following code returns the correct pluralization of a given english word based on the number provided.
The following code will enable you to implement multiprocessing in any Python project that contains a for loop. Take your for loop that has a long-running function in it and replace “for i in iterable” with your for loop conditions. Change “function_name” to the name of the function that will be executed. Change the list of function arguments to what you need.
import multiprocessing number_cores = multiprocessing.cpu_count() pool = multiprocessing.Pool(processes=number_cores) r = [pool.apply_async(function_name, args=(function_arg1, function_arg2)) for i in iterable] output = [p.get() for p in r] pool.terminate()
The above code would be the multiprocessing implementation of the following.
output =  for i in iterable: output += function_name(function_arg1, function_arg2)
Regex to match the end of sentences in order to split a block of text into sentences.
sentence_regex = ur'([\.\?!][\'\"\u2018\u2019\u201c\u201d\)\]]*\s*(?<!\w\.\w.)(?<![A-Z][a-z][a-z]\.)(?<![A-Z][a-z]\.)(?<![A-Z]\.)\s+)' regex = re.compile(sentence_regex, flags=re.UNICODE) sentences = regex.split(TEXT_BLOCK)
When I first got my Synology DS1815+ to replace my existing file server that was using Windows Storage Spaces on Windows 10, I was excited to continue using CrashPlan to backup my family’s computers. Unfortunately, I soon found out that while the Synology can run CrashPlan after reading the tutorial from PCLoadLetter, it was not anything like I was used to for administration. Using CrashPlan installed on the Synology required modifying configuration files on all of the computers that I wanted to backup, instead of simply logging into my CrashPlan account as I had done before. So, I promptly gave up and used Synology’s Cloud Station Backup for 6 months.
This project source can be found on my github here.
This project is a single webpage to calculate time based tokens for two factor authentication, just like Google Authenticator or Authy does on your phone. There is no network connection necessary, so it can be used offline and you can be sure that I am not stealing your codes.
The project can be used live here.