Skip to content

Instantly share code, notes, and snippets.

View ihsanberahim's full-sized avatar
💭
focusing on the strong base for long term

Muhammad Nur'Ihsan Bin Berahim ihsanberahim

💭
focusing on the strong base for long term
View GitHub Profile
@ihsanberahim
ihsanberahim / example.php
Last active August 29, 2015 13:57
simple code to create php menu tree. Inspired by Drupal.
<?php
require_once('menu.php');
?>
<?php load_menu() ?>
<table cellpadding="0" cellspacing="0" border="0" class="stdtable">
<colgroup>
<col class="con1">
<col class="con1">
</colgroup>
<thead>
@ihsanberahim
ihsanberahim / template.php
Created February 5, 2014 06:26
extract image source attribute from html string in Drupal
/**
* Author: ihsanberahim
* Author Url: http://blog.powergeng.com
* Author Facebook: http://facebook.com/ihsanberahim
*
* i found it from stackoverflow
*/
function content2src($html){
$doc = new DOMDocument();
@ihsanberahim
ihsanberahim / MyAccount.js
Last active January 1, 2016 14:29
TextInput - UI Module MyAccount - Controller Module App Theme Appcelerator 3.2.0.GA SDK
function MyAccount(_MainActivity){
/*---------------------------------
GROUP : Load Component Dependencies
----------------------------------*/
var H = require('/utils/Helper');
var C = require('/Config');
var UITextInput = require('/views/TextInput');
/*---------------------------------
@ihsanberahim
ihsanberahim / org.apache.httpd.plist
Created December 13, 2013 14:56
OSX Server apache plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>EnvironmentVariables</key>
<dict>
<key>SERVER_INSTALL_PATH_PREFIX</key>
<string>/Applications/Server.app/Contents/ServerRoot</string>
@ihsanberahim
ihsanberahim / org.apache.httpd.plist
Created December 13, 2013 14:54
Original apache plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>org.apache.httpd</string>
<key>EnvironmentVariables</key>
<dict>
sudo chmod -R +a '_www allow read,write,delete,add_file,add_subdirectory,file_inherit,directory_inherit' <dir>
@ihsanberahim
ihsanberahim / demo.php
Created November 15, 2013 03:41
example of how static variable works
<?php
function repeatIt(){
static $id;
if(!$id) $id=0;
$id++;
echo sprintf('<div id="someprefix_%s">Butang %s</div>',$id,$id);
}
for($i=0;$i<10;$i++){
repeatIt();
@ihsanberahim
ihsanberahim / filter.php
Created November 13, 2013 09:00
separate text by breakline
<?php
$subject = '
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
@ihsanberahim
ihsanberahim / helper.php
Created November 12, 2013 10:35
merge 2 array as column
<?php
$column1 = array(1,2,3,4);
$column2 = array('test','test','test','test');
$table = array();
//Example 1
/*foreach($column1 as $key => $row){
$table[] = array($column1[$key],$column2[$key]);
}*/
@ihsanberahim
ihsanberahim / regex.php
Last active December 28, 2015 02:19
search money in text
<?php
$subject = '
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test