Skip to content

Instantly share code, notes, and snippets.

View jdgo-mars's full-sized avatar

João Martins jdgo-mars

View GitHub Profile
@jdgo-mars
jdgo-mars / useUserReducer.ts
Created April 15, 2019 18:18 — forked from schettino/useUserReducer.ts
Better Reducers with React and Typescript 3.4
import { useReducer } from 'react'
export function updateName(name: string) {
return <const>{
type: 'UPDATE_NAME',
name
}
}
export function addPoints(points: number) {
function existsSum(arr, n, lIndex = 0, hIndex = null, iter = 0) {
const low = arr[lIndex];
const high = arr[hIndex || arr.length - 1];
const predicate = low + high;
if(iter === arr.length - 1 ) return false;
if(predicate === n) return true;
if(predicate < n) {
// increment lower index
return existsSum(arr, n, lIndex + 1, hIndex, iter + 1);
} else {
const t = (function () {
var _listeners = {};
/**
* Compare with a new listener handler
* to make sure we are not adding the same handler
* @param String EventType
* @param Function Callback
* @returns Boolean true if exists false if not
*/
var _existsHandler = function (eventType, cb) {
// Wrap an async function so we catch any errors that might occur
const wrapAsync = handler => (req, res) =>
handler(req, res)
.then(result => res.json(result))
.catch(error => res.status(500).json({ error: error.message }))
function existsSum(arr, n, lIndex = 0, hIndex = null, iter = 0) {
const low = arr[lIndex];
const high = arr[hIndex || arr.length - 1];
const predicate = low + high;
if (iter === arr.length - 1) return false;
if (predicate === n) {
return true;
}
if (predicate < n) {
// increment lower index
import { insert } from './insert';
const input = [
{
priority: 20
}
];
test('Should return array with one element when empty', () => {
const result = insert([], { priority: 2 }, 'priority');
1. What is the difference between the '==' operator and the '===' operator
2. Explain in your own words what is GIT and how it relates to web development?
3. Declare a variable named myFirstVariable and assign it to a string "TheKit Web development Course"
4. Write a function called "add" that takes two arguments and returns their sum
5. Given an array of numbers [1,2,3,4,5,6], generate a new array with only the even numbers [2, 4, 6]
6. What is JSON format? Provide an example
7. Using the Javascript DOM API how would you select an element with an id of "container"?
8. Name 4 mouse events and their purposes.
9. Solve this exercise -> https://codepen.io/jdmartins/pen/EQjOmJ
10. Using the browser console how would you write "banana" without inputting an "N"? Hint: Look into NaN and type coercion.
	[
		{
			id: 1515665095835,
			slots: [
				{
					id: 1,
					name: 'Thuja occidentalis'
				},
				{
@jdgo-mars
jdgo-mars / Meses e Dias - Array.php
Created March 27, 2017 10:13 — forked from thallisphp/Meses e Dias - Array.php
Array com nomes dos meses e dias da semana em português do Brasil
<?php
$meses = array(
1 => 'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
@jdgo-mars
jdgo-mars / serverCodes.md
Created March 10, 2017 10:12 — forked from sgnl/serverCodes.md
status codes

1xx: Information

Code Message Description
100 Continue The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Checkpoint Used in the resumable requests proposal to resume aborted PUT or POST requests

2xx: Successful

Code Message Description