Scala
def factorial(n: Int) = {
def tailFactorial(n: Int, acc: Int): Int =
if (n == 0) acc else tailFactorial(n - 1, acc * n)
tailFactorial(n, 1)
function extractEndpointNames (json) { | |
function recurExtract (json, result) { | |
for (let key in json[0]) { | |
if (Array.isArray(json[0][key])) { | |
recurExtract( | |
json[0][key], | |
result | |
) | |
} else { | |
if (key === 'args') { |
var refreshButton = document.querySelector('.refresh') | |
var refreshClickStream = Rx.Observable | |
.fromEvent(refreshButton, 'click') | |
var startupRequest = Rx.Observable | |
.just('https://api.github.com/users') | |
var reqOnRefreshStream = refreshClickStream | |
.map(event => { |
const d = document; | |
//* Basic setup | |
const first = d.createElement('a'); | |
first.innerText = 'Holi Primero'; | |
first.setAttribute('href', '#/first') | |
const second = d.createElement('a'); | |
second.innerText = 'Holi Segundo'; | |
second.setAttribute('href', '#/second') |
import { when, equals, always, __ } from 'ramda' | |
//* Return a value when a certain value is provided | |
const parseTitleRamda = value => ( | |
when(equals('workflow', __), always('endpoints'))(value), | |
when(equals('integration', __), always('connections'))(value) | |
) | |
const parseTitle = title => { | |
if (title === 'workflow') return 'endpoints'; |
export function * fetchAllWorker (action) { | |
yield put(actions.fetchAll.start()) | |
const { types } = action.payload | |
for (let i = 0; i < types.length; i++) { | |
const { res, error } = yield call(get, `js_helpers/${types[i]}`) | |
if (res.status > 201 || error) { | |
return put(actions.fetchAll.failure({ error })) |
import { omit, pipe, assoc } from 'ramda'; | |
const stringifyJson = e => JSON.stringify(e, null, '\t'); | |
const parsedJson = e => JSON.parse(e.replace('\t', '')); | |
const moduleDefinitionInput = pipe(omit(['staticDisplayName']), stringifyJson); | |
const moduleDefinitionOutput = pipe(parsedJson, assoc('staticDisplayName', staticDisplayName)); | |
moduleDefinitionInput(content); | |
moduleDefinitionOutput(content); |
const CONSONANTS = ['q', 'w', 'r', 't', 'y', 'p', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']; | |
const VOCALS = ['a', 'e', 'i', 'o', 'u']; | |
const buildPair = (cons, vocal) => | |
cons | |
.reduce((res, e) => { | |
const pair = VOCALS.map(v => e + v); | |
res.push(pair); | |
Nightwatch
is a testing tool made in Node
and Selenium
to test browser apps. Long story short you can set it to navigate (really, truly, navigate) your site to test it as if it was a real person.
After you setup your environment, add your tests and run them Nightwatch
will open a browser and start interacting with your site in realtime (you can see the whole thing). It will starting clicking around based on what you told it it should click and test if it encounters what you told it it should encounter.
Ok, so lets get to it!
I'm not gonna focus much in the setting up process (I'm much more interested in the API and the use cases) but this is a summary of what you should do in Mac: (full instructions in the Nightwatch website)
Refs are a reference to the DOM node created by a React element after rendering. There are some scenarios when you need to operate on the node element (the actual DOM node that is rendered to the view) rather than the element used by React in the virtual DOM. My case scenario: I needed to let the user download an image that was generated with a canvas in the virtual DOM. The only way to do this was to wait for the page to be fully rendered and do some stuff on the canva's node element.
With ref
you can access the node element that an element from the virtual DOM will generate after its done, like this:
render() {
return (