oleh Taufan Aditya
a. Sekilas tentang "native" PHP
Mari kita perhatikan sejenak kode berikut ini :
oleh Taufan Aditya
a. Sekilas tentang "native" PHP
Mari kita perhatikan sejenak kode berikut ini :
<?php | |
function bitly_shorten($url) { | |
$login = "bitly_login"; | |
$apikey = "bitly_apikey"; | |
$format = "json"; | |
$query = array("login" => $login, | |
"apiKey" => $apikey, | |
"longUrl" => urlencode($url), | |
"format" => $format); |
<?php | |
// Usage: | |
// $master=new WebSocket("localhost",12345); | |
// $master->callback = function($self, $user, $msg){ | |
// $self->send($user->socket,$msg); | |
// }; | |
require "CommandsAppBase.class.php"; | |
require "WsRequest.class.php"; |
<?php | |
// echo uuid_encode('cd76b808-4017-4965-b9b1-2dbcf857e405'); | |
function uuid_encode($uuid){ | |
$binary = pack("h*", str_replace('-', '', $uuid)); | |
$binary = base64_encode($binary); | |
$binary = str_replace('/', '_', $binary); | |
$binary = str_replace('=', '', $binary); | |
return $binary; |
# 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 |
function parseMessage (buffer) { | |
const firstByte = buffer.readUInt8(0); | |
const isFinalFrame = Boolean((firstByte >>> 7) & 0×1); | |
const [reserved1, reserved2, reserved3] = [ Boolean((firstByte >>> 6) & 0×1), Boolean((firstByte >>> 5) & 0×1), Boolean((firstByte >>> 4) & 0×1) ]; | |
const opCode = firstByte & 0xF; | |
// We can return null to signify that this is a connection termination frame | |
if (opCode === 0×8) | |
return null; | |
// We only care about text frames from this point onward | |
if (opCode !== 0×1) |
<?php | |
// Constants | |
$FIREBASE = "_YOUR_FIREBASE_URL_"; | |
$NODE_DELETE = "temperature.json"; | |
$NODE_GET = "temperature.json"; | |
$NODE_PATCH = ".json"; | |
$NODE_PUT = "temperature.json"; | |
// Data for PUT |
<?php | |
$files = glob("*.tar.gz"); | |
foreach($files as $file) { | |
if(is_file($file) | |
&& time() - filemtime($file) >= 7*24*60*60) { // 7 days | |
unlink($file); | |
} | |
} | |
?> |
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al. | |
# Modified (bringing often-changed options to the top) by Elliot Williams | |
# make all = Make software and program | |
# make clean = Clean out built project files. | |
# make program = Download the hex file to the device, using avrdude. Please | |
# customize the avrdude settings below first! | |
# Microcontroller Type | |
MCU = attiny13 |
#!/usr/bin/php | |
<?php | |
/** | |
* Script used to update DNS records in Cloud Flare when server IP address changes. | |
* My use case is to run this script on startup, when I spin up a new Digital Ocean VPS but | |
* this could easily be used to update for dynamic DNS with a cronjob. | |
* | |
* Digital Ocean referral code: https://www.digitalocean.com/?refcode=3655e259ce29 | |
* | |
* Requires PHP cURL |