Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pnkapadia6's full-sized avatar

Prashasti pnkapadia6

  • Gurgaon
View GitHub Profile
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
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.
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
@jboner
jboner / latency.txt
Last active April 22, 2024 15:20
Latency Numbers Every Programmer Should Know
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
@gillesdemey
gillesdemey / querystring.swift
Last active March 24, 2021 10:53
Retrieve specific query string parameter from NSURL
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()
}
@gaearon
gaearon / reducers.js
Last active December 11, 2020 14:56
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
@cvbuelow
cvbuelow / reducers.js
Last active July 25, 2019 11:10 — forked from gaearon/reducers.js
Code splitting in Redux with SSR
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);
}
@kakadiadarpan
kakadiadarpan / reactiveconf-2017-async-in-redux-cfp.md
Last active February 25, 2024 10:05
Different approaches to handling asynchronous Redux actions.

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 😇

@necolas
necolas / Hoverable.js
Last active January 1, 2024 17:32
Hover styles in React Native for Web
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} />}