Skip to content

Instantly share code, notes, and snippets.

View nim4n136's full-sized avatar
🏠
Working from home

NIM4N nim4n136

🏠
Working from home
View GitHub Profile
@nim4n136
nim4n136 / change_mode.sh
Created December 28, 2020 01:57
Change mode add access write to group user linux
# Add access write to group user linux
usermod -G user_apache apache
chmod g+rwx /var/www/app
@nim4n136
nim4n136 / multithread.py
Created June 22, 2020 21:34
Multi thread python
import threading
import time
def excute_program(x):
print(x)
time.sleep(100)
lst_thread = range(10000)
@nim4n136
nim4n136 / multiprocessing.py
Created June 22, 2020 21:27
Multi porccessing python
import time
import multiprocessing
def multiprocessing_func(x):
print(x)
time.sleep(1)
if __name__ == '__main__':
starttime = time.time()
pool = multiprocessing.Pool(processes=100)
@nim4n136
nim4n136 / notif.js
Created June 14, 2020 16:35
Notification browser
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!");
@nim4n136
nim4n136 / index.html
Last active June 14, 2020 15:16
Broadcast socket io
<!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>
@nim4n136
nim4n136 / DEPLOY.MD
Last active March 30, 2020 03:56
Cara deploy flask dengan uwsgi centos

Cara deploy flask dengan uwsgi centos

  1. Buat file wsgi.py di folder project root flask dengan is file dengan code berikut:

    from myproject import app
    
    if __name__ == "__main__":
        app.run()
@nim4n136
nim4n136 / cluster_data.py
Created March 19, 2020 16:37
cluster.py
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
@nim4n136
nim4n136 / chunk.py
Created March 19, 2020 15:46
Chunk array python
# 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))
@nim4n136
nim4n136 / date.py
Created March 4, 2020 09:21
Date min python
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
@nim4n136
nim4n136 / auth.py
Created March 3, 2020 11:10 — forked from ibeex/auth.py
Python LDAP (ActiveDirectory) authentication
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