Skip to content

Instantly share code, notes, and snippets.

View zrkb's full-sized avatar
❄️

Zero zrkb

❄️
View GitHub Profile
@zrkb
zrkb / TabView.swift
Created November 22, 2022 04:58 — forked from kishikawakatsumi/TabView.swift
My SwiftUI TabView
import SwiftUI
struct TabView: View {
var views: [TabBarItem]
@State var selectedIndex: Int = 0
init(_ views: [TabBarItem]) {
self.views = views
}
@zrkb
zrkb / ModelTestCase.php
Created October 31, 2020 14:52
ModelTestCase - Laravel CRUD
<?php
namespace Tests;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase;
abstract class ModelTestCase extends TestCase
{
use CreatesApplication;
@zrkb
zrkb / logging.php
Created July 1, 2020 23:38
logging request unique id
<?php
$uuid = Uuid::uuid();
$monolog = Log::getMonolog();
$monolog->pushProcessor(function ($record) use ($uuid) {
$record['extra']['request-id'] = $uuid;
$record['extra']['user'] = (Auth::user() ? Auth::user()->id : null);
$record['extra']['ip'] = \Request::getClientIp();
return $record;
@zrkb
zrkb / check.java
Created June 19, 2020 18:41
Check if Android App was installed from Google Play
val installer = context.packageManager.getInstallerPackageName(context.packageName)
val validInstallers = ArrayList(Arrays.asList("com.android.vending", "com.google.android.feedback"))
var check: Boolean = (installer != null && validInstallers.contains(installer)
@zrkb
zrkb / init_laravel.sh
Created October 22, 2019 15:08
Init new laravel project
#!/bin/bash
# Install dependencies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
# Generate env file
cp -p .env.example .env
# Generate key
php artisan key:generate
@zrkb
zrkb / .bashrc
Created September 16, 2019 20:38
.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls -lh'
alias vi='vim'
# Source global definitions
@zrkb
zrkb / CustomView.swift
Created October 24, 2018 17:18
CustomView Boilerplate
import UIKit
class CustomView: UIView {
init() {
super.init(frame: .zero)
setup()
}
required init?(coder aDecoder: NSCoder) {
@zrkb
zrkb / ruc.php
Last active April 11, 2019 14:44
Digito Verificador de Ruc Paraguayo
<?php
function digito_verificador($ci, $baseMax = 11)
{
$resultado = 0;
$index = 0;
for ($rucIndex = strlen($ci) - 1; $rucIndex >= 0; $rucIndex--) {
$resultado += (int) $ci[$rucIndex] * ($index + 2);
$r = $resultado % $baseMax;
$index++;
@zrkb
zrkb / MakeContract.php
Created September 14, 2018 15:52
MakeContract
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputArgument;
class MakeContract extends GeneratorCommand
{
/**
@zrkb
zrkb / make-contract.stub
Last active September 14, 2018 15:52
make-contract.stub
<?php
namespace App\Contracts;
interface DummyContract
{
public function handle();
}