Skip to content

Instantly share code, notes, and snippets.

View gippy's full-sized avatar

Jaroslav Hejlek gippy

View GitHub Profile
const Apify = require('apify');
const { PuppeteerCrawler } = Apify;
const saveScreen = async (page, key = 'debug-screen') => {
const screenshotBuffer = await page.screenshot({ fullPage: true });
await Apify.setValue(key, screenshotBuffer, { contentType: 'image/png' });
};
Apify.main(async () => {
@gippy
gippy / Dockerfile
Last active December 5, 2018 15:05
Test of Actor input schema
# Image is based on Node.js 8.X
FROM node:8-alpine
LABEL maintainer="[email protected]" Description="Image is used to run basic Apify acts"
# Remove yarn, it's not needed
RUN rm -rf /opt/yarn /usr/local/bin/yarn /usr/local/bin/yarnpkg
# Create app directory
RUN mkdir -p /usr/src/app
const { createTunnel, closeTunnel } = require('proxy-chain');
// This is how connection strings usually look like
const serviceConnectionString = '<protocol>://<auth>@<service-hostname>:<service port>';
// Create tunnel for the service, this call will start local tunnel and
// return string in format localhost:<selected-free-port> which is address
// of the local tunnel.
const tunnelInfo = await createTunnel(
'http://<username>:<password>@<proxy-server-hostname>:<proxy-server-port>',
@gippy
gippy / API
Last active January 2, 2018 13:28
setup database
setup reporting with injected database
setup s3 client
setup sequential store with injected client and reporting
init routes
GET /sequential-stores
return all stores owned by the user from database
POST /sequential-stores
Create new store in database
return the store
@gippy
gippy / Reporting
Last active January 2, 2018 13:25
class Reporting {
# DI of database connection
constructor(db) {}
getStore(store) {
find document with id of store
return the document
}
afterPush(store) {
@gippy
gippy / Schema
Last active January 2, 2018 08:35
SequentialStore = {
id: Unique ID,
owner: Owners ID,
itemsCount: Number,
persistedItemsCount: Number,
keys: Set,
fields: Set,
uploadedBytes: Number,
downloadedBytes: Number,
s3GetCount: Number,
createKey(store, new count, count of added items) {
start = new count - count of added items + 1
end = new count
return key in format '<store>/<padded start>-<padded end>'
}
class SequentialStore {
# DI of s3 client and reporting
constructor(s3, reporting){
setup buffer, s3 client and reporting
@gippy
gippy / Buffer
Last active January 2, 2018 11:20
Interface for our redis buffer
class Buffer {
push(store, record){
in a single transaction
add record to buffer - RPUSH
if this is first write into this store then save timestamp - SETNX
extract keys from the object and add them to set - SADD
increment size of the data in buffer - INCRBY
get size, number of records, unique keys - GET, LLEN, SMEMBERS
get timestamp of frist write - GET
return size, count, keys and timestamp

Co by měl fullstack React.JS programátor umět

HTML5

  • Běžně používané HTML tagy, jejich attributy a jejich použití
  • Běžně používané meta tagy
  • Vědět proč a kam vkládat link a script tagy