Skip to content

Instantly share code, notes, and snippets.

@candrasetiadi
candrasetiadi / pipeline.php
Last active January 7, 2019 17:22
candra-jabar-digital-service
<?php
class Pipeline
{
public static function make_pipeline(...$funcs)
{
return function($arg) use ($funcs)
{
foreach ($funcs as $item) {
$arg = $item($arg);
}
@candrasetiadi
candrasetiadi / SQL-employee.sql
Last active January 7, 2019 16:21
candra-jabar-digital-service
-- Write only the SQL statement that solves the problem and nothing else.
SELECT S.name
FROM
(SELECT a.id, a.managerId, a.name FROM employees AS a) AS S
LEFT JOIN
(SELECT e.id, e.managerId, e.name FROM employees as e WHERE e.managerId IS NOT NULL) AS T
ON S.id = T.managerId
WHERE T.managerId IS NULL
@candrasetiadi
candrasetiadi / SQL-students.sql
Created January 7, 2019 15:27
candra-jabar-digital-service
-- Write only the SQL statement that solves the problem and nothing else.
select count(firstName) from students where firstName = 'John'
@candrasetiadi
candrasetiadi / palindrome.php
Created January 7, 2019 15:05
candra-jabar-digital-service
<?php
class Palindrome
{
public static function isPalindrome($word)
{
$word = str_replace(' ', '', $word);
$word = preg_replace('/[^A-Za-z0-9\-]/', '', $word);
$word = strtolower($word);
$reverse = strrev($word);