Skip to content

Instantly share code, notes, and snippets.

Avatar
🌐
Try your best to be right, but don't worry when you are wrong.

Christos Paschalidis paschalidi

🌐
Try your best to be right, but don't worry when you are wrong.
View GitHub Profile
@paschalidi
paschalidi / HOC example
Last active Feb 6, 2021
a simple HOC component
View HOC example
import React from 'react';
const withStorage = (WrappedComponent) => {
class HOC extends React.Component {
state = {
localStorageAvailable: false,
};
componentDidMount() {
this.checkLocalStorageExists();
View terraform cash
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"}
View Github actions CICD with AWS Cloudfront
name: CI/CD
on: [push, pull_request]
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
View example
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 Dec 17, 2019
Given the code defined above, can you identify two problems?
View answer
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 / React.createElement
Created Dec 17, 2019
What is equivalent of the following using React.createElement?
View React.createElement
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
// answer
const element = React.createElement(
'h1',
{className: 'greeting'},
@paschalidi
paschalidi / Reference Types Interview
Last active Dec 13, 2019
A simple interiew question
View Reference Types Interview
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 ) {
View var let const - function
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);
}
View new Keyword question
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 Dec 13, 2019
A simple Dom interview question
View DOM 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">