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
// Javascript program Miller-Rabin primality test | |
// based on JavaScript code found at https://www.geeksforgeeks.org/primality-test-set-3-miller-rabin/ | |
// Utility function to do | |
// modular exponentiation. | |
// It returns (x^y) % p | |
function power(x, y, 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
[ | |
{ | |
"label": "A", | |
"cells": { | |
"values": [ | |
84.97, | |
63.49, | |
62.57, | |
61.63, | |
60.7, |
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
{ | |
"headings": [ | |
"Jun", | |
"Jul", | |
"Aug", | |
"Sep" | |
], | |
"high": 9, | |
"low": 4, | |
"rows": [ |
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
export default function Editor(props) { | |
const { setEditing } = props; | |
return ( | |
<Query query={LAUNCHES}> | |
{({ data, loading, error }) => { | |
if (loading) return <p>Loading...</p>; | |
if (error) return <p>ERROR</p>; | |
return ( | |
<Fragment> | |
<Submit /> |
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
// Editor.js | |
const LOGIN = gql` | |
mutation login { | |
login(email:"${faker.internet.email}") | |
} | |
` | |
const Submit = (props) => { | |
return <Mutation mutation={LOGIN} update={(cache, { data }) => sessionStorage.setItem('auth', data.login)}> |
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, { Fragment } from 'react'; | |
import { Query } from 'react-apollo'; | |
import gql from 'graphql-tag'; | |
const qLaunches = gql`query ls { | |
launches { | |
launches { | |
id | |
site | |
mission { |
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 { Worker, isMainThread } = require("worker_threads"); | |
function runService(workerData) { | |
const worker = new Worker("./service.js", { workerData }); | |
worker.postMessage("once"); | |
worker.on("message", incoming => console.log({ incoming })); | |
worker.on("error", code => new Error(`Worker error with exit code ${code}`)); | |
worker.on("exit", code => | |
console.log(`Worker stopped with exit code ${code}`) | |
); |
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 { workerData, parentPort, isMainThread } = require("worker_threads"); | |
// You can do any heavy stuff here, in a synchronous way | |
// without blocking the "main thread" | |
parentPort.on("message", message => { | |
if (message === "exit") { | |
parentPort.postMessage("sold!"); | |
parentPort.close(); | |
} else { | |
parentPort.postMessage({ going: message }); |
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-env mocha */ | |
import chai from 'chai'; | |
import fetch, { subscribe } from './fetch'; | |
chai.should(); | |
describe('subscribe, then go', function () { | |
this.timeout(5000); | |
const handlers = { |
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-env mocha */ | |
/* eslint-disable import/no-extraneous-dependencies */ | |
// see https://www.apollographql.com/docs/link/index.html#standalone | |
import fetch from 'node-fetch'; | |
import { execute, makePromise } from 'apollo-link'; | |
import { WebSocketLink } from 'apollo-link-ws'; | |
import { SubscriptionClient } from 'subscriptions-transport-ws'; | |
import ws from 'ws'; | |
import { HttpLink } from 'apollo-link-http'; |
NewerOlder