Skip to content

Instantly share code, notes, and snippets.

const check = (suma, x, requireValues) => {
const deepCheck = y => {
return y
? Object.entries(y).reduce((sumb, z) => {
return check(sumb, z, requireValues);
}, {})
: 'Required';
};
let result;
@motephyr
motephyr / index.html
Created May 9, 2019 23:41
react-konva DEMO react-konva DEMO // source https://jsbin.com/rexogokeqa
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="react-konva DEMO">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>react-konva DEMO</title>
<script type="text/javascript" src="https://cdn.rawgit.com/konvajs/konva/0.14.0/konva.min.js"></script>
<script type="text/javascript" src="https://rawgit.com/lavrton/react-konva/v1.0.1/dist/react-konva.bundle.js"></script>
<script src="http://rawgit.com/mrdoob/stats.js/master/build/stats.min.js"></script>
// app/data/resolvers.js
const resolvers = {
Query: {
...
async users() {
const users = await User.all()
return users.toJSON()
},
...
const createLoader = require('../Helpers/loaders/createLoader')
/**
* Define your loaders here.
* Each key should be a valid
* instance of DataLoader.
*/
const loaders = () => ({
user_group: createLoader('App/Models/UserGroup'),
user_personal_data: createLoader('App/Models/PersonalData', 'user_id'),
const DataLoader = require('dataloader')
/**
* Creates a dataloader for a supplied model.
*
* @param {String} model e.g. 'App/Models/User'
* @param {String} ref_id e.g. 'order_id'
* @returns {DataLoader}
*/
function createLoader(model, ref_id = 'id', has = 'one') {
//當你需要依照作者列出個人所有的文章時:
query Users{
users {
id
username
posts {
title
description
}
}
//-----types.graphql
type Post {
id: Int
user_id: Int
title: String
description: String
created_at: Date
updated_at: Date
}
FROM ubuntu:16.04
# Avoid error messages from apt during image build
ARG DEBIAN_FRONTEND=noninteractive
RUN \
apt-get update && \
apt-get install -y wget curl gnupg
alias Bootleg.{UI, Config}
use Bootleg.DSL
# Configure the following roles to match your environment.
# `build` defines what remote server your distillery release should be built on.
#
# Some available options are:
# - `user`: ssh username to use for SSH authentication to the role's hosts
# - `password`: password to be used for SSH authentication
# - `identity`: local path to an identity file that will be used for SSH authentication instead of a password
@motephyr
motephyr / worker.ex
Last active March 13, 2018 04:37
global variable
defmodule Dresser.Worker do
@moduledoc "The store, based on `Agent`."
def start_link do
result = Agent.start_link(fn -> %{} end, name: __MODULE__)
__MODULE__.put(:free_dress, 3)
result
end