Skip to content

Instantly share code, notes, and snippets.

View donamkhanh's full-sized avatar

Do Nam Khanh donamkhanh

View GitHub Profile
function daysInMonth(iMonth, iYear)
{
return 32 - new Date(iYear, iMonth, 32).getDate();
}
# [29.51 ms] SELECT SUM(point) AS total_point FROM booking_multichoice WHERE mul_id IN (19372)
# [0.36 ms] UPDATE website_cv_answer SET total_point = '7' WHERE aid='5152'
# [0.41 ms] SELECT SUM(point) AS total_point FROM booking_multichoice WHERE mul_id IN (19381)
# [0.44 ms] UPDATE website_cv_answer SET total_point = '0' WHERE aid='5668'
# [0.47 ms] SELECT SUM(point) AS total_point FROM booking_multichoice WHERE mul_id IN (19396)
# [0.62 ms] UPDATE website_cv_answer SET total_point = '0' WHERE aid='5671'
# [0.51 ms] SELECT SUM(point) AS total_point FROM booking_multichoice WHERE mul_id IN (19402)
# [0.4 ms] UPDATE website_cv_answer SET total_point = '0' WHERE aid='5677'
# [0.67 ms] SELECT SUM(point) AS total_point FROM booking_multichoice WHERE mul_id IN (19438)
# [0.5 ms] UPDATE website_cv_answer SET total_point = '0' WHERE aid='5680'
Directories: 274
Files: 2000
Lines of Code (LOC): 651963
Cyclomatic Complexity / Lines of Code: 0.12
Comment Lines of Code (CLOC): 157592
Non-Comment Lines of Code (NCLOC): 494371
Namespaces: 0
Interfaces: 47
Directories: 11
Files: 690
Lines of Code (LOC): 372365
Cyclomatic Complexity / Lines of Code: 0.11
Comment Lines of Code (CLOC): 39341
Non-Comment Lines of Code (NCLOC): 333024
Namespaces: 0
Interfaces: 1
SELECT booking_campaign.cv_id,
booking_campaign.psychometric_id,
booking_campaign.is_completed,
booking_campaign.fullname,
booking_campaign.candidate_status,
question_point.score_percen,
candidate_extra_service.iq_tests,
candidate_extra_service.iq_tests_service_cost,
candidate_extra_service.reference_checks,
candidate_extra_service.reference_checks_service_cost,
@donamkhanh
donamkhanh / json_encode bug
Created April 7, 2010 09:54
json_encode returns null for certain strings. See: http://bugs.php.net/49588
<?php
$a = "Hello, I'm an other charset éc éc";
$b = htmlentities($a, ENT_QUOTES, 'UTF-8');
$c = htmlentities($a);
echo "\n", json_encode($a); //ouput will be "Hello, I'm an other charset "
echo "\n", json_encode($b); //ouput will be "" (NULL)
echo "\n", json_encode($c); //ouput will be "Hello, I'm an other charset &eacute;c &eacute;c"
$today = date('Y-m-d', $mediaTimestamp);
Zend_Debug::dump($placementDate); //output is 2010-08-28
if( empty($placementDate) ) {
$placementDate = $today;
}
else {
$placementDate = date('Y-m-d',$mediaTimestamp);
}
UPDATE prepaid_pack p
INNER JOIN booking_detail bd
ON bd.pack_id = p.pack_id AND bd.related_pack_id = p.pack_id
SET first_used_date = (
SELECT MIN(booked_date)
FROM booking_detail
WHERE pack_id = p.pack_id AND related_pack_id = p.pack_id
)
WHERE p.ad_type != 'subscription'
@donamkhanh
donamkhanh / gist:2720326
Created May 17, 2012 17:22
Get root parent of element by row id. Root parent is TR has class = ".parent" and depth = 0
<html>
<head>
<title>Test parent</title>
<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
var a = '';
var i = 0;
while(i >= 0) {
a += '.parent()';
@donamkhanh
donamkhanh / gist:3706083
Created September 12, 2012 11:34
SELECT DISTANCE
SELECT *
FROM (SELECT *,
((2 * 3960 *
ATAN2(
SQRT(
POWER(SIN((RADIANS(47.470779 - latitude))/2), 2) +
COS(RADIANS(latitude)) *
COS(RADIANS(47.470779 )) *
POWER(SIN((RADIANS(-87.890699 - longitude))/2), 2)
),