-
Create a variable
hero
with the your favorite superhero -
Console.log
My favorite superhero's name is XXXX
-
Create a variable
sidekick
with another name -
Console.log
The sidekick's name is YYYY
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 from "react"; | |
export default function SVGFile() { | |
return ( | |
<svg | |
xmlns="http://www.w3.org/2000/svg" | |
xlink="http://www.w3.org/1999/xlink" | |
version="1.1" | |
id="Layer_1" | |
x="0px" |
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 from "react"; | |
export default function SVGFile() { | |
return ( | |
<svg | |
xmlns="http://www.w3.org/2000/svg" | |
xlink="http://www.w3.org/1999/xlink" | |
version="1.1" | |
id="Layer_1" | |
x="0px" |
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, { useState, useEffect } from "react"; | |
import "./App.css"; | |
import SVGFile from "./svgFile"; | |
function App() { | |
const [inputValue1, setInputValue1] = useState(""); | |
const [calculatedRate, setCalculatedRate] = useState(0); | |
const handleChange = e => { | |
e.preventDefault(); | |
setInputValue1(e.target.value); |
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 dict = { | |
en: { | |
welcome: "welcome to my page", | |
menu: { | |
about: "About Me" | |
} | |
}, | |
de: { | |
welcome: "wilkommen bei meinem seite", | |
menu: { |
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
function useTranslation() { | |
// here I make locale default to the defaultLocale value | |
const { locale = defaultLocale } = useContext(LocaleContext); | |
function t(key) { | |
const pathArr = [locale, ...key.split(".")]; | |
const translation = pathArr.reduce((obj, path) => { | |
return (obj || {})[path]; | |
}, dict); | |
console.log(translation); |
I have a simple Node application that takes form data from a website and saves to a Google sheets document. Wrote this some time back and now I am trying to write tests for it.
I have the submit function which is called when the client visits the '/submit' post route. Its content are:
// submit.routes.js
function Submit(req, res, next) {
const { data, token } = req.body;
const url = `https://www.google.com/recaptcha/api/siteverify?secret=${secret_key}&response=${token}`;
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
#!/usr/bin/env python3 | |
import http.server as httpserver | |
class CORSHTTPRequestHandler(httpserver.SimpleHTTPRequestHandler): | |
def send_head(self): | |
"""Common code for GET and HEAD commands. | |
This sends the response code and MIME headers. | |
Return value is either a file object (which has to be copied | |
to the outputfile by the caller unless the command was HEAD, |
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
# Source: https://stackoverflow.com/a/26467767 | |
class Parent(object): | |
def __init__(self, name, number): | |
self.name = name | |
self.number = number | |
def scream(self): | |
print('pparent') | |
OlderNewer