Skip to content

Instantly share code, notes, and snippets.

View paschalidi's full-sized avatar
🌐
in Mexico city

Christos Paschalidis paschalidi

🌐
in Mexico city
View GitHub Profile
@paschalidi
paschalidi / React.createElement
Created December 17, 2019 10:15
What is equivalent of the following using React.createElement?
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
// answer
const element = React.createElement(
'h1',
{className: 'greeting'},
@paschalidi
paschalidi / HOC example
Last active February 6, 2021 03:36
a simple HOC component
import React from 'react';
const withStorage = (WrappedComponent) => {
class HOC extends React.Component {
state = {
localStorageAvailable: false,
};
componentDidMount() {
this.checkLocalStorageExists();
2020/12/04 14:17:58 [INFO] Terraform version: 0.13.5
2020/12/04 14:17:58 [INFO] Go runtime version: go1.14.7
2020/12/04 14:17:58 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply", "--auto-approve"}
2020/12/04 14:17:58 [DEBUG] Attempting to open CLI config file: /Users/paschalidi/.terraformrc
2020/12/04 14:17:58 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory /Users/paschalidi/.terraform.d/plugins
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory /Users/paschalidi/Library/Application Support/io.terraform/plugins
2020/12/04 14:17:58 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2020/12/04 14:17:58 [INFO] CLI command args: []string{"apply", "--auto-approve"}
name: CI/CD
on: [push, pull_request]
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
class SubmitButton extends React.Component {
constructor(props) {
super(props);
this.state = {
isFormSubmitted: false
};
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit() {
@paschalidi
paschalidi / answer
Last active December 17, 2019 10:17
Given the code defined above, can you identify two problems?
Answer:
The constructor does not pass its props to the super class. It should include the following line:
constructor(props) {
super(props);
// ...
}
The event listener (when assigned via addEventListener()) is not properly scoped because ES2015 doesn’t provide autobinding. Therefore the developer can re-assign clickHandler in the constructor to include the correct binding to this:
constructor(props) {
super(props);
@paschalidi
paschalidi / Reference Types Interview
Last active December 13, 2019 14:41
A simple interiew question
var people = [
{ name: 'John Hill', age: 22 },
{ name: 'Jack Chill', age: 27 }
];
var getInitials = function( name ) {
// Reusing the name argument makes little sense in general.
// We are making this assignment here for demonstrating
// the difference between value types and reference types.
name = name.split( ' ' ).map( function( word ) {
function foo() {
// All variables are accessible within functions.
var bar = 'bar';
let baz = 'baz';
const qux = 'qux';
console.log(bar);
console.log(baz);
console.log(qux);
}
@paschalidi
paschalidi / new Keyword question
Created December 13, 2019 09:55
what will be consoled?
function Person(name) {
this.name = name;
}
var person = Person('John');
console.log(person);
console.log(person.name);
var person = new Person('John');
console.log(person);
@paschalidi
paschalidi / DOM question
Created December 13, 2019 09:44
A simple Dom interview question
<html>
<head>
<title>DOM!!!</title>
</head>
<body>
<h1 id="one">Welcome</h1>
<p>This is the welcome message.</p>
<h2>Technology</h2>
<p>This is the technology section.</p>
<script type="text/javascript">