Skip to content

Instantly share code, notes, and snippets.

Avatar

MDMCDC anovsiradj

View GitHub Profile
@anovsiradj
anovsiradj / v2.sql
Last active Aug 26, 2015
method that work for: mysql left join that count joined table
View v2.sql
-- 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 Aug 28, 2015
Regex validate username with PHP.
View valid-username.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(
@anovsiradj
anovsiradj / DIBACA.md
Last active May 14, 2016
Flex Actionscript
View DIBACA.md

Menggunakan Flex.

mxmlc path/to/StageExample.as

Kode demo untuk tutorial di Youtube

@anovsiradj
anovsiradj / class-object.php
Created May 28, 2016
playing with php class object
View class-object.php
<?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);
View javascript-strim.js
// @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 / layout.xml
Created Jun 8, 2016
Blogger (blogspot) dynamic CSS class.
View layout.xml
<!-- 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>
View side-menu.js
// 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 Oct 27, 2016
Windows - Install Node.js and NPM.js
View README.md
View README.md

Tiny PHP script to generate static DirectoryIndex

  • With Dark Theme
  • Prompt asking to override, if index.html is already exist
@anovsiradj
anovsiradj / datetime.bat
Last active Apr 12, 2017
Windows: cmd-datetime to Clipboard
View datetime.bat
:: DateTime to Clipboard
:: @author anovsiradj (http://ne-a-r.blogspot.com/ncr) <anov.siradj22@gmail.com>
:: @created 2016-05-04 , 09:23:44 (kerja3)
:: Result (in clipboard) yyyymmddhhii (no ss)
::pustaka
::http://ss64.com/nt/syntax-substring.html
::http://stackoverflow.com/questions/2772456/string-replacement-in-batch-file/2773504#2773504
::http://www.robvanderwoude.com/escapechars.php