Skip to content

Instantly share code, notes, and snippets.

View radicalloop's full-sized avatar
💻

RadicalLoop radicalloop

💻
View GitHub Profile
# request key: one_day / one_week / one_month / three_month / one_year
# one_day
# last 24 hrs data -- 24 data points, 1 per hour
[
{
time_point: "2022-04-14 00:00",
value: 72,
},
@radicalloop
radicalloop / Laravel-Container.md
Created July 15, 2020 07:43
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@radicalloop
radicalloop / index.js
Created March 2, 2020 12:55
Index Page (Next.js)
import withLayout from "../components/Layout";
import HomeComponent from "../components/home/Home";
import { addHomePage } from '../store/pages/action';
import api from '../api';
let Index = (props) => <HomeComponent {...props} />;
Index.getInitialProps = async ({ store, isServer }) => {
let homePage = store.getState().pages.homepage;
@radicalloop
radicalloop / _app.js
Created March 2, 2020 12:52
Overwrite "App" component in Next.js
import React from 'react'
import { Provider } from 'react-redux'
import withRedux from 'next-redux-wrapper'
import { initStore } from '../store/store'
import App from 'next/app';
const MyApp = props => {
const { Component, pageProps, store } = props
return (
<Provider store={store}>
@radicalloop
radicalloop / package.json
Created December 2, 2019 09:17
Scripts for laravel mix
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
}
@radicalloop
radicalloop / index.html
Created March 13, 2019 13:56
React Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Choose the Champ</title>
<link rel="stylesheet" type="text/css" href="css/app.css">
@radicalloop
radicalloop / composer.json
Last active January 2, 2018 18:40
Add Helpers.php in Autoload
...
"autoload": {
"files": [
"helpers.php"
]
},
...
@radicalloop
radicalloop / helpers.php
Last active June 13, 2018 11:16
helper for _dd function
<?php
if (!function_exists('_dd')) {
function _dd(...$args)
{
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
call_user_func_array('dd', $args);
}
}
@radicalloop
radicalloop / IlluminateAuthAdapter.php
Created July 5, 2017 10:59
Reimplemet IlluminateAuthAdapter of jwt-auth for kbwebs/multiauth
<?php
namespace App\Providers\Auth;
use Kbwebs\MultiAuth\MultiManager;
use Tymon\JWTAuth\Providers\Auth\AuthInterface;
class IlluminateAuthAdapter implements AuthInterface
{
/**
@radicalloop
radicalloop / eloquent.md
Created September 8, 2016 13:18 — forked from msurguy/eloquent.md
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';