Skip to content

Instantly share code, notes, and snippets.

View agneym's full-sized avatar

Agney Menon agneym

View GitHub Profile
@agneym
agneym / nginx.conf
Created June 15, 2021 19:00 — forked from foxxyz/nginx.conf
Serve current directory via nginx
# Extremely basic development setup to serve the current directory at http://localhost:9001
# Start nginx in this directory with `nginx -p . -c nginx.conf`
# Stop nginx with `nginx -p . -s stop`
events {}
http {
# Serve files with correct mimetypes on OSX
# location may have to be adjusted depending on your OS and nginx install
include /usr/local/etc/nginx/mime.types;
// Set a page title in app.module.ts
@NgModule({
imports: [
BrowserModule,
ReactiveFormsModule,
RouterModule.forRoot([
// ProductListComponent does not have a title
{ path: '', component: ProductListComponent },
// This page has a title
@agneym
agneym / prettier-airbnb.md
Created February 24, 2020 17:27
Prettier with AirBnB ESLint Config

Install:

npm i prettier --save-exact
npm i husky lint-staged eslint-config-prettier

On eslintrc.js:

@agneym
agneym / Coffee.js
Created February 14, 2020 15:10
Buy me a Coffee with React and Styled Components
import React from 'react';
import styled from 'styled-components';
const Button = styled.a`
line-height: 2;
height: 5rem;
text-decoration: none;
display:inline-flex;
color: #FFFFFF;
background-color: #FF813F;
@agneym
agneym / server.js
Created January 31, 2019 13:32
API Call from Node from Axios
const axios = require("axios");
async function getData() {
const response = await axios.get("https://cat-fact.herokuapp.com/facts");
console.log(response.data);
}
getData();
var observer = new IntersectionObserver(changes => {
for (const change of changes) {
console.log(change.time); // Timestamp when the change occurred
console.log(change.rootBounds); // Unclipped area of root
console.log(change.boundingClientRect); // target.boundingClientRect()
console.log(change.intersectionRect); // boundingClientRect, clipped by its containing block ancestors, and intersected with rootBounds
console.log(change.intersectionRatio); // Ratio of intersectionRect area to boundingClientRect area
console.log(change.target); // the Element target
}
}, {});
const observer = new IntersectionObserver(callback);
const target = document.querySelector('#target');
observer.observe(target);
function callback(entries) {
// Do action here
}
function handleChange(value) {
this.setState({
value: newValue
}, ()=>{
console.log(this.state.value);
});
}
function handleChange(value) {
this.setState({
value: newValue
});
console.log(this.state.value); //Why is my state not updated?
}
@agneym
agneym / gist:0a1e2c7dc4671735504912f83b44cf67
Last active February 7, 2018 15:05
Convert hasClass to classes() codemod.
codemod "expect\((.*?)\.hasClass\(('.*?')\)\)\.to\.equal\(true\)" 'expect(\1.classes()).to.include(\2)'
codemod "expect\((.*?)\.hasClass\(('.*?')\)\)\.to\.equal\(false\)" 'expect(\1.classes()).to.not.include(\2)'
codemod "expect\((.*?)\.hasAttribute\(('.*?'),('.*?')\)\)\.to\.equal\(true\);" ''