Skip to content

Instantly share code, notes, and snippets.

View ulexxander's full-sized avatar
💪
Workin hard

Alexander Ustyugov ulexxander

💪
Workin hard
View GitHub Profile
const intSize = unsafe.Sizeof(int(0))
func intToUUID(n int) uuid.UUID {
var u uuid.UUID
intPtr := unsafe.Pointer(&n)
for i := 0; i < int(intSize); i++ {
byteptr := (*byte)(unsafe.Add(intPtr, i))
u[i] = *byteptr
}
return u
@ulexxander
ulexxander / effector-services.tsx
Last active October 1, 2021 18:31
Testing approach to write effector business logic only using factories.
import {
combine,
createEffect,
createEvent,
createStore,
Effect,
Event,
forward,
sample,
Store,
@ulexxander
ulexxander / reactCaptchaPlaceholder.ts
Last active September 28, 2021 10:23
Component that embeds ReCAPTCHA from react-google-recaptcha and saves your time in develpment because it can be replaced with placeholder
import React, { forwardRef, useEffect } from "react";
import ReCAPTCHA, { ReCAPTCHAProps } from "react-google-recaptcha";
import { setting } from "../config";
type CaptchaProps = Omit<ReCAPTCHAProps, "sitekey">;
const CaptchaPlaceholder: React.FC<{ onClick?: () => void }> = ({
onClick,
}) => {
return (
@ulexxander
ulexxander / createConfirmation.ts
Last active January 7, 2022 15:08
Effector factory - Confirmation of some action
import { createEvent, restore, sample } from "effector";
export function createConfirmation<Require, Allow>() {
type Confirmed = { require: Require; allow: Allow };
const require = createEvent<Require>();
const $payload = restore(require, null);
const allow = createEvent<Allow>();
const confirmed = createEvent<Confirmed>();