Skip to content

Instantly share code, notes, and snippets.

@40thieves
40thieves / aliases.sh
Last active September 26, 2016 11:04
Some useful docker aliases
# Filter containers by a given name, then tail the logs
# Example: `docker_logs client`, tails the logs within a container where the name contains "client"
function docker_logs() {
docker logs $(docker ps --filter "name=$1" -q) --tail 1 --follow
}
# Filter containers by a given name, then execute a command in that container
# Example: `docker_exec client npm test`, executes `npm test` within a container where the name contains "client"
function docker_exec() {
CONTAINER="$1"; shift; COMMAND="$@"
{
"extends": "airbnb",
"parser": "babel-eslint",
"plugins": [
"babel"
],
"rules": {
// Tabs, just because
"indent": [2, "tab"],
@40thieves
40thieves / check.js
Last active July 18, 2017 08:25
Check for missing npm dependencies before starting node script
#!/usr/bin/env node
var npmCheck = require('npm-check')
npmCheck({ skipUnused: true })
.then((state) => {
const missing = state.get('packages').filter((p) => p.notInstalled)
if (missing.length) {
import React from 'react'
import ReactDOM from 'react-dom'
class HelloWorld extends React.Component {
render() {
return <h1>Hello World</h1>
}
}
class HelloCodeYourFuture extends React.Component {
[
{
"title": "Mr",
"firstName": "John",
"surname": "Doe",
"email": "johndoe@doe.com",
"roomId": 2,
"checkInDate": "2017-11-21",
"checkOutDate": "2017-11-23"
},

Homework Exercises

  1. Write a function which takes 2 numbers and tells the user the result of the number's addition, subtraction, multiplication and division. The log should be formatted like: "For numbers {firstNumber} and {secondNumber}, the addition is {addition}, the subtraction is {subtraction}, the multiplication is {multiplication} and the division is {division}".

  2. Write a function to log the grade of a student in an examination. The student will get A+ grade if the mark is in the range 90 - 100 (inclusive), A if the mark is in the range 80 - 89, B if the mark is in the range 70 - 79, C if the mark is in the range 60 - 69, D if the mark is in the range 50 - 59 and E if the mark is 49 or lower.

  3. Write a function which takes an integer number and checks if it is within 20 digits of 100 or within 20 digits of 400.

  4. Write a function which takes a city name and checks whether it is one of the Code Your Future cities (London, Glasgow, Manchester). If it is one of the CYF cities, log a succe

.figure {
border: 1px solid $grey-light-medium;
padding: 10px;
background: $white;
}
.figure-img {
padding-bottom: 5px;
border: none;
}
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFu7H3gBEADMwsszOxErzCY6ws/ME+dA1bSlpiKCib3/XePhIG9au2+2JrZ+
T6YbwHZvbfVPekDA4hSFxPIIe8Lwp8Wq9ybedKCfq98tdZSG9PpPIKhWcUNY/D9Y
IsblFMHRaZxIRvT1k7g9mS4UOVgWGWHy5x0sgkN7FSvO2B7mlcIboAk9qhuJVBdZ
bFMsGNyB0BTo7fdRztj8/JArtcH8IbR09Py153mvhEQGjv68INcSx6CkA2LBbeTD
RmUP9VGb1nAIO02SX+Hx3HJSrQpECBo09QqnFc6dDOGdY1QX61CeObATT4AuYNXD
PIhtHC4iwKrTA9g22j1588Hr4dEmuhtGtBhvYVE5ufEN/EuHZPRhQ7L41za46HUI
8J+CamEhnMck7qn9SV+1NM9qPs4aI6XnwJ7x+Eod19uRuxbVyPXsdaC5lzMJ2WG7
fxazE4QQ7FYSY1ssjfUw6VGA5lqAjsT/JadI5/uiCpA1HtkvPbRHBzUN1MzXogrg

Create a form that:

  1. Has a dropdown to select an option from a list
  2. An input to type out a short sentence
  3. A longer textbox to write out a paragraph of text
  4. A submit button
  5. Has useful labels for each field
  6. Code that runs when the submit button is clicked
  7. Code to make a POST request containing the form data
  8. Code to check form validation
/*
* Example 1
*/
function example1() {
return "Ali".ToUpperCase();
}
console.log(example1());
/*
* Example 2