Skip to content

Instantly share code, notes, and snippets.

Avatar

Akshay Vijay Jain akshayjai1

View GitHub Profile
View gist:fe2eee5eb362f3ea76a1ebac748965f1
Last login: Mon Oct 4 10:58:38 on console
akshay@Akshays-MacBook-Pro ~ % cd code/w
akshay@Akshays-MacBook-Pro w % ls
developer-portal wso2am-3.2.0 wso2am-3.2.0.zip
akshay@Akshays-MacBook-Pro w % cd wso2am-3.2.0
akshay@Akshays-MacBook-Pro wso2am-3.2.0 % ls
INSTALL.txt bin release-notes.html tmp
LICENSE.txt business-processes repository updates
README.txt dbscripts resources wso2carbon.pid
XMLInputFactory.properties lib samples
View settings.json
{
"editor.wordWrap": "on",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"prettier.tabWidth": 2,
"prettier.endOfLine": "lf",
"prettier.jsxBracketSameLine": true,
"editor.useTabStops": false,
"git.autofetch": true,
"git.confirmSync": false,
View addressFields
[
{
"code": "AF",
"text": "Afghanistan",
"address_config": {
"city": {"tem": {"label": "City", "field": "city", "sequence": 3}},
"state": {"tem": {"label": "State", "field": "state", "sequence": 4}},
"address1": {
"tem": {"label": "Address Line 1", "field": "address1", "sequence": 1}
},
@akshayjai1
akshayjai1 / logger.tsx
Last active Nov 18, 2020
a very useful logger while development
View logger.tsx
/**
* logger
* @param data object
*/
export const log = (data: any) => {
console.log('------------------logger------------------------');
Object.entries(data || {}).forEach((t, i) => {
console.log(`\n ${i}. \t ${t[0]} is ${JSON.stringify(t[1], null, 2)}`);
});
console.log('------------------logger------------------------');
@akshayjai1
akshayjai1 / Dispatch.ts
Created Oct 2, 2020
typescript type for redux dispatch
View Dispatch.ts
import { Dispatch } from 'redux';
export interface IDom {
value?: string;
name?: string;
className?: string;
style?: any;
}
export interface IEvent {
target?: IDom;
@akshayjai1
akshayjai1 / assertNonNull.ts
Last active Jul 13, 2020
Code snippet to throw an error for Null or Undefined
View assertNonNull.ts
/**
* Code snippet to throw an error for Null or Undefined
* Container = object containing variables for example
* if we want to assert that a variable x is not null or undefined
* we can use function like this
* let x;
* assertNonNull({x}) // if x is null or undefined,
* this function will throw appropriate error
*/
export const assertNonNull = (container: any) => {
@akshayjai1
akshayjai1 / remove-node.sh
Last active Jun 13, 2020
a shell file to remove node completely from macos
View remove-node.sh
sudo rm -rf ~/.npm ~/.nvm ~/node_modules ~/.node-gyp ~/.npmrc ~/.node_repl_history
sudo rm -rf /usr/local/bin/npm /usr/local/bin/node-debug /usr/local/bin/node /usr/local/bin/node-gyp
sudo rm -rf /usr/local/share/man/man1/node* /usr/local/share/man/man1/npm*
sudo rm -rf /usr/local/include/node /usr/local/include/node_modules
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /usr/local/lib/dtrace/node.d
sudo rm -rf /opt/local/include/node /opt/local/bin/node /opt/local/lib/node
sudo rm -rf /usr/local/share/doc/node
sudo rm -rf /usr/local/share/systemtap/tapset/node.stp
brew uninstall node
@akshayjai1
akshayjai1 / copy-file.js
Last active Apr 2, 2020
node snippet to copy files matching a pattern from a folder to a new location with specific file name
View copy-file.js
const fs = require('fs-extra');
const folders = [
{
path: './build/static/css',
regex: /^(main).[\w]*.css$/,
outputFile: '../public-pages/style/sme.css'
},
{
path: './build/static/js',
regex: /^(main).[\w]*.js$/,
View Optional Chaining coalescing operation
let customer = {
name: "Carl",
details: { age: 82 },
surname: ""
};
console.log(customer?.city ?? "Unknown city";); // Unknown city
console.log(customer?.city ?? "Unknown city";); // Unknown city
console.log(customer?.surname ?? "Unknown city";); // ''
console.log(customer?.surname || "Unknown city";); // Unknown city