-
Buat file wsgi.py di folder project root flask dengan is file dengan code berikut:
from myproject import app if __name__ == "__main__": app.run()
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
# Add access write to group user linux | |
usermod -G user_apache apache | |
chmod g+rwx /var/www/app |
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
import threading | |
import time | |
def excute_program(x): | |
print(x) | |
time.sleep(100) | |
lst_thread = range(10000) |
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
import time | |
import multiprocessing | |
def multiprocessing_func(x): | |
print(x) | |
time.sleep(1) | |
if __name__ == '__main__': | |
starttime = time.time() | |
pool = multiprocessing.Pool(processes=100) |
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
function notifyMe() { | |
// Let's check if the browser supports notifications | |
if (!("Notification" in window)) { | |
alert("This browser does not support desktop notification"); | |
} | |
// Let's check if the user is okay to get some notification | |
else if (Notification.permission === "granted") { | |
// If it's okay let's create a notification | |
var notification = new Notification("Hi 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title></title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js"></script> | |
</head> | |
<body> | |
<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
from collections import defaultdict | |
def cluster_data(lst_array, max_range): | |
clustered = defaultdict(list) | |
n = 1 | |
for lst in lst_array: | |
clustered[n].append(lst) | |
n = n+1 | |
if n > max_range: | |
n = 1 |
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
# chunk data array | |
def chunks(lst, n_max): | |
n = max(1, n_max) | |
return (lst[i:i+n] for i in range(0, len(lst), n_max)) |
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
from datetime import date | |
from datetime import timedelta | |
def backdate(): | |
# Get today. | |
today = date.today() | |
# Subtract timedelta of 32 day. | |
yesterday = today - timedelta(days=32) | |
return yesterday |
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
import ldap | |
def check_credentials(username, password): | |
"""Verifies credentials for username and password. | |
Returns None on success or a string describing the error on failure | |
# Adapt to your needs | |
""" | |
LDAP_SERVER = 'ldap://xxx' | |
# fully qualified AD user name | |
LDAP_USERNAME = '%s@xxx.xx' % username |