Skip to content

Instantly share code, notes, and snippets.

View komputronika's full-sized avatar

Komputronika komputronika

View GitHub Profile
@komputronika
komputronika / xswitch
Created September 6, 2017 19:16
Switch XAMPP version in Linux
#!/bin/bash
echo "XAMPP Switcher"
if [ -z "$1" ] ; then
# No argument
echo
echo "Silahkan ketik versi PHP"
echo "[5] Untuk PHP versi 5"
echo "[7] Untuk PHP versi 7"
@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.
*/
@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 / 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 / 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
//-------------------------------------

1. Clone your fork:

git clone [email protected]: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 / 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

@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 / 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