Skip to content

Instantly share code, notes, and snippets.

View KlavierCat's full-sized avatar
:octocat:

KlavierCat KlavierCat

:octocat:
  • Platform 9¾, King's Cross Station, London
View GitHub Profile
@KlavierCat
KlavierCat / Regex for replacing react-intl with react-i18next.md
Created October 27, 2021 12:53
Regex for replacing formatMessage() in react-intl with t() in react-i18next

Here's a regex for replacing formatMessage() in react-intl with t() in react-i18next in the codebase. The solution here is VSCode compatible.

Strings without Arguments

  • Find: formatMessage\(messages.(\w+)\)
  • Replace: t('$1')

Strings with Arguments

  • Find:
    • formatMessage\(messages.([\w.]+)(,)(.+\)) - assuming that the keys are made up of alphanumericals and dots.
  • formatMessage\(messages.(\S+)(,)(.+\)) - a more wildcard match that allow any non empty space character in the keys.
@KlavierCat
KlavierCat / gist:f2ac2f8244d27136c2dc35a7235fb709
Last active February 23, 2021 22:07 — forked from ivanoats/gist:1823034
Setting up GIT Bash autocompletion. Use this only if you are using Bash instead of ZSH.
@KlavierCat
KlavierCat / GraphQLintegrationServer.js
Last active September 21, 2017 08:44
Integration Server for GraphQL testing using NodeJS (with Express) and MongoDB (with Mongoose)
'use strict';
import express from 'express';
import graphqlHTTP from 'express-graphql';
import request from 'request-promise';
import graphqlSchema from '../src/data/schema';
function start(appPort) {
const app = express();
const PORT = appPort || 9000;
@KlavierCat
KlavierCat / index.js
Created August 22, 2017 15:33
My first working Alexa skill with AWS Lambda
/**
* user setting
**/
const favBus = '38D';
const buses = ['38A', '38'];
const Alexa = require('alexa-sdk');
const APP_ID = ''; // TODO replace with your app ID (OPTIONAL).