Skip to content

Instantly share code, notes, and snippets.

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

Tạ Trường truongtv22

🏠
Working from home
View GitHub Profile
@imranariffin
imranariffin / navigations.index.js
Last active August 7, 2021 08:51
React Native Private/Public Screen Pattern - Wrap the `@react-navigation/stack` to be auth aware (Note: replace `.` in file names with `/` to make more sense)
import AScreen from 'screens/A'
import BScreen from 'screens/B'
import MainScreen from 'screens/Main'
import SignInScreen from 'screens/SignIn'
import SignUpScreen from 'screens/SignUp'
import SomeNestedScreen from 'screens/SomeNested'
import StackNavigator from './stack-navigator'
const Navigations = () => {
@slikts
slikts / advanced-memo.md
Last active February 25, 2025 15:19
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@maapteh
maapteh / apollo-client.ts
Created November 28, 2018 16:08
apollo client with batched http and option to get out of batch by setting important on context
import { InMemoryCache, NormalizedCacheObject } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
import { ApolloLink, split } from 'apollo-link';
import { onError } from 'apollo-link-error';
import { HttpLink } from 'apollo-link-http';
import { BatchHttpLink } from 'apollo-link-batch-http';
// add fragments from apollo endpoint
import { fragmentMatcher } from './fragment-matcher';
// TODO: link http://gateway:8080/graphql and https://foo.bar/graphql for each environment
@efernandesng
efernandesng / reset_teamviewer.sh
Last active May 12, 2025 03:05
Remove "Commercial use suspected"/"Commercial use detected" warning on teamviewer 13
#!/bin/bash
##
# Remove "Commercial use suspected"/"Commercial use detected" warning on teamviewer 13
#
# Tested on Arch linux
##
CONFIG_FILE=/opt/teamviewer/config/global.conf
@loilo
loilo / pass-slots.md
Last active July 4, 2025 09:46
Vue: Pass Slots through from Parent to Child Components

Vue: Pass Slots through from Parent to Child Components

The Situation

  • We've got some components A, B and C which provide different slots.
    const A = {
      template: `<div><slot name="a">Default A Content</slot></div>`
    }

const B = {

@Godofbrowser
Godofbrowser / axios.refresh_token.1.js
Last active November 18, 2024 04:31 — forked from culttm/axios.refresh_token.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@wyhasany
wyhasany / README.md
Last active April 19, 2024 13:08
Wine configuration for QTranslate under Linux/MacOS

QTranslate for Linux

This is tutorial how to run awesome application to context translation: QTranslate The authors write on the site that they don't plan to support QTranslate for other platforms than Microsoft Windows. I felt a lack similiar solution at Linux. So I've tried to run that application at Linux Ubuntu distribution. On the end that's works I really appreciate all the help which I received at winehq forum.

Installation

@PurpleBooth
PurpleBooth / README-Template.md
Last active August 18, 2025 10:39
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@assafweinberg
assafweinberg / RelationalWrapper.js
Last active June 26, 2019 11:44
SQL Join with LokiJS
import loki from 'lokijs';
import _ from 'lodash';
class relationalWrapper {
constructor(dbName) {
this.db = new loki('dbName');
}
//Utility to strip loki meta data
_stripMetaData(obj) {
@vesse
vesse / express-jwt.js
Last active October 3, 2024 10:52
Two Passport + JWT (JSON Web Token) examples
//
// Implementation using express-jwt middle
//
var express = require('express'),
ejwt = require('express-jwt'),
jwt = require('jsonwebtoken'),
passport = require('passport'),
bodyParser = require('body-parser'),
LocalStrategy = require('passport-local').Strategy,
BearerStrategy = require('passport-http-bearer').Strategy;