Skip to content

Instantly share code, notes, and snippets.

View indapublic's full-sized avatar
🏠
Working from home

Vasilii indapublic

🏠
Working from home
View GitHub Profile
@epicbytes
epicbytes / example.api.ts
Last active February 6, 2024 18:28
NextJS Authorization Files
/*** function that used as middleware ***/
accessToken: async (name) => {
if (typeof document === "undefined") return "";
let token = document.cookie
.split(";")
.filter((cookie) => cookie.startsWith("token"))[0];
if (!token) {
const response = await fetch("/api/refresh", { method: "POST" });
@vovkasm
vovkasm / KeyboardDismisser.tsx
Last active March 29, 2019 22:31
How to hide keyboard by click outside text field withotu ScrollView
// tslint:disable:object-literal-sort-keys
import React from 'react'
import { GestureResponderEvent, LayoutRectangle, NativeTouchEvent, UIManager } from 'react-native'
// HACK
import { blurTextInput, currentlyFocusedField, isTextInput } from 'App/lib/extendedTextState'
/**
* Touchable states.
@danielkcz
danielkcz / formik-mobx.js
Last active July 26, 2023 21:51
Formik with MobX
function useFormik(props) {
// useState to keep the same observable around without recreating it on each render
const [formik] = React.useState(() =>
mobx.observable({
values: props.initialValues || {},
touched: {}
})
)
// just mutate state, this function itself can be considered an action+reducer
@neretin-trike
neretin-trike / pug.md
Last active April 24, 2024 18:22
Туториал по HTML препроцессору Pug (Jade)
@du5rte
du5rte / autoStore.js
Last active March 8, 2023 12:10
Auto saving to localStorage with MobX
import mobx from "mobx"
import store from "store"
export default function(_this) {
let firstRun = true
// will run on change
mobx.autorun(() => {
// on load check if there's an existing store on localStorage and extend the store
if (firstRun) {
@miljan-aleksic
miljan-aleksic / calendar-matrix.js
Last active August 19, 2022 12:24
Calendar Matrix (date-fns, ES6) inspired by https://github.com/bclinkinbeard/calendar-matrix
import getYear from 'date-fns/get_year'
import getMonth from 'date-fns/get_month'
import addDays from 'date-fns/add_days'
import startOfWeek from 'date-fns/start_of_week'
const rows = range(6)
const cols = range(7)
/**
* Returns a two-dimensional array with calendar represented dates
@mcsepes
mcsepes / bookmarks.xml
Last active March 18, 2023 12:08
Radio Tray bookmarks
<bookmarks>
<group name="root">
<group name="ETHNIC / FOLK / SPIRITUAL MUSIC">
<bookmark name="Indian Folk/Ethnic" url="http://79.111.14.76:9021/"/>
<bookmark name="Russian Folk Music" url="http://79.120.77.11:9057/"/>
<bookmark name="Православная Духовная Музыка" url="http://79.111.14.76:9127/"/>
<bookmark name="Flamenco" url="http://79.111.14.76:9055/"/>
<bookmark name="Tango" url="http://79.120.39.202:9117/"/>
<bookmark name="Middle East Music" url="http://79.111.119.111:9133/"/>
<bookmark name="Celtic Music" url="http://79.111.14.76:9087/"/>
@almost
almost / 1-react-native-simulator-and-device.md
Last active November 17, 2022 14:05
Test React Native on the simulator and on a device without editing the code each time!

In the default React Native app scaffolding you have to edit AppDelegate.m to change where it loads the code if you want to test on your device. I use the following snippet to detect if it's being compiled for Debug or Production and for the Simulator or a device. For Production it uses a copy of the code included in the bundle, for Debug on the simualtor it loads from a server on localhost and for Debug on a device it loads from a server on a given IP address.

NOTE: You need to edit YOUR-IP-HERE and change it to the IP to load the code from when in Debug mode on a device. You could use a service like ngrok to make this work from anywhere.

  NSURL *jsCodeLocation;

  // Loading JavaScript code
  #if DEBUG
    // For Debug build load from development server. Start the server from the repository root: