Note: I'm currently taking a break from this course to focus on my studies so I can finally graduate
Why rewrite URLs? Check Wikipedia
Make sure AllowOverride is on for your directory, or put in httpd.conf
# Apache (.htaccess or httpd.conf)
RewriteEngine On
We now have everything we need to build a web app, except for images and other binary files. Your application will likely not get a lot of engagement if its not visual. In this lesson, we shall be adding the ability to upload images to your Posts api.
Since this will be a continuation from the class on Deploying to production you are adviced to start by cloning that workspace and then working from there.
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
// Highcharts CheatSheet Part 1. | |
// Create interactive charts easily for your web projects. | |
// Download: http://www.highcharts.com/download | |
// More: http://api.highcharts.com/highcharts | |
// 1. Installation. | |
// Highcharts requires two files to run, highcharts.js and either jQuery, MooTools or Prototype or the Highcharts Standalone Framework which are used for some common JavaScript tasks. | |
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
// <script src="https://code.highcharts.com/highcharts.js"></script> |
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
Julia likes to study KMP algorithm again using lecture note. What she likes to do is to go over the lecture | |
notes word by word, and then focus on thinking process. | |
She started to review KMP using Chinese blog, but she found out that the blog is not clear, so she likes to | |
follow up with more detail lecture note. | |
She likes to write and also she likes to read good writing of the KMP algorithm. | |
https://www.ics.uci.edu/~eppstein/161/960227.html |
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
<?php | |
// Referensi : | |
// https://id.wikipedia.org/wiki/Algoritma_Knuth-Morris-Pratt | |
// https://stackoverflow.com/questions/44081348/is-it-possible-to-use-knuth-morris-pratt-algorithm-for-string-matching-on-text-t | |
// http://www.elangsakti.com/2013/03/implementasi-algoritma-string-matching.html | |
// https://stackoverflow.com/questions/29439930/knuth-morris-pratt-string-search-algorithm | |
// https://stackoverflow.com/questions/5873935/how-to-optimize-knuth-morris-pratt-string-matching-algorithm | |
// https://stackoverflow.com/questions/13271856/understanding-knuth-morris-pratt-algorithm | |
// | |
// |
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
""" | |
This module contains an implementation of the Knuth-Morris-Pratt algorithm allowing to look for sequence matching. | |
For example if you want to find the sequence [1, 2, 3] in [2, 3, 1, 2, 3, 5, 6], you could do: | |
find_sequence([2, 3, 1, 2, 3, 5, 6], [1, 2, 3]) | |
This algorithm is especially interesting in case of many partial matches. Otherwise, you could simply use a brute | |
force search with correct performances. | |
The main function to use here is find_sequence which actually performs the KMP algorithm. |
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 KMP: | |
def partial(self, pattern): | |
""" Calculate partial match table: String -> [Int]""" | |
ret = [0] | |
for i in range(1, len(pattern)): | |
j = ret[i - 1] | |
while j > 0 and pattern[j] != pattern[i]: | |
j = ret[j - 1] | |
ret.append(j + 1 if pattern[j] == pattern[i] else j) |
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
<?php | |
/** | |
* This is an implementation of the Knuth-Morris-Pratt-Algorithm as in | |
* Thomas H. Cormen et. al.: "Algorithmen - Eine Einführung" | |
* (German version by Paul Molitor) 3. Auflage, page 1017 | |
* | |
* My changes: | |
* - Indexes starting with 0 | |
* - overlapping matches are recognized | |
*/ |