Skip to content

Instantly share code, notes, and snippets.

View iamalvisng's full-sized avatar
🏠
Working from home

Alvis Ng iamalvisng

🏠
Working from home
View GitHub Profile
@iamalvisng
iamalvisng / InfiniteScrollTrigger.tsx
Last active August 7, 2023 03:40
Infinite scroll using Intersection Observer API
import React, { useEffect, useRef } from 'react';
// Define the properties for the InfiniteScrollTrigger component
type InfiniteScrollTriggerProps = {
onIntersect: () => void; // Callback function to be executed when intersection is detected
root?: Element | Document | null; // The Element or Document object to be used as the viewable area for the IntersectionObserver
threshold?: number; // A single number or an array of numbers between 0.0 and 1.0 indicating at what percentage of the target's visibility the observer's callback should be executed
rootMargin?: string; // Margin around the root. Can have values similar to the CSS margin property
};
@iamalvisng
iamalvisng / request.js
Created June 11, 2019 01:43 — forked from sheharyarn/request.js
Axios Request Wrapper for React (https://to.shyr.io/axios-requests)
/**
* Axios Request Wrapper
* ---------------------
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
*/
import axios from 'axios'
@iamalvisng
iamalvisng / antd_sc_example.js
Created May 31, 2018 12:08 — forked from newswim/antd_sc_example.js
Wrapping Ant Design components with Styled Components
import { Link } from 'react-router-dom'
import { Badge, Col, Menu } from 'antd'
const StyledBadge = styled(Badge)`
.ant-badge-count {
background-color: #7ECBBF;
color: white;
box-shadow: 0 0 0 1px #d9d9d9 inset;
}
`
import React from 'react';
import { string, bool, func } from 'prop-types';
import { StyledButton } from './styled';
const Button = ({
size,
text,
}) => (
<StyledButton
size={size}
@iamalvisng
iamalvisng / introrx.md
Created May 7, 2018 04:12 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
// 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');
}
@iamalvisng
iamalvisng / Contributing.md
Created January 5, 2018 03:28 — forked from MarcDiethelm/Contributing.md
How to contribute to a project on Github

This text now lives at https://github.com/MarcDiethelm/contributing/blob/master/README.md. I turned it into a Github repo so you can, you know, contribute to it by making pull requests.


Contributing

If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.

class App extends Component {
constructor(props) {
super(props);
this.state = {
location: 'Loading...',
temp: null,
icon: '01d',
unit: 'C',
isMetric: true,
@iamalvisng
iamalvisng / gulpfile.js
Last active August 29, 2015 14:28 — forked from donovanh/gulpfile.js
Gulp file for Jekyll, with Sass, Autoprefixer, and browsersync
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),