Skip to content

Instantly share code, notes, and snippets.

View anatooly's full-sized avatar

Anatolii B anatooly

View GitHub Profile
<Switch
style={{ transform: [{ scaleX: 0.9 }, { scaleY: 0.9 }] }}
onValueChange={handleValueChange}
value={value}
ios_backgroundColor={value ? '#B3BCB4' : '#B6B6B6'}
trackColor={{
false: '#B6B6B6',
true: '#B3BCB4',
}}
thumbColor={value ? palette.green : palette.gray}
@anatooly
anatooly / validate-branch-name
Created October 26, 2022 16:03
validate-branch-name
"postinstall": "husky install",
"validate-branch-name": {
"pattern": "^(feature|release|hotfix)/(KB-[0-9]+)-([a-zA-Z]+)",
"errorMsg": "Invalid branch name, please use name rule like this: feature/KB-123-implementNewLogic"
}
husky
husky-check-email
@anatooly
anatooly / PressableHighlight.js
Created October 17, 2022 07:53
PressableHighlight
export default function PressableHighlight(props) {
return (
<Pressable
android_ripple={{
color: '#676B5F',
}}
style={({ pressed }) => [
Platform.select({
ios: {
backgroundColor: pressed ? 'rgba(0,0,0,0.1)' : 'transparent',
@anatooly
anatooly / ArbitrarySizeViewIos.js
Created October 11, 2022 08:49
ArbitrarySizeViewIos
import React from 'react'
import {View, Platform} from 'react-native'
const ARBITRARY_SIZE = 1000
const ArbitrarySizeViewIos = (props) => {
if (Platform.OS !== 'ios') return null
const backgroundColor = props?.backgroundColor
@anatooly
anatooly / SafeAreaBackground.js
Created October 11, 2022 08:48
SafeAreaBackground.js
import React from 'react'
import {SafeAreaView} from 'react-native-safe-area-context'
const SafeAreaBackground = ({
children = null,
backgroundColorTop = '',
backgroundColorBottom = '',
}) => {
return (
<>
@anatooly
anatooly / pre-commit
Created August 12, 2022 09:40
pre-commit
#!/bin/bash
#
# Pre-commit hooks
# Check branch name
BRANCH_NAME_LENGTH=`git rev-parse --abbrev-ref HEAD | grep -E '^(?!((fix|feature)\/[a-zA-Z0-9\-]+)$).*' | wc -c`
if [ ${BRANCH_NAME_LENGTH} -eq 0 ] ; then
echo -e '\E[37;44m'"\033[1mERROR\033[0m in pre-commit hook: vim .git/hooks/pre-commit"
echo "Branch name should be like feature/lowerUpper09-EXY-134 - brand is two letters"
@anatooly
anatooly / gist:502618ee6b73b9946350ea83b07db084
Created February 17, 2022 14:47
Git push code to dev (origin/master) & customer repo (customer/main)
git remote add customer [email protected]:anatooly/test.git
git co -b main <Initial commit>
git merge --squash master
git commit -m <Commit text>
git push customer
or
rsync -rv --exclude=.git --exclude=node_modules --exclude=.next dev-dir/ customer-dir
manual commit & push from customer-dir
@anatooly
anatooly / addon.contentscript.js
Created October 15, 2021 11:52 — forked from kucheruk/addon.contentscript.js
ATI.su morpheus gist.
//content script = ship, feature component = morpheus.
console.log("Morpheus injected");
const features = new Map();
function messageToMorpheus(msg) {
window.postMessage({ direction: "from-ship", message: msg }, "*");
}
chrome.runtime.onMessage.addListener((msg, _, sendResponse) => {
@anatooly
anatooly / react-app-auth.js
Created August 30, 2021 12:27
kentcdodds.com react app auth
// @doc https://codesandbox.io/s/react-app-auth-bc99t?fontsize=14&hidenavigation=1&theme=dark&file=/src/original.js:0-1988
import React from 'react'
const sleep = time => new Promise(resolve => setTimeout(resolve, time))
const getUser = () => sleep(1000).then(() => ({username: 'elmo'}))
// .then(() => null)
const AuthContext = React.createContext()
function AuthProvider({children}) {
{
"Create React.FC typescript component RN/Relay fragment": {
"scope": "javascript,typescript",
"prefix": "#react-fc",
"body": [
"import React from 'react'",
"import { StyleSheet, View, Text } from 'react-native'",
"import { graphql, useFragment } from 'react-relay/hooks'",
"import { ${TM_FILENAME_BASE}_data$$key } from '__generated__/${TM_FILENAME_BASE}_data.graphql'",
"",