Random Logic Code
//Tambah key array dalam array php
$comments = $this->comment->get_list($card_id);
$presence = array();
foreach ($comments as $key => $value) {
$presence_user = ($this->account->get_presence($value['user_id'])?1:0);
$comments[$key]['presence'] = $presence_user;
}
//hampir sama dengan fungsi file_exist yg ada di php
//tapi memanfaatkan ajax dan respon file not exist 404
//untuk dipakai di javascript dan multi domain (dan ada di server)
function UrlExists(url)
{
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status!=404;
}
$.ajax({ url:'http://www.example.com/somefile.ext', type:'HEAD', error: function() { //file not exists }, success: function() { //file exists } });
$hot_cards = array();
foreach($result as $r) {
$hot_cards[] = $r['card_id'];
}
//CSS SELECTORS
ul.mambo /* ul that has class mambo*/
ul .mambo /* all element with class mambo with grandparent ul*/
ul.mambo#jumbo.rambo[title="auooo"]
/* all element with
(class mambo AND class rambo AND id jumbo AND has attribute auooo)
with grandparent ul*/
<ul>
<li>Item 1</li>
<li>
<ol>
<li>Subitem 2A</li>
<li>Subitem 2B</li>
</ol>
</li>
</ul>
Conjunction
ol,ul,li
Descendant
ul li /*affect all li inside ul - get all 4 li in above example*/
Exact Descendant (don’t quite understand about it though)
ul * li /*affect second li inside ul*/
Child
ul > li /*affect only one level li below ul - get only child of ul (2 li) in above example*/ <h2>Heading</h2> <p>The selector above matches this paragraph.</p> <p>The selector above does not match this paragraph.</p>
Adjacent Sibling
h2+p /*affect only the first p in above example*/
General Sibling
h2~p /*affect all p that in the same level as h2 in above example*/ SQL Select user_id, count(komentar_id) from komentar group_by user_id
Javascript Parse string into int, isNumber
function parse(number){
return parseInt(number.replace(/\D/g, ''), 10);
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
Find duplicate entry MySQL
SELECT address, count(id) as cnt FROM list
GROUP BY address HAVING cnt > 1
end…
Be the first to start a conversation

Recent Comments