This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
combine, | |
createEffect, | |
createEvent, | |
createStore, | |
Effect, | |
Event, | |
forward, | |
sample, | |
Store, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func splitEscaped(s string, sep, esc rune) []string { | |
var pos int | |
a := strings.FieldsFunc(s, func(r rune) bool { | |
escaped := pos > 0 && rune(s[pos-1]) == esc | |
pos++ | |
return r == sep && !escaped | |
}) | |
for i, s := range a { | |
a[i] = strings.ReplaceAll(s, string(esc)+string(sep), string(sep)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
basename prop has '/' by deafult | |
it works as a prefix for all of routes, pushes, links and so on | |
*/ | |
export const App: React.FC = () => { | |
return ( | |
<Router basename="/admin"> | |
{/* ... */} | |
</Router> | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: containers must be on the same network as Prometheus | |
# And port 80 with /metrics endpoint must be exposed | |
scrape_configs: | |
- job_name: "docker_sd" | |
docker_sd_configs: | |
# Do not forget to mount docker socket into container | |
- host: "unix:///var/run/docker.sock" | |
relabel_configs: | |
- source_labels: | |
- "__meta_docker_container_id" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package random | |
import ( | |
"crypto/rand" | |
"encoding/hex" | |
"fmt" | |
) | |
func TokenHex(length int) (string, error) { | |
// Base 16 is 2x longer than Base 256 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Duration embeds time.Duration and makes it more JSON-friendly. | |
// Instead of marshaling and unmarshaling as int64 it uses strings, like "5m" or "0.5s". | |
type Duration time.Duration | |
func (d Duration) MarshalJSON() ([]byte, error) { | |
return json.Marshal(d.String()) | |
} | |
func (d *Duration) UnmarshalJSON(data []byte) error { | |
var str string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package twofactorunmarshal | |
import ( | |
"encoding/json" | |
"fmt" | |
"testing" | |
"github.com/pkg/errors" | |
) |
OlderNewer