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 / firebase.php
Created December 7, 2018 07:36 — forked from krhoyt/firebase.php
Interact with Firebase from PHP.
<?php
// Constants
$FIREBASE = "_YOUR_FIREBASE_URL_";
$NODE_DELETE = "temperature.json";
$NODE_GET = "temperature.json";
$NODE_PATCH = ".json";
$NODE_PUT = "temperature.json";
// Data for PUT
@komputronika
komputronika / user_ip_address.php
Created November 16, 2018 02:31
Get user's IP address with PHP
<?php
function user_ip_address() {
if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) {
$addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
$ip = filter_var(trim($addr[0]), FILTER_VALIDATE_IP)
return $ip;
} else {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
@komputronika
komputronika / GitHub-Forking.md
Created July 6, 2018 03:53 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@komputronika
komputronika / multiButton.ino
Created June 5, 2018 16:18
Mendeteksi penekanan tombol ganda dengan Arduino
//-------------------------------------
// Mendeteksi Penekanan Tombol Ganda
// Semacam mendeteksi double klik, tapi bisa lebih dari 2 klik
//
// - Bisa mendeteksi jumlah tekanan berurutan pada button
// - Jumlah penekanan tidak terbatas (single, double, triple, dst)
// - Rentang waktu tekanan bisa diatur
//
// Author: Julius Chandra
//-------------------------------------
@komputronika
komputronika / auto_off.ino
Last active April 28, 2018 11:13
Sketch Arduino untuk Auto-off Baterai Menggunakan Relay
/*
Sketch auto off baterai
menggunakan relay
Author: Komputronika.com
*/
// Definisi
@komputronika
komputronika / index.php
Created April 28, 2018 08:46
Script PHP untuk Baca dan Simpan data IoT
<?php
/*
Script memerlukan file bernama ".htaccess" dengan isi seperti ini:
-----------------------------------
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
-----------------------------------
@komputronika
komputronika / gpio_relay.c
Last active September 21, 2017 14:35
Raspberry Pi – Driving a Relay using GPIO
/*
* gpio_relay.c - example of driving a relay using the GPIO peripheral on a BCM2835 (Raspberry Pi)
*
* Copyright 2012 Kevin Sangeelee.
* Released as GPLv2, see <http://www.gnu.org/licenses/>
*
* This is intended as an example of using Raspberry Pi hardware registers to drive a relay using GPIO. Use at your own
* risk or not at all. As far as possible, I've omitted anything that doesn't relate to the Raspi registers. There are more
* conventional ways of doing this using kernel drivers.
*/