Skip to content

Instantly share code, notes, and snippets.

View rafpiek's full-sized avatar

Rafał Piekara rafpiek

  • Kraków, Poland
View GitHub Profile
@rafpiek
rafpiek / esbuild-dev.config.js
Created February 10, 2022 10:43
Rails Esbuild livereload
#!/usr/bin/env node
const path = require('path')
const chokidar = require('chokidar')
const http = require('http')
const clients = []
http.createServer((req, res) => {
return clients.push(
@rafpiek
rafpiek / select_detect.rb
Last active August 4, 2021 16:00
Filtrowanie elementów w tablicy
# SELECT DETECT
Book = Struct.new(:title, :author, :status)
lord_of_the_rings = Book.new('Lord of the Rings', 'Tolkien', :read)
silmarillion = Book.new('Silmarillion', 'Tolkien', :read)
clean_code = Book.new('Clean code', 'Martin', :read)
books = [ lord_of_the_rings, silmarillion, clean_code ]
#--select
@rafpiek
rafpiek / all_any.rb
Created August 4, 2021 14:59
Sprawdzanie elementów w kolekcji
# ALL? ANY?
Book = Struct.new(:title, :author, :status)
lord_of_the_rings = Book.new('Lord of the Rings', 'Tolkien', :read)
silmarillion = Book.new('Silmarillion', 'Tolkien', :read)
clean_code = Book.new('Clean code', 'Martin', :read)
books = [ lord_of_the_rings, silmarillion, clean_code ]
#--all?
import i18next from "i18next";
import locales from "./locales";
class Locales {
static init() {
i18next.init(
{
lng: "en",
debug: false,
resources: locales,
@rafpiek
rafpiek / callAll.js
Last active December 8, 2020 14:54
callAll
function callAll(...fns) {
return (...args) => {
fns.forEach(fn => {
fn && fn(...args)
})
}
}
@rafpiek
rafpiek / fetchMock.js
Last active October 11, 2020 18:44
fetchMock.js
const fetchMock = (url, suffix = "") => (
new Promise((resolve) => (
setTimeout(() => {
resolve({
json: () => (
Promise.resolve({
data: url + suffix,
}),
)
})
@rafpiek
rafpiek / init_css.scss
Created August 4, 2020 12:50
Initial general css
*, *::before, &::after {
margin: 0;
padding: 0;
font-family: $font-body;
color: $color-text-primary;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
import { constants } from "utils";
export const emailValidator = (text) => ({
isValid: constants.regex.email.test(text),
});
export const passwordValidator = (text) => ({
isValid: constants.regex.password.test(text),
});
import i18next from "i18next";
import locales from "./locales";
class Locales {
static init() {
i18next.init(
{
lng: "en",
debug: false,
resources: locales,
echo "\n================================\n"
echo "Starting build \n"
yarn build
echo "Build finished \n"
echo "\n================================\n"
echo "\n================================\n"
echo "Startin upload \n"
aws s3 cp ./build/ s3://todoardo --recursive --acl public-read
echo "Upload finished \n"
echo "\n================================\n"