Skip to content

Instantly share code, notes, and snippets.

View femmerling's full-sized avatar
🛠️
Building things

Fauzan Erich Emmerling femmerling

🛠️
Building things
View GitHub Profile
@femmerling
femmerling / crawler.py
Created November 3, 2012 16:49
Simple Crawler Using Python
"""
crawler.py
web link crawler
Nov 3rd 2012 saturday night insomnia coding session
Fauzan Erich Emmerling
erich@emfeld.com
"""
import re
from urllib2 import urlopen
@femmerling
femmerling / quicksort.py
Created December 23, 2012 15:53
The quick sort Algorithm written in python.
def quicksort(input_list):
higher = []
lower = []
if len(input_list) > 2:
pivot = (len(input_list) - 1)/2
mid = [input_list[pivot]]
i = 0
while i < len(input_list):
if i != pivot:
if input_list[i] <= input_list[pivot]:
@femmerling
femmerling / hashtable.py
Last active September 22, 2017 14:35
Hashtable algorithm written in python
#create the key-value object
class KeyValue:
def __init__(self,key,value):
self.key=key
self.value=value
class HashTable:
#initiate an empty list that will store all key value pair based on the KeyValue object
def __init__(self):
@femmerling
femmerling / lesson1.py
Last active December 10, 2015 01:58
Python lesson #1 to share in ID-Python facebook group. Feel free to share. Materials are in Bahasa Indonesia
"""
Dasar pertama dalam mempelajari bahasa program adalah tipe data.
Pelajaran ini akan memberi pengetahuan mengenai variable dan tipe data pada python
"""
#Deklarasi Variable
var_none = None
#None merupakan pengganti null pada bahasa lain
var_integer = 1
var_float = 1.1
@femmerling
femmerling / mergesort.py
Last active November 2, 2021 15:45
Merge Sort written in python.
def merge_lists(left_sublist,right_sublist):
i,j = 0,0
result = []
#iterate through both left and right sublist
while i<len(left_sublist) and j<len(right_sublist):
#if left value is lower than right then append it to the result
if left_sublist[i] <= right_sublist[j]:
result.append(left_sublist[i])
i += 1
else:
@femmerling
femmerling / main.py
Created February 28, 2013 05:24
Generated Main.py
# do not change or move the following lines if you still want to use the box.py auto generator
from app import app, db
from models import Contact
# you can freely change the lines below
from flask import render_template
from flask import json
from flask import session
from flask import url_for
from flask import redirect
@femmerling
femmerling / main.py
Created February 28, 2013 05:29
Edit contacts routing
@app.route('/contact/view-all')
def contact_view_controller():
#this is the controller to view all data in the model
contact_list = Contact.query.all()
if contact_list:
contact_entries = [contact.dto() for contact in contact_list]
else:
contact_entries = None
@femmerling
femmerling / main.py
Last active December 14, 2015 07:59
Editing contact/add routing
@app.route('/contact/')
def contact_add_controller():
#this is the controller to add new model entries
return render_template('contact_add.html', title = "Add New Entry")
@app.route('/contact/create/',methods=['POST','GET'])
def contact_create_data_controller():
# this is the contact data create handler
contact_name = request.values.get('contact_name')
contact_email = request.values.get('contact_email')
@femmerling
femmerling / base.html
Last active December 14, 2015 07:59
base.html fix
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>My Website</title>
<meta name="description" content="">
@femmerling
femmerling / main.py
Created February 28, 2013 06:16
fixed home routing
# home root controller
# @app.route('/')
# def index():
# # define your controller here
# return render_template('welcome.html')
@app.route('/') #Link
def home_control():
# add your controller here
return render_template('home.html')