Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@remoharsono
remoharsono / 0-startup-overview.md
Created February 7, 2019 04:25 — forked from dideler/0-startup-overview.md
Startup Engineering notes
@remoharsono
remoharsono / klein-url-rewriting.md
Last active December 21, 2018 07:01 — forked from jamesvl/gist:910325
Web server rewrite rules for using klein PHP router

URL-rewriting for klein PHP router

Why rewrite URLs? Check Wikipedia

Apache

Make sure AllowOverride is on for your directory, or put in httpd.conf

# Apache (.htaccess or httpd.conf)

RewriteEngine On

@remoharsono
remoharsono / working_with_image.md
Created November 30, 2018 08:59 — forked from prodeveloper/working_with_image.md
How to upload and use images on your Django application

Working with images

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.

Step 1

// 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>
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
@remoharsono
remoharsono / php-Knuth-Morris.php
Created November 26, 2018 02:20 — forked from fatkulnurk/php-Knuth-Morris.php
Algoritma Knuth-Morris-Pratt
<?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
//
//
@remoharsono
remoharsono / KMP_algo.py
Created November 26, 2018 02:19 — forked from RaphaelAslanian/KMP_algo.py
Implementation of the Knuth-Morris-Pratt algorithm
"""
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.
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)
@remoharsono
remoharsono / kmp_match.php
Created November 26, 2018 00:12 — forked from white-gecko/kmp_match.php
Knuth-Morris-Pratt-Algorithm
<?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
*/
@remoharsono
remoharsono / gist:43c07cc7674d2eff9b21102cbf1a8297
Created October 17, 2018 12:02 — forked from evildmp/gist:3094281
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using: