Skip to content

Instantly share code, notes, and snippets.

View Nagibaba's full-sized avatar
💭
Bilmək olmaz

Babak Naghiyev Nagibaba

💭
Bilmək olmaz
  • Azerbaijan
View GitHub Profile
@Nagibaba
Nagibaba / gist:b45ad65239ef35db8252cb35e46e3159
Created November 15, 2023 18:02
Javascript Promise simple examples
const sumPromise = (a,b) => {
const p = new Promise((resolve, reject) =>{
if(typeof a === 'number' && typeof b === 'number'){
resolve(a+b)
} else {
reject(new Error('Tip düzgün deyil'))
}
})
@Nagibaba
Nagibaba / config-overrides.js
Last active November 7, 2022 12:08
Override create-react-app webpack config
const { addWebpackModuleRule, override } = require('customize-cra')
module.exports = {
webpack: override(
addWebpackModuleRule({
test: /\.css$/,
use: [
{
loader: "css-loader",
options: {
@Nagibaba
Nagibaba / ScrollAnimatedHeader.jsx
Created January 21, 2022 08:00
React native animated header example
import React, { useRef } from 'react';
import { SafeAreaView, StyleSheet, Text, Dimensions, Animated, View } from 'react-native';
import { Font } from '../../../../ui/components';
import { colors } from '../../../../common/constants';
export const ScrollAnimatedHeader = ({ children }) => {
const scrollPosition = useRef(new Animated.Value(0)).current;
const minHeaderHeight = 45;
const maxHeaderHeight = 140;
COMMIT
$ git reset HEAD^ <file> git commit --amend
If you accidentally commit changes to an existing file that you want to undo, then there are many ways to resolve, but I would prefer
LOG
$ git log --follow [file]
Lists version history for a file, including renames
$ git log --oneline --graph --decorate
An overview with reference labels and history graph. One commit
@Nagibaba
Nagibaba / gitflow-breakdown.md
Created July 27, 2020 05:45 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@Nagibaba
Nagibaba / EasyTooltip.js
Last active June 3, 2020 08:51
best better docs configuration for React
import React from 'react';
import pt from 'prop-types';
import { Tooltip, OverlayTrigger } from 'react-bootstrap';
/**
* A very expandable component for
* adding tooltip to elements easily.
*
* ```
* <EasyTooltip
@Nagibaba
Nagibaba / fizzapay-under-construction.markdown
Created May 27, 2020 12:40
FizzaPay Under construction
@Nagibaba
Nagibaba / JS Speed test of large string compare functions
Last active February 25, 2020 19:56
bitwise search against localCompare on same and different large strings. It will be used for a service worker approach without ETag
/*
Conclusion
On identical strings localCompare function is pretty fast, but if there is any difference, bitwise search function named "equals" is faster
*/
const CACHE = 'cache-and-update-v2.0.1';
// bitwise
function equals(a, b) {
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
@Nagibaba
Nagibaba / React Native Clear Cache
Created July 19, 2019 08:06 — forked from jarretmoses/React Native Clear Cache
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache