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 getInfo = async () => { | |
console.log(await axios.get('/users')) | |
console.log(await getGroups()) | |
console.log(await getFavorites()) | |
return 'all done'; | |
} | |
getInfo(); |
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 React from 'react'; | |
const findByType = (children, component) => { | |
const result = []; | |
/* This is the array of result since Article can have multiple times the same sub-component */ | |
const type = [component.displayName] || [component.name]; | |
/* We can store the actual name of the component through the displayName or name property of our sub-component */ | |
React.Children.forEach(children, child => { | |
const childType = | |
child && child.type && (child.type.displayName || child.type.name); | |
if (type.includes(childType)) { |
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 React, { Component } from 'react'; | |
import findByType from './findByType'; | |
import css from './somestyle.css'; | |
// We instantiate the Title sub-component | |
const Title = () => null; | |
class Article extends Component { | |
// This is the function that will take care of rendering our Title sub-component | |
renderTitle() { | |
const { children } = this.props; | |
// First we try to find the Title sub-component among the children of Article |
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
module.exports = { | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: "babel-loader" | |
} | |
} |
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 | |
namespace App\Http\Controllers; | |
use App\Models\Project; | |
use Illuminate\Http\Request; | |
class ProjectController extends Controller | |
{ | |
public function update(Request $request, Project $project) |
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
/** Returns a simple relative time string | |
* @example | |
* nicetime(new Date()-1e4) == 'Just now' // within the last minute | |
* nicetime(Date.now()-1e6) == '16m' // within the last hour | |
* nicetime(Date.now()-1e7) == '2h' // within the last hour | |
* nicetime('Dec 31, 2014') == '4d' // within the last 7 days | |
* nicetime('Dec 25, 2014') == 'Dec 25' // over 7 days ago gives a simple date | |
* nicetime('July 4, 2014') == 'Jul 4, 2014' // over half a year ago adds the year | |
*/ | |
function nicetime(text) { |
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 | |
namespace App\Http\Requests; | |
use Illuminate\Http\JsonResponse; | |
use Illuminate\Validation\ValidationException; | |
use Illuminate\Contracts\Validation\Validator; | |
use Illuminate\Http\Exceptions\HttpResponseException; | |
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest; |
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
/* eslint-disable jsx-a11y/accessible-emoji */ | |
import React, { Suspense, useState } from "react"; | |
import { unstable_scheduleCallback } from "scheduler"; | |
import { unstable_createResource as createResource } from "react-cache"; | |
import { | |
Combobox, | |
ComboboxInput, | |
ComboboxList, | |
ComboboxOption, | |
ComboboxOptionText |
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 noPassword = ({ password, ...rest }) => rest | |
const user = { | |
id: 100, | |
name: 'Howard Moon', | |
password: 'Password!' | |
} | |
noPassword(user) //=> { id: 100, name: 'Howard moon' } |
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 user2 = { | |
id: 200, | |
name: 'Vince Noir' | |
} | |
const user4 = { | |
id: 400, | |
name: 'Bollo', | |
quotes: ["I've got a bad feeling about this..."] | |
} |
OlderNewer