Skip to content

Instantly share code, notes, and snippets.

View anovsiradj's full-sized avatar

MDMCDC anovsiradj

View GitHub Profile
@anovsiradj
anovsiradj / v2.sql
Last active August 26, 2015 03:40
method that work for: mysql left join that count joined table
-- work, but the result not accurate
SELECT c.user_id,
c.user_fname,
COUNT(cc.user_id) AS total_child,
COUNT(ccc.user_id) AS total_consul
FROM drpp_user c
LEFT JOIN drpp_child cc
ON cc.user_id = c.user_id
LEFT JOIN drpp_consul ccc
ON ccc.user_id = c.user_id
@anovsiradj
anovsiradj / valid-username.php
Last active August 28, 2015 09:40
Regex validate username with PHP.
<?php
/**
* @version 20150828
*/
function username($str) {
$bool = preg_match('/^[a-zA-Z][a-zA-Z0-9_]+$/', $str);
$status = ($bool ? "<b>Good</b>" : "Bad");
echo $status." : ".$str."\n";
}
$kind = array(
// @param st: The string that will be trimmed. @default whitespace
String.prototype.strim = function(st) {
st = st || "\\s";
return this.replace(new RegExp("^"+st+"+|"+st+"+$",'g'),'');
}
/*
example:
"alorem ipsuma".strim('a'); // return "lorem ipsum"
" lorem ipsum ".strim(); // return "lorem ipsum"
@anovsiradj
anovsiradj / DIBACA.md
Last active May 14, 2016 13:56
Flex Actionscript

Menggunakan Flex.

mxmlc path/to/StageExample.as

Kode demo untuk tutorial di Youtube

@anovsiradj
anovsiradj / class-object.php
Created May 28, 2016 16:40
playing with php class object
<?php
// 201602211052, 201605282339
error_reporting(E_ALL); ini_set('display_errors', 1);
class Anoop {
public function bend($elm,$attack) {
if (!isset($this->{$elm})) {
$this->{$elm} = new ELement($elm);
}
$this->{$elm}->technique($attack);
@anovsiradj
anovsiradj / layout.xml
Created June 8, 2016 13:46
Blogger (blogspot) dynamic CSS class.
<!-- put inside <head/> tag -->
<style>
<b:loop index='i' values='1 to 100' var='n'>
<b:if cond='data:n%5 == 0'>
.w-<data:n/>p {width:<data:n/>%;}
.h-<data:n/>p {height:<data:n/>%;}
</b:if>
</b:loop>
</style>
// 201605201035, 201608100851
$('#side-menu').find('li.active:first').each(function() {
$(this).children('a').css('color','#eee');
$(this).parentsUntil('#side-menu','li').children('a').each(function() {
$(this).css('color','#eee').trigger('click');
});
});
@anovsiradj
anovsiradj / README.md
Last active October 27, 2016 04:43
Windows - Install Node.js and NPM.js

Tiny PHP script to generate static DirectoryIndex

  • With Dark Theme
  • Prompt asking to override, if index.html is already exist
@anovsiradj
anovsiradj / README.md
Last active May 25, 2017 07:36
HTML CountDown

Countdown

😢