Skip to content

Instantly share code, notes, and snippets.

@abhishekbhardwaj
abhishekbhardwaj / useStateIfMounted.ts
Last active February 15, 2021 14:36
useStateIfMounted: Use this instead of useState with Inertia.js if running into "Can't perform a React state update on an unmounted component". The error happens because the server-side redirect doesn't give your component enough time to clean up.
import { useEffect, useRef, useState } from "react";
export default function useStateIfMounted<T>(
initialState: T
): [T, (newState: T) => void] {
const isMounted = useRef(true);
const [state, setState] = useState(initialState);
useEffect(() => {
return () => {
@abhishekbhardwaj
abhishekbhardwaj / custom_game_engines_small_study.md
Created April 25, 2020 01:50 — forked from raysan5/custom_game_engines_small_study.md
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like Unreal or Unity for their games (or that's what lot of people think) becaus

import escapeHtml from "escape-html";
import { Text } from "slate";
export const serialize = node => {
let nodeText = escapeHtml(node.text);
if (Text.isText(node)) {
if (node["bold"]) {
nodeText = `<strong>` + nodeText + `</strong>`;
}
import { jsx } from "slate-hyperscript";
export const deserialize = el => {
const TEXT_TAGS = {
CODE: () => ({ code: true }),
DEL: () => ({ strikethrough: true }),
EM: () => ({ italic: true }),
I: () => ({ italic: true }),
S: () => ({ strikethrough: true }),
STRONG: () => ({ bold: true }),
@abhishekbhardwaj
abhishekbhardwaj / gist:edf62514302eaca83077a1d3d71e916e
Created March 21, 2019 03:42
Convert Tailwind Colors to PascalCase for ReactNative.
const _ = require('lodash');
// https://tailwindcss.com/docs/colors/#default-color-palette
let colors = {
'transparent': 'transparent',
'black': '#22292f',
'grey-darkest': '#3d4852',
'grey-darker': '#606f7b',
'grey-dark': '#8795a1',
@abhishekbhardwaj
abhishekbhardwaj / .eslintrc
Created March 19, 2019 20:58
ESLint for Typescript powered React Native Projects
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended",
"universe/native",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint"],
"settings": {
"import/resolver": {
@abhishekbhardwaj
abhishekbhardwaj / .eslintrc
Last active March 8, 2019 11:13
Setup ESLint + Prettier for Vue.js Development.
{
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": [
"eslint:recommended",
"airbnb-base",
"plugin:vue/recommended",
@abhishekbhardwaj
abhishekbhardwaj / whois.db.sh
Created December 17, 2018 07:48 — forked from kolobus/whois.db.sh
Get list of all active TLD's w/whois server
#!/bin/bash
# 1
wget -qO root.zone http://www.internic.net/domain/root.zone
# 2
cat root.zone | grep "IN\sNS" | awk '{print $1}' | uniq | sort | sed -r 's/\.//g' | sed '/^$/d' > zone.list 2> /dev/null
# 3
@abhishekbhardwaj
abhishekbhardwaj / test-hashtag-regexp.php
Created December 13, 2018 05:50 — forked from ravisorg/test-hashtag-regexp.php
pnut.io unicode hashtag parser
<?php
// You can find the test data file at https://www.ravis.org/hashtag-test.zip
// You're gonna want to have your console output supporting UTF8 before running this, or you're
// gonna see a bunch of ? in the output...
// For curiosity's sake, post number 693,847 is an emoji hashtag: #(heart)
@abhishekbhardwaj
abhishekbhardwaj / build-emoji-regexp.php
Created December 13, 2018 05:50 — forked from ravisorg/build-emoji-regexp.php
Generate a PHP compatible regular expression to match emoji from the most recent unicode data.
<?php
/**
* Uses the data from unicode.org's emoji-data.txt to build a PHP compatible Regular Expression
* along the lines of:
* (?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\x{FE0F}?)
*
* To use: php build-hashtag-regexp.php <emoji-data.txt>
* Output will be the generated regular expression.
*