Skip to content

Instantly share code, notes, and snippets.

View Dirk94's full-sized avatar

Dirk Hoekstra Dirk94

View GitHub Profile
@Dirk94
Dirk94 / google-cloud-screenshots.js
Created October 13, 2019 12:23
The Google Cloud function that can take screenshots of websites.
const puppeteer = require('puppeteer');
const { Storage } = require('@google-cloud/storage');
const GOOGLE_CLOUD_PROJECT_ID = "screenshotapi";
const BUCKET_NAME = "screenshot-api-net";
exports.run = async (req, res) => {
res.setHeader("content-type", "application/json");
try {
const express = require('express');
const randomEmoji = require('random-unicode-emoji');
const app = express();
app.get('/', (req, res) => {
const emojis = randomEmoji.random({ count: 10 });
res.send(emojis.join(""));
});
FROM node:12-slim
# Create an app directory in the docker
WORKDIR /app
# Copy the package.json and package-lock.json.
COPY package*.json ./
# Install production dependencies.
RUN npm install --only=production
<template>
<p>Your name is {{ name }}</p>
</template>
<script>
export default {
data() { return {
name: "Dirk",
} },
}
</script>
@Dirk94
Dirk94 / store.js
Last active February 1, 2021 12:16
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
// This is the state of the application.
state: {
todos: [
{
@Dirk94
Dirk94 / App.vue
Last active February 1, 2021 12:19
<template>
<div id="app">
<h1>Todo App</h1>
<ul>
<li v-for="todo in todos" :key="todo.message">
{{ todo.message }}
</li>
</ul>
</div>
</template>
<template>
<div id="app">
<h1>Todo App</h1>
<input type="text" @keyup.enter="addTodo()" v-model="message" placeholder="Add a to-do">
<ul>
<li v-for="todo in todos" :key="todo.message">
{{ todo.message }}
</li>
</ul>
</div>
@Dirk94
Dirk94 / store.js
Last active February 1, 2021 12:59
actions: {
async addTodo({ commit }, todo) {
// This is a fake function to illustrate the example.
const response = await postRequestToTheAPI(todo);
if (response.isOk) {
commit('ADD_TODO', todo);
}
}
}
<template>
<div id="app" style="font-size: 24px;">
<p>Quote of the day:</p>
<p>
{{ quote }}
</p>
</div>
</template>
<script>
app.get('/quote', (req, res) => {
res.set('Access-Control-Allow-Origin', 'http://localhost:8080');
res.send({
quote: "The way to get started is to quit talking and begin doing."
});
})