Skip to content

Instantly share code, notes, and snippets.

View nawawi's full-sized avatar

Nawawi Jamili nawawi

View GitHub Profile
@nawawi
nawawi / icu-last-intltest-failed
Created September 18, 2014 03:08
icu-last intltest failed patch
--- icu.orig/source/test/intltest/dtfmttst.cpp 2013-10-04 22:48:00.000000000 +0200
+++ icu/source/test/intltest/dtfmttst.cpp 2014-06-13 19:34:40.611299572 +0200
@@ -1129,7 +1129,7 @@
return;
}
parse2DigitYear(fmt, "5/6/17", date(117, UCAL_JUNE, 5));
- parse2DigitYear(fmt, "4/6/34", date(34, UCAL_JUNE, 4));
+ parse2DigitYear(fmt, "4/6/34", date(134, UCAL_JUNE, 4));
}
@nawawi
nawawi / gist:1ca6130c669a9da9dee6
Last active August 29, 2015 14:15
remove sql injecttion
<?php
/* nawawi jamili -- rutweb.com */
function _remove_sql_inject($str) {
// add more pattern
$pat[] = "/'\s+AND\s+extractvalue.*/i";
$pat[] = "/'\s+and\(.*/i";
$pat[] = "/select\s+.*?\s+from.*/i";
$pat[] = "/(rand|user|version|database)\(.*/i";
$pat[] = "/union\(.*/i";
@nawawi
nawawi / gist:19bba9230fcf7e9da96c
Created March 20, 2015 14:55
contoh duit masuk dan keluar
-- function duit masuk simpan dalam sen
-- contoh guna: INSERT INTO `test` (`duit`) VALUES ( duitmasuk('1.20') );
CREATE FUNCTION `duitmasuk`(`num` FLOAT) RETURNS int(11)
DETERMINISTIC
RETURN ( num * 100 )
-- function duit keluar dalam ringgit
-- conth guna: SELECT duitkeluar(duit) as duit FROM `test`
CREATE FUNCTION `duitkeluar`(num INT) RETURNS float
DETERMINISTIC
<?php
$noic="letak no ic";
$p = file_get_contents("https://api-rutweb.rhcloud.com/spr/?ic={$noic}");
$array = json_decode($p);
print_r($array);
@nawawi
nawawi / gist:8fc646a927d043737a4b
Last active October 30, 2017 10:52
check valid phone number format
function _check_phone_number($string, &$data = null ) {
if ( preg_match( '/^[+]?([\d]{0,3})?[\(\.\-\s]?([\d]{3})[\)\.\-\s]*([\d]{3})[\.\-\s]?([\d]{4})$/', $string, $mm ) ) {
$data = $mm;
return true;
}
// 13102016: malaysia format 00-000 000 00-000000
if ( preg_match( '/^[+]?([\d]{0,2})?[\(\.\-\s]?([\d]{2})[\)\.\-\s]*([\d]{2})[\.\-\s]?([\d]{4})$/', $string, $mm ) ) {
$data = $mm;
return true;
}
@nawawi
nawawi / check_uploaded_file.php
Created May 16, 2015 13:04
Check uploaded file
/**
* Check uploaded file
*
* @param string $file file
* @param int $max_file_length Maximum file length
* @return bool Return TRUE if Ok, FALSE otherwise.
*/
function _check_upload_filename($file, $max_file_length = 260) {
$valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-';
$file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($file) );
@nawawi
nawawi / dump_object
Created May 20, 2015 12:43
dump_object
function dump_object(array) {
var pad_char = ' ', pad_val = 2;
function repeat_char(len, pad_char) {
var str = '';
for (var i = 0; i < len; i++) {
str += pad_char;
}
return str;
};
@nawawi
nawawi / rubber stamp
Created May 26, 2015 19:09
try create rubber stamp / company stamp
<?php
$img = imagecreatetruecolor(200, 200);
// allocate some colors
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
$green = imagecolorallocate($img, 0, 255, 0);
$blue = imagecolorallocate($img, 0, 0, 255);
$blue1 = imagecolorallocate($img, 102, 104, 230);
@nawawi
nawawi / table-responsive.html
Last active April 20, 2020 02:49
table responsive
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>table responsive</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<style>
@media screen and (max-width: 600px) {
table.table-grid {
@nawawi
nawawi / check_email.php
Created July 6, 2015 17:59
check email
<?php
function _check_email($email, $strict = false) {
if ( filter_var($email, FILTER_VALIDATE_EMAIL) ) {
if ( $strict && function_exists("getmxrr") ) {
list($prefix, $domain) = split("@",$email);
return @getmxrr($domain, $maxhost);
}
return true;
}
return false;