Skip to content

Instantly share code, notes, and snippets.

View vamsiampolu's full-sized avatar

Vamsi Ampolu vamsiampolu

  • Sydney, Australia
View GitHub Profile
@vamsiampolu
vamsiampolu / generate_docker_container_name.js
Created June 22, 2022 03:15
Generate random names like Docker
const Chance = require('chance');
const chance = new Chance();
const left = [
"admiring",
"adoring",
"affectionate",
"agitated",
"amazing",
"angry",
" returns 1 if:
" eslintConfig exists in package.json and eslint is a devDependency
" .eslintrc exists and eslint is a devDependency in package.json
" returns 0 if
" eslint is a devDependency but no eslintConfig or .eslintrc is found,
" this is because eslint does not turn on any validation rules by default
" eslint is not a devDependency
function! HasEslint()
"a: indicates that the variable is argument scoped
"l: specifies that a variable is local to a function
@vamsiampolu
vamsiampolu / Diff Message
Created April 8, 2018 23:10
Message of the diff generated by scala-xml-diff `=#=` operator
[info] - should compare two xml nodes and check that they are the same *** FAILED ***
Neq(List(UnequalElem(music,List(UnequalElem(artist,List(UnequalElem(album,List(UnequalElem(description,List(AbsentNode(
[info] The King of Limbs is the eighth studio album by English rock band Radiohead, produced by Nigel Godrich. It was self-released on 18 February 2011 as a download in MP3 and WAV formats, followed by physical CD and 12" vinyl releases on 28 March, a wider digital release via AWAL, and a special "newspaper" edition on 9 May 2011. The physical editions were released through the band's Ticker Tape imprint on XL in the United Kingdom, TBD in the United States, and Hostess Entertainment in Japan.
[info] ), RedundantNode(The King of Limbs is the eighth studio album by English rock band Radiohead, produced by Nigel Godrich. It was self-released on 18 February 2011 as a download in MP3 and WAV formats, followed by physical CD and 12" vinyl releases on 28 March, a w
@vamsiampolu
vamsiampolu / music.xml
Created April 8, 2018 23:06
Music XML Sample
<music>
<artist name="Radiohead">
<album title="The King of Limbs">
<song title="Bloom" length="5:15"/><song title="Morning Mr Magpie" length="4:41"/><song title="Little by Little" length="4:27"/><song title="Feral" length="3:13"/><song title="Lotus Flower" length="5:01"/><song title="Codex" length="4:47"/><song title="Give Up the Ghost" length="4:50"/><song title="Separator" length="5:20"/>
<description link="http://en.wikipedia.org/wiki/The_King_of_Limbs">
The King of Limbs is the eighth studio album by English rock band Radiohead, produced by Nigel Godrich. It was self-released on 18 February 2011 as a download in MP3 and WAV formats, followed by physical CD and 12&quot; vinyl releases on 28 March, a wider digital release via AWAL, and a special &quot;newspaper&quot; edition on 9 May 2011. The physical editions were released through the band's Ticker Tape imprint on XL in the United Kingdom, TBD in the United States, and Hostess Entertainment in Japan.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}]
}
const hmr = {
entry: [FILE_PATHS.reactHotLoader, FILE_PATHS.hmrEntry,
FILE_PATHS.entry],
plugins: [
new HmrPlugin(),
new NoErrorsPlugin(),
new EnvironmentPlugin({
NODE_ENV: 'development'
})
@vamsiampolu
vamsiampolu / callingChildComponentInRender.js
Last active August 7, 2018 15:11 — forked from coryhouse/callingChildComponentInRender.js
Example of calling extracted child component in render to avoid binding or declaring an arrow function
import React from 'react';
import UserListItem from './UserListItem';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
users: [
{ id: 1, name: 'Cory' },
{ id: 2, name: 'Meg' }
@vamsiampolu
vamsiampolu / app.js
Created July 5, 2017 19:04
Server rendering svg sprite loader
import sprite from 'svg-sprite-loader/runtime/sprite.build';
const spriteContent = sprite.stringify();
// Your express app goes here
// Good luck with the rest of the server rendered configuration
res.send(`
<!DOCTYPE html>
<head>
<!-- add all your stylesheets and other stuff here, use the styled-components plugin, that is very powerful -->
@vamsiampolu
vamsiampolu / svg-to-react-component.js
Created July 5, 2017 18:57
Svg Sprite Loader runtime generator for React Component
const path = require('path');
const pascalCase = require('pascal-case');
const { stringifyRequest } = require('loader-utils');
const { stringifySymbol, stringify } = require('../../lib/utils');
module.exports = function runtimeGenerator({ symbol, config, context, loaderContext }) {
const { spriteModule, symbolModule, runtimeOptions } = config;
const compilerContext = loaderContext._compiler.context;
const iconModulePath = path.resolve(compilerContext, runtimeOptions.iconModule);
@vamsiampolu
vamsiampolu / Icon.js
Created July 5, 2017 18:50
Svg Sprite loader icon2
function Icon (props) {
// support transform in browsers that dont provide support for transforms using CSS
const {id, viewBox} = props
// using the default value for preserveAspectRatio
/*
*/
return (
<svg