Skip to content

Instantly share code, notes, and snippets.

View komputronika's full-sized avatar

Komputronika komputronika

View GitHub Profile
@komputronika
komputronika / readme.md
Created January 9, 2019 06:05 — forked from nonsintetic/readme.md
PHP - Get YouTube subscriber count with Youtube API v3

How to:

Here's a 'simple' way to get the YouTube subscriber number from Google's Youtube API v3:

  1. Go to https://console.developers.google.com/apis/library
  2. Log in with your Google account.
  3. Next to the logo click on 'Project' and 'Create project'. Name it whatever you want and click on 'Create'.
  4. Wait until the project is created, the page will switch to it by itself, it will take a couple of seconds up to a minute. Once it's done it will be selected next to the logo.
  5. Once it's created and selected, click on 'Credentials' from the menu on the left.
  6. Click on 'Create Credentials' and choose 'API Key'. You can restrict it to specific IPs, or types of requests (website, android, ios etc.) if you want, it's safer that way.
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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]) {