Skip to content

Instantly share code, notes, and snippets.

View winarcooo's full-sized avatar
🏠
Working from Mars

Andy Winarko winarcooo

🏠
Working from Mars
View GitHub Profile
<?php
public function cacheOrDatabase(string $cacheKey, callable $callable)
{
if ($this->cache->has($cacheKey)) {
return $this->cache->get($cacheKey);
}
$fromDatabase = $callable();
if ($dataFromDatabase === null || empty($dataFromDatabase)) {
<?php
// check from cache, if not exist get using closure,
// then save to cache
$value = Cache::remember('users', $seconds, function () {
return DB::table('users')->get();
});
// wrap closure using transaction from DB facade
use Illuminate\Support\Facades\DB;
@winarcooo
winarcooo / System Design.md
Last active March 29, 2024 05:02 — forked from vasanthk/System Design.md
#systemdesign #interview

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
<?php
require_once 'Container.php';
class UserController
{
public $repository;
public function __construct(Repository $repository)
{

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@winarcooo
winarcooo / Cherry Picking Multiple Commits.md
Created September 7, 2020 13:07 — forked from grafikchaos/Cherry Picking Multiple Commits.md
Cherry pick multiple commits from a remote or upstream branch
@winarcooo
winarcooo / git
Created August 18, 2020 08:08
[git remote branch locally and remotely] #git
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
@winarcooo
winarcooo / snippet.md
Last active August 5, 2020 14:28
[switch php version] script to switch version php #bash #php
@winarcooo
winarcooo / PermMissingElem.py
Last active July 15, 2020 11:07
[PermMissingElem] Find the missing element in a given permutation. #hackerrank #codility #easy #timecomplexity #python
'''
Task description
An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing.
Your goal is to find that missing element.
Write a function:
def solution(A)