Skip to content

Instantly share code, notes, and snippets.

@malikalichsan
malikalichsan / sources.list
Created January 5, 2021 09:34
/etc/apt/sources.list for ubuntu 20.10
deb http://id.archive.ubuntu.com/ubuntu/ groovy main universe restricted multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ groovy main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu groovy-security main universe restricted multiverse
deb-src http://security.ubuntu.com/ubuntu groovy-security main universe restricted multiverse
deb http://id.archive.ubuntu.com/ubuntu/ groovy-updates main universe restricted multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ groovy-updates main universe restricted multiverse
deb http://id.archive.ubuntu.com/ubuntu groovy-backports main restricted universe multiverse
deb-src http://id.archive.ubuntu.com/ubuntu groovy-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu groovy partner
deb-src http://archive.canonical.com/ubuntu groovy partner
@malikalichsan
malikalichsan / sources.list
Created January 5, 2021 09:32
/etc/apt/sources.list for ubuntu 20.04
deb http://id.archive.ubuntu.com/ubuntu/ focal main universe restricted multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ focal main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu focal-security main universe restricted multiverse
deb-src http://security.ubuntu.com/ubuntu focal-security main universe restricted multiverse
deb http://id.archive.ubuntu.com/ubuntu/ focal-updates main universe restricted multiverse
deb-src http://id.archive.ubuntu.com/ubuntu/ focal-updates main universe restricted multiverse
deb http://id.archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
deb-src http://id.archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner
@malikalichsan
malikalichsan / calculationBetweenTimes.js
Last active June 18, 2020 06:38
Calculation between times in Javascript using moment.js
const calculationBetweenTimes = (startTime, endTime) => {
let diff = moment(endTime, 'HH:mm').diff(moment(startTime, 'HH:mm'))
let d = moment.duration(diff);
let hours = Math.floor(d.asHours());
let minutes = moment.utc(diff).format("mm");
return {
hours: hours,
minutes: minutes,
}
};
@malikalichsan
malikalichsan / summaryArr.js
Last active June 18, 2020 06:24
Group by key and summary value from Array in Javascript
var instagram = [{
"name": "Instagram",
"icon": "https://example.com/instagram.jpg",
"quota": {
"quota": 10,
"unit": "GB"
}
},
{
"name": "Instagram",
@malikalichsan
malikalichsan / sources.list
Last active July 20, 2021 18:49
/etc/apt/sources.list for ubuntu 19.10
# deb cdrom:[Ubuntu 19.10 _Eoan Ermine_ - Release amd64 (20191017)]/ eoan main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
# deb-src http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan-updates main restricted
@malikalichsan
malikalichsan / DragonBall.php
Last active June 18, 2020 06:40
Basic looping using Dragon Ball as example in PHP
<?php
class DragonBall {
public $ballCount = 0;
public function iFoundBall($loop) {
for ($i = 0; $i < $loop; $i++) {
$ball = $this->ballCount+=1;
@malikalichsan
malikalichsan / SampleClass.php
Created June 25, 2019 07:51
Sample Validation Code
<?php
namespace App\Http\Controllers\System;
use App\Http\Controllers\Controller;
use App\User;
Class SampleClass extends Controller {
public function store()
@malikalichsan
malikalichsan / string.php
Last active June 25, 2019 07:40
Summarize String in PHP
<?php
$data = "1,2,3,4,5,6,7"; // String
$sum = array_sum(explode(',', $data));
print_r($sum);
@malikalichsan
malikalichsan / Pipeline.php
Created January 3, 2019 03:38
#Jabar Digital Services PHP Question 2
<?php
class Pipeline
{
public static function make_pipeline(...$funcs)
{
return function ($arg) use ($funcs)
{
foreach ($funcs as $function) {
if(!isset($value))
$value = $function($arg);
@malikalichsan
malikalichsan / Palindrome.php
Last active June 18, 2020 11:49
#Jabar Digital Services PHP Question 1
<?php
class Palindrome
{
public static function isPalindrome($string)
{
$string = str_replace(' ', '', $string);
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
$string = strtolower($string);