Skip to content

Instantly share code, notes, and snippets.

View komputronika's full-sized avatar

Komputronika komputronika

View GitHub Profile
@komputronika
komputronika / tcp_tweaks.txt
Created April 15, 2024 07:35 — forked from n4ss1m/tcp_tweaks.txt
High performance tuning of Nginx
## From a post on the ML, apropos this:
## http://lowlatencyweb.wordpress.com/2012/03/20/500000-requestssec-modern-http-servers-are-fast.
## For sysctl.conf
net.ipv4.tcp_slow_start_after_idle = 0
echo "1768 64512" > /proc/sys/net/ipv4/ip_local_port_range
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
@komputronika
komputronika / pubsub.js
Created April 5, 2024 07:18 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@komputronika
komputronika / node-app-as-service-on-ubuntu.md
Created March 10, 2024 16:25 — forked from maliarslan/node-app-as-service-on-ubuntu.md
Run Node.js application as service on Ubuntu 16.04

Assuming that you have already installed Node.js on your system. If you haven't visit https://nodejs.org/en/download/package-manager/

First we need to create a service file into /lib/systemd/system to introduce our service.

So, with your favorite editor, open up a new file there with;

sudo nano /lib/systemd/system/mygreatestapp.service

Put the following contents in it;

[Unit]
@komputronika
komputronika / my.cnf
Created March 9, 2024 04:51 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@komputronika
komputronika / cors.conf
Created March 1, 2024 13:59
NGINX Configuration: CORS and URL Rewrite
location /Folder {
add_header 'Access-Control-Allow-Origin' '*' always;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "*" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Headers' "Authorization, Origin, X-Requested-With, Content-Type, Accept" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000;
@komputronika
komputronika / serializeObject.js
Created March 1, 2024 04:53
Serialize Form's Values to Object JSON
// Function to create JSON Object from <form> values
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
@komputronika
komputronika / mongodb-autoincrement.php
Last active March 1, 2024 04:56
How to create autoincrement sequence number in MongoDB, with PHP library
<?php
// Table "counters", stores autoincrement value (seq)
/*
Initial value are:
{
"_id": "nota", // Counter key, eg: 'nota'
"seq": 1 // Initial number
@komputronika
komputronika / index.php
Created May 14, 2021 11:32 — forked from oriolrivera/index.php
Simple Chat Using WebSocket and PHP Socket
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<style type="text/css">
<!--
.chat_wrapper {
width: 500px;
margin-right: auto;
margin-left: auto;
@komputronika
komputronika / Functions-in-file.php
Created September 9, 2019 00:39
Find all functions in a file and return it's names in array
<?php
//--------------------------------
// Example usage:
//--------------------------------
print "<pre>";
print_r( functions_in_file(__FILE__) );
//--------------------------------
// Find functions in a file:
@komputronika
komputronika / save_screenshot_with_select.py
Created May 17, 2019 03:02 — forked from lantip/save_screenshot_with_select.py
Script untuk menyimpan tangkap-layar dari laman KPU, dengan terlebih dulu memilih TPS
# Sebagai kelanjutan dari script saya sebelumnya (save_screenshot.py)
# Script ini membuka laman kpu, memilih berurutan Propinsi, Kabupaten, Kecamatan, Kelurahan dan TPS
# Di penghujung proses, dilakukan penyimpanan screenshot.
# Sebagai POC, saya batasi saja 5 TPS
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from datetime import datetime
import time