Skip to content

Instantly share code, notes, and snippets.


Hengki Sihombing hengkiardo

  • Jakarta, Indonesia
View GitHub Profile
hengkiardo / gist:4023845
Created Nov 6, 2012
Example of scrollbar customization (works in Webkit only)
View gist:4023845
::-webkit-scrollbar {
width: 12px;
::-webkit-scrollbar-track {
background: none;
::-webkit-scrollbar-thumb {
background: -webkit-linear-gradient(left, #547c90, #002640);
hengkiardo / gist:4023855
Created Nov 6, 2012
Create image data URIs (base64) using PHP
View gist:4023855
// A few settings
$image = 'cricci.jpg';
// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));
// Format the image SRC: data:{mime};base64,{data};
$src = 'data: '.mime_content_type($image).';base64,'.$imageData;
// Echo out a sample image
hengkiardo / gist:4023868
Created Nov 6, 2012
Get latitude and longitude from an adress
View gist:4023868
function getLatLong($address){
if (!is_string($address))die("All Addresses must be passed as a string");
$_url = sprintf('',rawurlencode($address));
$_result = false;
if($_result = file_get_contents($_url)) {
if(strpos($_result,'errortips') > 1 || strpos($_result,'Did you mean:') !== false) return false;
preg_match('!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U', $_result, $_match);
$_coords['lat'] = $_match[1];
$_coords['long'] = $_match[2];
hengkiardo / gist:4023880
Created Nov 6, 2012
Download and save images from a page using cURL
View gist:4023880
function getImages($html) {
$matches = array();
$regex = '~*?)\.jpg~i';
preg_match_all($regex, $html, $matches);
foreach ($matches[1] as $img) {
function saveImg($name) {
hengkiardo / gzip_footer.php
Created Nov 6, 2012
Use GZip compression on your PHP files
View gzip_footer.php
hengkiardo / iphone.css
Created Nov 19, 2012
Single Element iPhone 5 using CSS3
View iphone.css
body {background: url(}
/* First, we'll make the body. After that we'll use :after and :before elements to make other things like buttons */
.iphone5 {
position: relative;
height: 520px;
width: 248px;
border-radius: 35px;
margin: 50px auto;

Twitter autoresponder bot

By Daniel15 ( This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

hengkiardo / gist:4142221
Created Nov 25, 2012
QR Code for the Current URL with PHP and Google Charts
View gist:4142221
function saveImage($your_url, $width, $height, $file) {
$your_url = urlencode($your_url);
$url = ''.$width.'x'.$height.'&cht=qr&chl='.$your_url';
// initialize cURL settings
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
hengkiardo / jbookm.js
Last active Oct 13, 2015 — forked from irace/gist:1041837
Simple bookmarklet template with jQuery
View jbookm.js
// Stripped down jQuerify for modern browsers:
(function() {
var f = function() {
jQuery.noConflict()(function($) {
// Bookmarklet code goes here
if (typeof jQuery != 'undefined') {
hengkiardo / gist:4147311
Created Nov 26, 2012
Database configuration file for MySQL service at AppFog Cloud
View gist:4147311
$services_json = json_decode(getenv("VCAP_SERVICES"),true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
$username = $mysql_config["username"];
$password = $mysql_config["password"];
$hostname = $mysql_config["hostname"];
$port = $mysql_config["port"];
$db = $mysql_config["name"];