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
@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 / 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 / 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) {}

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 / 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':
<?php
class LaporanController extends CController
{
public function actionDownload()
{
$filename = $_GET['name'];
$reportPath = Yii::app()->basePath.'/report/';
if (file_exists($reportPath.$filename)) {
<?php
/**
* Benchmark: Reflection Performance
*
* Conclusion: there is no performance-gain from caching reflection-objects.
*/
define('NUM_TESTS', 10);
<?php
/**
* Calculate a precise time difference.
* @param string $start result of microtime()
* @param string $end result of microtime(); if NULL/FALSE/0/'' then it's now
* @return flat difference in seconds, calculated with minimum precision loss
*/
function microtime_diff($start, $end = null) {
if (!$end) $end = microtime();
@zmiftah
zmiftah / postgre_snippets.sql
Last active July 6, 2017 04:21
Collection of Snippet from Postgres Query
-- Grant For Schema
GRANT ALL PRIVILEGES ON SCHEMA pdg TO project1;
-- Grant For Table
GRANT ALL PRIVILEGES ON TABLE pdg.proposal TO project1;
-- Grant For Sequence
GRANT USAGE, SELECT ON SEQUENCE pdg.proposal_id_seq TO project1;
-- Grant For View
GRANT SELECT ON pdg.vw_program_hierarchy TO project1;
-- //-- Source: http://www.postgresql.org/docs/8.3/static/sql-grant.html --//
@zmiftah
zmiftah / enumerable_data.php
Last active August 29, 2015 14:16
Create Enumerable Class as Array
<?php
class EnumerableData implements Iterator, Countable
{
private $position = 0;private $count = 0;
private $keys = array();
private $vars = array();
public function __construct()
{
$this->rewind();