Skip to content

Instantly share code, notes, and snippets.

View marten-cz's full-sized avatar

Martin Malek marten-cz

View GitHub Profile
@marten-cz
marten-cz / tracking.js
Created September 14, 2023 10:04
Tracking code
function SporeTracking(clientID)
{
this._address = "http://trackingpic.marten-online.com/trac/tracking.gif?";
this._clientID = clientID;
this.DebugElement = null;
this._prefixTime = "smdt";
if (!this._defined)
{
SporeTracking.prototype._defined = true;
@marten-cz
marten-cz / Dockerfile
Created July 27, 2022 06:52
Docker with puppeteer
FROM node:16.15.1-alpine3.16
# Create app directory
WORKDIR /usr/src/app
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV NODE_ENV production
ENV PORT 5000
EXPOSE 5000
@marten-cz
marten-cz / Dockerfile.nginx
Created July 26, 2022 08:47
Django & React docker
FROM node
WORKDIR /app/
RUN yarn build
FROM nginx:1.11.1
RUN rm /etc/nginx/conf.d/default.conf
ADD nginx.conf /etc/nginx/conf.d/web.conf
COPY --from=builder /app/build /www/static
@marten-cz
marten-cz / server.js
Created July 8, 2022 09:27
React simple ssr
import path from "path";
import fs from "fs";
import React from "react";
import ReactDOMServer from "react-dom/server";
import express from "express";
import App from "../src/App";
const PORT = process.env.PORT || 3000;
@marten-cz
marten-cz / useCompare.js
Last active March 30, 2022 10:56
React hooks
import { useEffect, useRef } from 'react';
import isEqual from 'lodash/isEqual';
export const useCompare = (value) => {
const prevValue = usePrevious(value);
return !isEqual(prevValue, value);
};
export const usePrevious = (value) => {
const ref = useRef();
@marten-cz
marten-cz / test1.php
Last active January 8, 2022 13:01
Old interview tests
Problem: Customer complained that he is not able to log in to the system. His credentials:
username: El'Jose
Password: si"ai^#i
When the developer saw the code, he got hearthattack. Why? What is wrong with the code
PS: This was maybe for PHP 5.6, so take that to the account.
<?php
ini_set('display_errors', 1);
ini_set('register_globals', 1);
@marten-cz
marten-cz / resize.ts
Created November 13, 2021 14:40
Resize Image in JS
function resizeBase64Img(base64Str: string, maxWidth = 500, maxHeight = 500) {
return new Promise<string>((resolve) => {
const img = new Image();
img.src = base64Str;
img.onload = () => {
const canvas = document.createElement('canvas');
const MAX_WIDTH = maxWidth;
const MAX_HEIGHT = maxHeight;
let {width, height} = img;
#!/usr/local/bin/bash
apt-get update
apt-get upgrade
apt-get install -y vim mc unzip
# Docker
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
@marten-cz
marten-cz / mapping.xml
Created October 19, 2020 18:49
Mapping
<?xml version="1.0" encoding="UTF-8"?>
<map><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100451" profession_name="Referent"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100452" profession_name="Vkládání dat do počítače"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100453" profession_name="Pracovník back office"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100002" profession_name="Administrativní pracovník"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100017" profession_name="Asistentka"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100058" profession_name="Fakturantka"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100197" profession_name="Office Manager"/><branch branch_id="200900001" branch_name="Administrativa" profession_id="201100264" profession_name="Recepční"/><branch branch_id="
@marten-cz
marten-cz / docker-compose.yml
Last active June 10, 2021 09:15
Docker VPN
version: "3"
services:
php:
build:
context: ./
dockerfile: Dockerfile
depends_on:
- vpn
# This container can access services which are in VPN