Skip to content

Instantly share code, notes, and snippets.

function makelist(x) {return [x]}
makelist(document.head[0])
makelist("DKC:TF")
makelist("6502")
makelist(0xf13e455d7a1b96cd2d930e578284d889)
var printNumbers = () => {
[1,2,3].forEach((number) => console.log(`Hello, ${number}`))
}
printNumbers()
var print = (list) => {
list.forEach((number) => console.log(`Hello, ${number}`))
}
print([1,2,3])
print(["D","K","C"])
var print = (list) => {
list.forEach((item) => {
// naming become harder :(
var itemDescription
if (typeof item === "object") {
itemDescription = item.name
} else {
itemDescription = item
}
console.log(`Annyong, ${itemDescription}`)
var print = (list) => {
list.forEach((item) => {
var itemDescription
if (typeof item === "object") {
itemDescription = item.name || item.brand
if (item.arch) {
itemDescription = `${item.name} - ${item.arch}`
}
} else {
itemDescription = item
var defaultPrint = (item) => console.log(`Hello, ${item}`)
var myForEach = (list, printFunction = defaultPrint) => {
list.forEach((item) => printFunction(item))
}
myForEach([1,2,3])
myForEach(["D","K","C"])
myForEach([{name: "Tomba!"},{name: "Neo Cortex"}], (person) => defaultPrint(person.name))
myForEach([{brand: "Ferrari"}, {brand: "Mercedes"}], (car) => defaultPrint(car.brand))
myForEach([{name: "N64", arch: "MIPS"}, {name: "3DS", arch: "ARM9"}], (console) => defaultPrint(`${item.name} - ${item.arch}`))
rails new myapp --skip-active-record
# we'll use an existent image which already have ruby installed
FROM ruby:2.3.0
# creating our app folder
RUN mkdir /myapp
# move to this folder
WORKDIR /myapp
# move the Gemfile to our app's root folder
ADD Gemfile /myapp/Gemfile
# move the Gemfile.lock too
ADD Gemfile.lock /myapp/Gemfile.lock
# we'll call our web app of web
web:
# it'll build this container based the docker file ./Dockerfile
build: .
# it'll run this command to star the server
command: bash -c "rm -f tmp/pids/server.pid || true && bundle exec rails s -p 3000 -b '0.0.0.0'"
# it'll export the port 3000
ports:
- "3000:3000"
# it links to db container (on mongoid.yaml at rail's config we say host: db:27017 it's linked)
# we'll build our container from an existent image :)
FROM nginx
# for some reason we need to create this folder
RUN mkdir -p /var/lib/nginx/proxy
# copy our app config to nginx
COPY sites-enabled/myapp.conf /etc/nginx/nginx.conf