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
@props(['url', 'field', 'error', 'selected' => null, 'extra' => null]) | |
<div wire:ignore> | |
<select {{ $attributes->merge(['style' => 'width:100%', 'class' => 'mt-1 block w-full py-2 px-3 bg-white rounded-md shadow-sm focus:outline-none | |
sm:text-sm'])->except('wire:model') }}> | |
@if ($selected)<option value="{{ $selected[0] }}" selected="selected">{{ $selected[1] }}</option>@endif | |
</select> | |
</div> | |
@if (!empty($error))<span class="text-red-500 text-sm">{{ $error }}</span>@endif |
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 { useState, useEffect } from 'react'; | |
import api from 'utils/api'; | |
const useFecth = (url, params) => { | |
const [response, setResponse] = useState(null); | |
const [error, setError] = useState(null); | |
const [isLoading, setIsLoading] = useState(true); | |
useEffect(() => { |
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
Promise.allValues = async (object) => { | |
return _.zipObject(_.keys(object), await Promise.all(_.values(object))) | |
} |
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
const memoize = function(f) { | |
let cache = {}; | |
return function(...args) { | |
const arg_str = JSON.stringify(args); | |
cache[arg_str] = cache[arg_str] || f.apply(f, args); | |
return cache[arg_str]; | |
} | |
} |
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
const greaterThan = (thisNumber) => (anotherNumber) => anotherNumber > thisNumber; | |
const greaterThan10 = greaterThan(10); | |
const greaterThan2 = greaterThan(2); | |
console.log('12 > 10 = ', greaterThan10(12)); // 12 > 10 = True | |
console.log('8 > 10 = ', greaterThan10(8)); // 8 > 10 = False | |
console.log('3 > 2 = ', greaterThan2(3)); // 3 > 2 = 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
from random import choice | |
from string import ascii_lowercase, ascii_uppercase, digits | |
from tkinter import Tk, Entry, Button, StringVar | |
def random_string(length): | |
return ''.join(choice(ascii_lowercase + digits + ascii_uppercase) for i in range(length)) | |
root = Tk() | |
root.title('32 chars random string generator') |
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 | |
/* index.html */ | |
class __TwigTemplate_37a968442c22648ceb4a16069820cc5350b97e50f45f26c5442d7c036ad743d2 extends Twig_Template | |
{ | |
public function __construct(Twig_Environment $env) | |
{ | |
parent::__construct($env); | |
$this->parent = $this->env->loadTemplate("base.html"); |
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 datetime | |
month_placeholder = { | |
'Jan' : 1, | |
'Feb' : 2, | |
'Mar' : 3, | |
'Apr' : 4, | |
'Mei' : 5, | |
'Jun' : 6, | |
'Jul' : 7, |
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 EWebUser extends CWebUser{ | |
// ini buat pengecekan level akses tiap user | |
function getLevel(){ | |
$level = Yii::app()->user->getState('level'); | |
return $level; | |
} | |
function isAdmin(){ // apakah user adalah admin? | |
return Yii::app()->user->getState('level') == 1; |
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 | |
function transform($numbers){ | |
$rules = [ | |
1 => 'a', | |
2 => 'b', | |
3 => 'c', | |
4 => 'd', | |
5 => 'e', | |
6 => 'f', |
NewerOlder