Skip to content

Instantly share code, notes, and snippets.

View komputronika's full-sized avatar

Komputronika komputronika

View GitHub Profile
@toopay
toopay / composer.md
Last active September 16, 2017 13:59
Composer Explained (PHP Indonesia EMagz Draft)

Composer Explained

oleh Taufan Aditya

I. Kenapa Menggunakan Composer

a. Sekilas tentang "native" PHP

Mari kita perhatikan sejenak kode berikut ini :

@xhezairbey
xhezairbey / bitly_api_v3_shorten.php
Created October 27, 2011 23:42
BitLy API v3 Shorten PHP
<?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";
@fdcore
fdcore / uuid.php
Last active March 2, 2019 03:26
Encode long UUID to short binary string like youtube hash
<?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;
@lantip
lantip / save_screenshot_with_select.py
Last active May 17, 2019 10:41
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
@Srushtika
Srushtika / server.js
Last active October 13, 2019 16:55
WebSockets server tutorial
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)
@krhoyt
krhoyt / firebase.php
Created December 6, 2014 19:29
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
@Xeroday
Xeroday / delete-targz.php
Created July 21, 2013 22:27
Deletes .tar.gz files older than 7 days.
<?php
$files = glob("*.tar.gz");
foreach($files as $file) {
if(is_file($file)
&& time() - filemtime($file) >= 7*24*60*60) { // 7 days
unlink($file);
}
}
?>
@bradfordbarr
bradfordbarr / Makefile
Created February 24, 2014 06:42
Sample AVR Makefile
# 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
@lewayotte
lewayotte / cloudflare-dns.php
Last active March 17, 2022 09:32
Cloud Flare Automatic DNS Record Updater (PHP Script)
#!/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