Skip to content

Instantly share code, notes, and snippets.

View chengkangzai's full-sized avatar
🎯
Focusing

Ching Cheng Kang chengkangzai

🎯
Focusing
View GitHub Profile
@chengkangzai
chengkangzai / policy.stub
Last active November 8, 2022 05:00
Policy Stub
<?php
namespace {{ namespace }};
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use {{ namespacedModel }};
use {{ namespacedUserModel }};
class {{ class }}
@chengkangzai
chengkangzai / Generate Filament Test.php
Last active December 3, 2022 08:41
Auto generate Filament Resource Test
<?php
Route::get('test', function () {
//get all the files under tests/Filament
$files = File::allFiles(base_path('tests/Feature/Filament/Resources'));
foreach ($files as $file) {
//get the className
$className = str(pathinfo($file->getFilename(), PATHINFO_FILENAME))->replace('Test', '');
//get the resource name
$modelName = str($className)->replace('Resource', '');
$modelVariables = str($modelName)->camel()->plural();
@chengkangzai
chengkangzai / gist.php
Created July 6, 2022 11:41
Generate Data Definition for academic purpose
public function index()
{
$tables = DB::select('SHOW TABLES');
$defs = collect($tables)
->pluck('Tables_in_' . env('DB_DATABASE'))
->map(function ($table) {
$data = DB::select('SELECT * FROM ' . $table . ' LIMIT 1');
return [
'table' => $table,
'columns' => DB::select('SHOW COLUMNS FROM ' . $table),
@chengkangzai
chengkangzai / gist:9eb347d3a0e9dac34912eebd2705706b
Created July 6, 2022 11:31
Parse Pest Test case name to academic Test Case
$tests = collect();
$files = File::allFiles(__DIR__ . '/../../../tests/Feature');
foreach ($files as $file) {
$baseName = $file->getBasename('.php'); //CreatePaymentActionTest
$name = str($baseName)->snake()->replace('_', ' ')->title(); //Create Payment Action Test
$realPath = $file->getPathInfo()->getRealPath(); //Feature
$nameSpace = str($realPath)->explode('/tests/Feature/')->last();
$levels = str($nameSpace)->explode('/');
$level = $levels->count();
@chengkangzai
chengkangzai / python2pseudo.py
Created February 14, 2022 09:23 — forked from BlueNexus/python2pseudo.py
Python to Pseudocode converter
import re
'''
Make sure to put
#F
as a comment at the end of lines that contain a function call that don't also contain an assignment (=).
'''
python_file = 'file.py'
work_file = None
@chengkangzai
chengkangzai / resume.json
Last active September 6, 2022 09:04
resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Ching Cheng Kang",
"label": "Programmer Internship at Softinn Solutions",
"image": "",
"email": "pycck@hotmail.com",
"phone": "",
"url": "https://www.chengkangzai.com/",
"summary": "Experienced Technical Assistant with a demonstrated history of working in the education management industry. Skilled in Firebase, Microsoft Word, Sales, jQuery, and Public Speaking. Strong administrative professional with a Diploma In Information & Communication Technology With Specialism In Software Engineering focused in Information & Communication Technology from Asia Pacific University of Technology and Innovation (APU / APIIT). ",
@chengkangzai
chengkangzai / Code.gs
Last active September 10, 2021 01:09
Website Health check with google Sheet
var spreadSheet = SpreadsheetApp.openById('####')
/**
* Helper Section
*/
function ping(url) {
try {
return UrlFetchApp.fetch(url).getResponseCode();
} catch (err) {
return 500;
}
var User = require('../models/user');
var jwt = require('jsonwebtoken');
var config = require('../config/config');
var request = require('request-promise-native');
generateToken = user => {
return jwt.sign(
{ id: user.id, username: user.username },
config.jwtSecret,
{