Skip to content

Instantly share code, notes, and snippets.

View cuheguevara's full-sized avatar

Suhendra Yohana Putra cuheguevara

View GitHub Profile
@cuheguevara
cuheguevara / SMTP_validateEmail.php
Created June 23, 2014 07:51
How To Check email are exists or Not.
<?php
class SMTP_validateEmail {
/* Validate an email address. */
function validEmail($email) {
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex) {
$isValid = false;
@cuheguevara
cuheguevara / email-mx-validate.php
Created May 23, 2014 00:50
Check MX Record to Validate Email Address
<?php
class SMTP_validateEmail {
/* Validate an email address. */
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
@cuheguevara
cuheguevara / master-detail.php
Created August 7, 2013 14:15
Master Detail PHP jQuery
<?php
if (isset($_POST["tombol"]))
{
echo "<pre>";
//print_r($_POST);
echo "</pre>";
$head = $_POST["head"];
$detail = $_POST["item"];
echo "Head Looping Foreach <br/>";
@cuheguevara
cuheguevara / myuploads.php
Last active December 20, 2015 00:49
CodeIgniter Custom Uploads #libraries
<?php
public function myupload($file_name, $opt) {
$this->load->helper('directory');
$opt_folder_uploads = ( ($opt["opt_folder_uploads"] == NULL) || ($opt["opt_folder_uploads"] == "") ? "./media/uploads/news/" . date("Y-m") : $opt["opt_folder_uploads"] );
$opt_input_text_name = ( ($opt["opt_input_text_name"] == NULL) || ($opt["opt_input_text_name"] == "") ? "userfile" : $opt["opt_input_text_name"] );
$opt_type = ( ($opt["opt_type"] == NULL) || ($opt["opt_type"] == "") ? "images" : $opt["opt_type"] );
$opt_prefix = ( ($opt["opt_prefix"] == NULL) || ($opt["opt_prefix"] == "") ? NULL : $opt["opt_prefix"] );
$opt_suffix = ( ($opt["opt_suffix"] == NULL) || ($opt["opt_suffix"] == "") ? NULL : $opt["opt_suffix"] );
@cuheguevara
cuheguevara / mysql_autonumber.sql
Created April 23, 2013 05:36
Function Nomor Otomatis MySQL MySQL Autonumeric
CREATE TABLE `mahasiswa` (
`nim` INT(8) UNSIGNED ZEROFILL NOT NULL DEFAULT '00000000',
`nama` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
PRIMARY KEY (`nim`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
CREATE DEFINER=`root`@`127.0.0.1` FUNCTION `id_auto_mahasiswa`(`kodejurusan` INT, `kodekonsentrasi` INT, `kodekampus` INT)
RETURNS int(10) unsigned
@cuheguevara
cuheguevara / php_xml_parser.php
Created April 17, 2013 09:17
PHP XML Parser
<?php
function curl_get_html($options, $file) {
$ch = curl_init();
foreach ($options as $key => $value) {
curl_setopt($ch, $key, $value);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
@cuheguevara
cuheguevara / fn_explode_mysql.sql
Created April 3, 2013 16:50
split or explode in mysql
CREATE FUNCTION explode(isDelimiter VARCHAR(12),inString VARCHAR(255),position INT)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(inString, isDelimiter, position),
LENGTH(SUBSTRING_INDEX(inString, isDelimiter, position -1)) + 1),isDelimiter, '');
-- usage :
-- select explode ('|', 'suhendra|yohana|putra',1); -- give output suhendra
-- select explode ('|', 'suhendra|yohana|putra',2); -- give output yohana
-- select explode ('|', 'suhendra|yohana|putra',3); -- give output putra
@cuheguevara
cuheguevara / gist:5303007
Created April 3, 2013 16:50
split or explode in mysql
CREATE FUNCTION explode(isDelimiter VARCHAR(12),inString VARCHAR(255),position INT)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(inString, isDelimiter, position),
LENGTH(SUBSTRING_INDEX(inString, isDelimiter, position -1)) + 1),isDelimiter, '');
-- usage :
-- select explode ('|', 'suhendra|yohana|putra',1); -- give output suhendra
-- select explode ('|', 'suhendra|yohana|putra',2); -- give output yohana
-- select explode ('|', 'suhendra|yohana|putra',2); -- give output putra
@cuheguevara
cuheguevara / forceNumeric.js
Created February 20, 2013 08:02
Membuat File input hanya bisa memasukan Bilangan,
$(function ($) {
$.fn.forceNumeric = function () {
return this.each(function () {
$(this).keyup(function() {
if (!/^[0-9]+$/.test($(this).val())) {
$(this).val($(this).val().replace(/[^0-9]/g, ''));
}
});
});
};
@cuheguevara
cuheguevara / number-currency-formatter.js
Last active December 12, 2015 05:18
Javascript Formatting Numeric-Currency Value
Number.prototype.formatMoney = function(decPlaces, thouSeparator, decSeparator) {
var n = this,
decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
decSeparator = decSeparator == undefined ? "." : decSeparator,
thouSeparator = thouSeparator == undefined ? "," : thouSeparator,
sign = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
};