Skip to content

Instantly share code, notes, and snippets.

View prakashsvmx's full-sized avatar

Prakash Senthil Vel prakashsvmx

View GitHub Profile
@prakashsvmx
prakashsvmx / RFReactSelect.js
Created September 11, 2018 15:59 — forked from leocristofani/RFReactSelect.js
How to integrate React Select with Redux Form
import React, { PropTypes } from 'react';
import Select from 'react-select';
import 'react-select/dist/react-select.css';
RFReactSelect.defaultProps = {
multi: false,
className: ""
};
RFReactSelect.propTypes = {
@prakashsvmx
prakashsvmx / ajaxWithReduxSaga.js
Created September 30, 2018 15:36 — forked from rowlandekemezie/ajaxWithReduxSaga.js
A basic implementation of AJAX with redux-saga
const { applyMiddleware, createStore } = Redux;
const createSagaMiddleware = ReduxSaga.default;
const { put, call } = ReduxSaga.effects;
const { takeLatest } = ReduxSaga;
const { connect, Provider } = ReactRedux;
// GitHub API
const gitHubApi = (username) => {
return fetch(`https://api.github.com/users/${username}`)
.then(response => {
@prakashsvmx
prakashsvmx / context.js
Created August 27, 2019 09:45 — forked from julianburr/context.js
Why Suspense Will Be a Game Changer - Context
const DataContext = React.createContext();
class DataContextProvider extends Component {
// We want to be able to store multiple sources in the provider,
// so we store an object with unique keys for each data set +
// loading state
state = {
data: {},
fetch: this.fetch.bind(this)
};
@prakashsvmx
prakashsvmx / suspense-boundaries.js
Created August 27, 2019 09:48 — forked from julianburr/suspense-boundaries.js
Why Suspense Will Be a Game Changer - Suspense Boundaries
class App extends Component {
render () {
return (
<Suspense fallback={<p>Loading...</p>}>
<DeepNesting>
<ThereMightBeSeveralAsyncComponentsHere />
</DeepNesting>
</Suspense>
);
}
@prakashsvmx
prakashsvmx / IP Address in OneLine
Last active March 11, 2020 17:03
Useful Utilities/Commands
ipconfig getifaddr en0
@prakashsvmx
prakashsvmx / upload-minio.html
Created December 18, 2020 03:57 — forked from harshavardhana/upload-minio.html
Upload to play.minio.io:9000 from browser using minio-js
<!DOCTYPE html>
<html>
<head>
<title>Minio SDK for JavaScript - Sample Application</title>
//copy the $file to $dir2
var copyFile = (file, dir2, fileName)=>{
//include the fs, path modules
var fs = require('fs');
var path = require('path');
//gets file name and adds it to dir2
var f = path.basename(fileName);
var source = fs.createReadStream(file);
var dest = fs.createWriteStream(path.resolve(dir2, f));
async function logInOrder(urls) {
// fetch all the URLs in parallel
const textPromises = urls.map(async url => {
const response = await fetch(url);
return response.text();
});
// log them in sequence
for (const textPromise of textPromises) {
console.log(await textPromise);
function getResponseSize(url) {
return fetch(url).then(response => {
const reader = response.body.getReader();
let total = 0;
return reader.read().then(function processResult(result) {
if (result.done) return total;
const value = result.value;
total += value.length;