Skip to content

Instantly share code, notes, and snippets.

@sagarpanda
sagarpanda / vim
Last active November 10, 2019 09:28
vim
# Open file
:e main.js
# Mapping keys in Vim (here onPress => , + l)
:map ,l :!node main.js<cr>
.htaccess flag list
- C (chained with next rule)
- CO=cookie (set specified cookie)
- E=var:value (set environment variable var to value)
- F (forbidden - sends a 403 header to the user)
- G (gone - no longer exists)
- H=handler (set handler)
- L (last - stop processing rules)
Last rule: instructs the server to stop rewriting after the preceding directive is processed.
@sagarpanda
sagarpanda / config.js
Created September 25, 2019 23:43
Storybook config with ThemeProvider
// File: .storybook/config.js
import { configure, addDecorator } from '@kadira/storybook';
import Theme from './../src/ui/theme';
import React from 'react';
import { ThemeProvider } from 'styled-components'
function loadStories() {
require('../stories');
}
@sagarpanda
sagarpanda / localhost.sh
Last active September 16, 2019 08:46
access localhost from internet
ssh -R 80:localhost:8080 ssh.localhost.run
ssh -R 80:localhost:3000 serveo.net
# Request multiple tunnels at once
ssh -R 80:localhost:8888 -R 80:localhost:9999 serveo.net
npm install -g localtunnel
lt --port 8000
https://github.com/localtunnel/localtunnel
https://www.pluralsight.com/guides/exposing-your-local-node-js-app-to-the-world
@sagarpanda
sagarpanda / xPathToCss.js
Last active November 24, 2018 08:27
Convert selenium Xpath to CSS
function xPathToCss(xpath) {
return xpath
.replace(/\[(\d+?)\]/g, function(s,m1){ return '['+(m1-1)+']'; })
.replace(/\/{2}/g, '')
.replace(/\/+/g, ' > ')
.replace(/@/g, '')
.replace(/\[(\d+)\]/g, ':eq($1)')
.replace(/^\s+/, '');
}
@sagarpanda
sagarpanda / webpack.config.js
Created November 11, 2018 18:07
Webpack config ref. to use MiniCssExtractPlugin
const path = require("path");
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports = {
entry: {
admin: "./React/js/App/Modules/Admin/admin.js",
@sagarpanda
sagarpanda / execSync.js
Created October 30, 2018 04:58
execSync - execute cmd in nodejs
var execSync = require('child_process').execSync;
var cmd = execSync("echo 'hello world'", { stdio: [0, 1, 2] });
http://fontello.com/
@sagarpanda
sagarpanda / macOS
Created August 12, 2017 02:11
macOS configuration
### Git autocomplete in terminal
brew install git
vi ~/.bash_profile
------------------------
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
@sagarpanda
sagarpanda / AgGrid.jsx
Created August 11, 2017 04:29
Serverside sorting and filtering
import React, { Component } from 'react';
import { AgGridReact } from 'ag-grid-react';
import axios from 'axios';
import 'ag-grid/dist/styles/ag-grid.css';
import 'ag-grid/dist/styles/theme-fresh.css';
const dataSource = {
//rowCount: null, // behave as infinite scroll
getRows: function(params) {
console.log(params);