Skip to content

Instantly share code, notes, and snippets.

import axios from 'axios';
import { faker } from '@faker-js/faker';
async function sendRequest() {
const data = {
template: 'TEMPLATE',
data: {
'title.text': faker.lorem.sentence()
}
};
@jpomykala
jpomykala / detectBrowserLocale.ts
Last active April 13, 2021 11:04
Detecting browser locale for SimpleLocalize.io
export const LOCALE_PATTERN = /[a-z]{2}_[A-Z]{2}/gi;
export const isLocaleValid = (locale: string): boolean => {
return Boolean(new RegExp(LOCALE_PATTERN).test(locale));
}
export const getBrowserLocaleOrNull = (): string | null => {
const locale = window.navigator.language; //won't work on SSR
@jpomykala
jpomykala / example.po
Created April 1, 2021 14:51
A simple example of a PO file
msgid ""
msgstr ""
"Project-Id-Version: SimpleLocalize 1.0\n"
"Report-Msgid-Bugs-To: [email protected] \n"
"Last-Translator: Jakub Pomykała <[email protected]>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
@jpomykala
jpomykala / synology-mysql-backup.sh
Last active November 10, 2019 13:32
mysql-backup.sh
#!/bin/bash
# I installed MariaDB 10 from Package Center
export PATH=/bin:/usr/bin:/usr/local/bin:/volume1/@appstore/MariaDB10/usr/local/mariadb10/bin
# Put backups in the same place where the script is placed
DB_BACKUP_PATH=`dirname "$0"`
backup-mysql() {
MYSQL_HOST=$1
@jpomykala
jpomykala / buildspec.yml
Created April 12, 2019 16:47
S3 frontend deployment CodePipeline
version: 0.1
phases:
install:
commands:
# Install nodejs https://nodejs.org/en/download/package-manager/
- curl -sL https://deb.nodesource.com/setup_7.x | bash -
- apt-get install -y nodejs
# Install yarn natively https://yarnpkg.com/en/docs/install#linux-tab
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
@jpomykala
jpomykala / jlink-me.sh
Created April 3, 2019 20:12
Java 9+ - Using jlink
@jpomykala
jpomykala / Dockerfile
Created March 16, 2019 12:27
Dockerfile for Java
FROM openjdk:11-jre-slim
LABEL maintainer="[email protected]"
ENV PATH $PATH:$JAVA_HOME/bin
ENV JAVA_OPTS "-server -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+OptimizeStringConcat -Dsun.net.inetaddr.ttl=60"
ENV HEAP_SPACE "-Xms512m -Xmx2g"
ENV REMOTE_DEBUG "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:1044"
ENV JMX "-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
ENV TIME_ZONE UTC
ENV SPRING_PROFILES_ACTIVE live
<div>
<form action="#" id="callbackForm" class="contact-form">
<div class="form-group">
<label for="email">Email</label>
<input type="email" required id="email" class="form-control" placeholder="" autocomplete="email" name="email" />
</div>
<div class="form-group">
<label for="name">Message</label>
<input id="message" type="text" class="form-control" placeholder="" name="message" />
</div>
@jpomykala
jpomykala / OfferSearchConditionFactory.java
Last active December 21, 2018 12:01
Filter params to JooQ Condition - Java 8+
public class OfferSearchConditionFactory {
public static Collection<Condition> create(OfferSearchFilter searchFilter) {
List<Condition> conditions = Lists.newArrayList();
Optional<OfferSearchFilter> filter = Optional.of(searchFilter);
filter
.map(OfferSearchFilter::getUserId)
onChangeShareValue = (newShareValue: number, ingredientRowIndex: number) => {
const {
values,
setValues
} = this.props;
const nextIngredients = [...values.ingredients];
nextIngredients[ingredientRowIndex].shareAmount = newShareValue;
setValues({...values, ingredients: [...nextIngredients]});
};