Skip to content

Instantly share code, notes, and snippets.

View zmiftah's full-sized avatar
💭
Waiting List ...

Zein Miftah zmiftah

💭
Waiting List ...
  • West Java, Indonesia
View GitHub Profile
<?php
/**
* Benchmark: Reflection Performance
*
* Conclusion: there is no performance-gain from caching reflection-objects.
*/
define('NUM_TESTS', 10);
<?php
class LaporanController extends CController
{
public function actionDownload()
{
$filename = $_GET['name'];
$reportPath = Yii::app()->basePath.'/report/';
if (file_exists($reportPath.$filename)) {
@zmiftah
zmiftah / php_get_image_dimension.php
Created January 3, 2014 07:17
PHP: Get Image Dimension By Type
<?php
public function getDimensions($filename, $filetype)
{
$image = null;
switch ($filetype) {
case 'image/gif':
$image = imagecreatefromgif($filename);
break;
case 'image/jpeg':

a simple git branching model

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@zmiftah
zmiftah / js_create_xhr_object.js
Last active December 23, 2015 17:19
Js : Create XHR Object
function getHTTPObject() {
if (typeof XMLHttpRequest != 'undefined') {
return new XMLHttpRequest();
}
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
@zmiftah
zmiftah / pthreads.md
Created September 9, 2013 07:35 — forked from krakjoe/pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
@zmiftah
zmiftah / media-query-resize-height.less
Created August 14, 2013 02:58
Less Media Query Resize Height
@media (min-width: 1200px) {
#header-row {
.header-row( 103px );
}
}
@media (min-width: 1024px) {
#header-row {
.header-row( 103px );
}
@zmiftah
zmiftah / angular_controller.js
Last active December 10, 2015 22:08 — forked from zergin/controller.js
JS: Angular Controller
$scope.$on('$viewContentLoaded', function() {
$scope._style = document.createElement('link');
$scope._style.type = 'text/css';
$scope._style.href = 'application/Invoice/Resource/single.css';
$scope._style.rel = 'stylesheet';
$scope._style = document.head.appendChild($scope._style);
});
$scope.$on('$destroy', function() {
@zmiftah
zmiftah / class_paginator_v1.php
Last active October 12, 2015 08:28
PHP: Simple Class Paginator v0.1
<?php
class Paginator {
var $per_page;
var $total;
var $list;
var $period;
public function __construct( $per_page, $total ) {
$this->per_page = $per_page;
$this->total = $total;
@zmiftah
zmiftah / php_db_logger.php
Last active October 11, 2015 05:28
PHP: Db (Mysql) Logger Class
<?php
class DbLogger {
private $table_name;
private $db;
private $queries;
private $errors;
private $result;
private $safe;