This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tab content is parent | |
$.each($('.tab-content :input'),function(index, dom){ | |
if(index % 2 == 0){ | |
$(dom).val(index / 2); | |
} else { | |
$(dom).val("Kendala " + index /2); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var key in responseData) { | |
// unique nominal_tarif | |
var compareKodeMataAnggaran = null; | |
responseData[key] = responseData[key].filter(function(value){ | |
if( compareKodeMataAnggaran != value.kode_mata_anggaran){ | |
compareTarif = value.nominal_tarif; | |
return true; | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Text.ParserCombinators.Parsec | |
import System.IO | |
csvFile = endBy line eol | |
line = sepBy cell (char ',') | |
cell = many (noneOf ",\n") | |
eol = char '\n' | |
parseCSV :: String -> Either ParseError [[String]] | |
parseCSV input = parse csvFile "(unknown)" input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function split_sorted() | |
{ | |
$arr = array('1','2','2','3'); | |
$output = array(); | |
$previous = null; | |
$temp = array(); | |
foreach($arr as $row){ | |
if(isset($previous) === true and $previous !== $row){ | |
$output[] = $temp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class carFactory | |
{ | |
public function createObject($carClass) | |
{ | |
$file = $carClass . '.php'; | |
require_once $file; | |
$obj = new $carClass; // magic | |
return $obj | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="post" action="form.php"> | |
<input name="person[male][first_name]" value="john" /> | |
<input name="person[male][last_name]" value="smith" /> | |
<input name="person[female][first_name]" value="jane" /> | |
<input name="person[female][last_name]" value="jones" /> | |
<input type="submit" value="Submit"> | |
</form> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Testingclass untuk User.php | |
// pakai TestCase karena gw pakai kenjis testing framework | |
Class User_test extends TestCase | |
{ | |
public function test_mockUsername(){ | |
// secara implisit, melakukan mock ke method getPost() | |
// sekarang getPost() akan return NULL | |
$model = $this->getMockBuilder('Users') | |
->setMethods(array('getUsername')) | |
->getMock(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Contoh mocking dengan membaca global variable. | |
// Buatlah fungsi private/protected untuk di mock di phpunit | |
class User | |
{ | |
public function getUsername(){ | |
return $this->getPost(); | |
} | |
protected function getPost(){ | |
return $username = $_POST['username']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
// datatables init | |
var table = $('#example').DataTable(); | |
// global variable | |
document.inputLock = false; | |
$('#example tbody').on('click', 'td', function () { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GenericTree { | |
public $root; | |
function __construct() { | |
$this->root = new Node(); | |
} |
NewerOlder