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
<!DOCTYPE html> | |
<html> | |
<body> | |
<p>Click the button to display the fixed number.</p> | |
<button onclick="myFunction('99999999999998.5900', '', 0, '.', ',')">Try it</button> | |
<p>1</p> | |
<p id="demo"></p> |
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
/* | |
Split an array into chunks and return an array | |
of these chunks. | |
This will *not* preserve array keys. | |
*/ | |
Array.prototype.chunk = function(groupsize){ | |
var sets = [], chunks, i = 0; | |
chunks = this.length / groupsize; |
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
tinymce.addI18n('pt_BR',{ | |
"Cut": "Recortar", | |
"Heading 5": "Cabe\u00e7alho 5", | |
"Header 2": "Cabe\u00e7alho 2", | |
"Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X\/C\/V keyboard shortcuts instead.": "Seu navegador n\u00e3o suporta acesso direto \u00e0 \u00e1rea de transfer\u00eancia. Por favor use os atalhos Ctrl+X - C - V do teclado", | |
"Heading 4": "Cabe\u00e7alho 4", | |
"Div": "Div", | |
"Heading 2": "Cabe\u00e7alho 2", | |
"Paste": "Colar", | |
"Close": "Fechar", |
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
public interface CRUDService<T, K> { | |
public T create(T entity) throws ServiceException; | |
public T update(T entity) throws ServiceException; | |
public void remove(T entity) throws ServiceException; | |
public T findById(K id) throws ServiceException; | |
public Iterable<T> findAll() throws ServiceException; | |
public Page<T> findByFilter(String filter, String value, Pageable pageable) throws ServiceException; | |
default public Page<T> findByFilter(Predicate predicate, Pageable pageable) throws ServiceException { | |
return null; |
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 { ApolloServer, gql } = require('apollo-server-express'); | |
const fs = require('fs'); | |
const express = require('express'); | |
const port = 3000;; | |
const app = express(); | |
// Build a schema using GraphQL schema language from the schema file | |
const typeDefs = gql(fs.readFileSync('./schema.graphql', { encoding: 'utf-8' })); |
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
type User { | |
id: ID!, | |
name: String!, | |
description: String, | |
email: String!, | |
age: Int, | |
followers: [User] | |
} | |
type Tweet { |
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 db = require('./database'); | |
const Query = { | |
users: () => db.users.list(), | |
user: (root, { id }) => db.users.get(id), | |
tweets: (root, { userId, last }) => { | |
const tweets = db.tweets.list().filter(tweet => tweet.userId === userId); | |
return last ? tweets.slice(-last) : tweets; | |
} | |
}; |
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
// Omitted query resolver | |
const User = { | |
followers: (user) => { | |
const followersIds = db.users.get(user.id).followers; | |
const followers = []; | |
for (id of followersIds) { | |
followers.push(db.users.get(id)); | |
} | |
return followers; |
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
async function graphqlRequest(query, variables = {}) { | |
const request = { | |
method: 'POST', | |
headers: { 'content-type': 'application/json' }, | |
body: JSON.stringify({ query, variables }) | |
}; | |
const response = await fetch('http://localhost:3000/graphql', request); | |
const responseBody = await response.json(); | |
return responseBody.data; |
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
<body> | |
<button onclick="getUser()">Get user</button> | |
<script src="graphql-requests.js"></script> | |
</body> |
OlderNewer