Skip to content

Instantly share code, notes, and snippets.

View whoisryosuke's full-sized avatar
👾
Going deep with game development

Ryosuke whoisryosuke

👾
Going deep with game development
View GitHub Profile
const getInfo = async () => {
console.log(await axios.get('/users'))
console.log(await getGroups())
console.log(await getFavorites())
return 'all done';
}
getInfo();
@MaximeHeckel
MaximeHeckel / findByType.js
Last active August 17, 2018 20:02
Medium - React "sub-components" - findByType function
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)) {
@MaximeHeckel
MaximeHeckel / Article.js
Last active August 17, 2018 20:02
Medium - React "sub-component" - Title sub-component
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
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
<?php
namespace App\Http\Controllers;
use App\Models\Project;
use Illuminate\Http\Request;
class ProjectController extends Controller
{
public function update(Request $request, Project $project)
@developit
developit / nicetime.js
Last active November 27, 2018 20:57
nicetime.js
/** 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) {
<?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;
/* 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
const noPassword = ({ password, ...rest }) => rest
const user = {
id: 100,
name: 'Howard Moon',
password: 'Password!'
}
noPassword(user) //=> { id: 100, name: 'Howard moon' }
const user2 = {
id: 200,
name: 'Vince Noir'
}
const user4 = {
id: 400,
name: 'Bollo',
quotes: ["I've got a bad feeling about this..."]
}