Skip to content

Instantly share code, notes, and snippets.

Prashasti pnkapadia6

Block or report user

Report or block pnkapadia6

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@necolas
necolas / Hoverable.js
Last active Apr 16, 2019
Hover styles in React Native for Web
View Hoverable.js
import createHoverMonitor from './createHoverMonitor';
import { element, func, oneOfType } from 'prop-types';
import React, { Component } from 'react';
const hover = createHoverMonitor();
/**
* Use:
* <Hoverable>
* {(hover) => <View style={hover && styles.hovered} />}
@kakadiadarpan
kakadiadarpan / reactiveconf-2017-async-in-redux-cfp.md
Last active Dec 2, 2017
Different approaches to handling asynchronous Redux actions.
View reactiveconf-2017-async-in-redux-cfp.md

Async in Redux

This is a CFP for ReactiveConf open call for lightning talks. If you'd like to see this talk become a reality, please ⭐️ star this gist. #ReactiveConf

If you're on your phone, please request the desktop site to star this gist 😇

@cvbuelow
cvbuelow / reducers.js
Last active Jul 25, 2019 — forked from gaearon/reducers.js
Code splitting in Redux with SSR
View reducers.js
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
// Inject the initial state for async loaded reducers
function injectState(reducers, preloadedState = {}) {
return Object.keys(reducers).reduce((finalReducers, key) => {
if (typeof reducers[key] === "function") {
finalReducers[key] = (state = preloadedState[key], action) => reducers[key](state, action);
}
@gaearon
gaearon / reducers.js
Last active Aug 20, 2019
How I'd do code splitting in Redux (pseudo code, not tested!)
View reducers.js
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
@gillesdemey
gillesdemey / querystring.swift
Last active Jul 8, 2019
Retrieve specific query string parameter from NSURL
View querystring.swift
func getQueryStringParameter(url: String, param: String) -> String? {
let url = NSURLComponents(string: url)!
return
(url.queryItems? as [NSURLQueryItem])
.filter({ (item) in item.name == param }).first?
.value()
}
@jboner
jboner / latency.txt
Last active Sep 19, 2019
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active Sep 19, 2019
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
View node-and-npm-in-30-seconds.sh
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
You can’t perform that action at this time.