Skip to content

Instantly share code, notes, and snippets.

View blood72's full-sized avatar

Kim Dong-Hyeon blood72

  • @marketboro 마켓보로
  • South Korea
  • 16:38 (UTC +09:00)
View GitHub Profile
<?php
namespace App\Concerns;
use App\Casts\HashableKey;
trait CanRouteKeyHashing
{
/** @var bool */
protected $hashedKey = false;
<?php
if (! function_exists('random_float')) {
/**
* Generates random float number.
*
* @param int|float $min
* @param int|float $max
* @param int $digit
* @return float|int
@blood72
blood72 / Character.php
Last active April 23, 2020 07:45
Return character(s) for each position(s) to string
<?php
use Illumniate\Support\Str;
if (! Str::hasMacro('character')) {
Str::macro('character', static function ($value, $positions, $glue = '') {
if (! is_array($positions)) {
$positions = [$positions];
}
@blood72
blood72 / isSoftDeleting.php
Last active March 17, 2020 03:41
Determine if the model implements soft deletes and does soft delete.
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Model;
trait isSoftDeleting
{
/**
* Determine if the model implements soft deletes and does soft deleting.
@blood72
blood72 / IsEncrypted.php
Created February 19, 2020 05:57
IsEncrypted.php
<?php
use Illuminate\Support\Facades\Validator;
Validator::extend('encrypted', function ($attribute, $value, $parameters, $validator) {
try {
return decrypt($value);
} catch (\Illuminate\Contracts\Encryption\DecryptException $exception) {
return false;
}
@blood72
blood72 / Directory.php
Last active June 25, 2019 06:31
Route::file, Route::directory macro with route_path() helper in Laravel
<?php
use Illuminate\Support\Facades\Route;
if (! Route::hasMacro('directory')) {
Route::macro('directory', function ($path, $attributes = [], $recursive = false) {
$route = $this; // for IDE
/** @var Route $route */
return $route->group((array) $attributes, function () use ($path, $recursive) {
foreach (File::{$recursive ? 'allFiles' : 'files'}($path) as $file) {
@blood72
blood72 / treeorder.c
Created May 30, 2019 06:45
학창 시절에 만든 C언어 이진 트리 순회
#include <stdio.h>
#include <stdlib.h>
typedef struct TreeNode
{
int data;
struct TreeNode *llink, *rlink;
} TreeNode;
/*
@blood72
blood72 / stack.c
Created May 30, 2019 06:39
학창 시절에 만든 C언어 스택 (feat. 후위표기식 변환)
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable:4996)
// 노드 정의 선언
typedef struct
{
int item;
@blood72
blood72 / SortData.c
Created May 30, 2019 06:31
학창 시절에 만든 C언어 정렬비교
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <malloc.h>
#pragma warning(disable:4996)
// 선택 정렬
void SelectionSort(int list[], int n)
{
int i, j, least, temp;
@blood72
blood72 / LinkedListADT.c
Created May 30, 2019 06:30
학창 시절에 만든 C언어 구조체 연결리스트 (int형 / char형 주석구분)
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996) //scanf 에러문 무시
// #define BUF_SIZE 100 // char 형태 데이터
// #define NAME_SIZE 20 // char 형태 데이터
typedef struct Node{
int data; // int 형태 데이터