Skip to content

Instantly share code, notes, and snippets.

View parshap's full-sized avatar

Parsha Pourkhomami parshap

View GitHub Profile
@parshap
parshap / get-export-1.js
Created February 3, 2018 23:24
Get a module's default export from a Babel AST
const t = require('babel-types');
const assert = require('assert');
/**
* Is `module.exports` expression
*/
const isModuleExportsMemberExpression = (node) => {
t.assertMemberExpression(node);
t.assertIdentifier(node.object);
assert.equal(node.object.name, 'module');
@parshap
parshap / learning-javascript-and-react.md
Last active June 5, 2017 22:41
Learning JavaScript and React

Learning JavaScript and React

A guide for experienced programmers learning JavaScript and React.

JavaScript

Books & Reading

  • [Effective JavaScript][effectivejs] covers advanced JavaScript topics, such as concurrency and library design, in great detail.
@parshap
parshap / node-modules-in-react-native.md
Last active November 15, 2023 11:15
Running Node Modules in React Native

Running Node Modules in React Native

How to use packages that depend on Node.js core modules in React Native.

See the [node-libs-react-native][node-libs-react-native] library as a convenience for implementing this method.

Node.js Core Modules

@parshap
parshap / react-native-fonts.md
Last active April 20, 2023 13:27
Fonts in React Native

Fonts in React Native

Default Fonts

A number of fonts are available by default based on the platform (e.g., Roboto on Android, Helvetica on iOS). See the full list here.

@parshap
parshap / patch-readable-stream.js
Created March 12, 2017 06:01
Fix readable-stream in React Native
const glob = require('glob');
const fs = require('fs');
const path = require('path');
const ROOT_PATH = path.resolve(`${__dirname}/..`);
// Get paths to all readable-stream packages in the dependency tree
function getPackagePaths(rootPath, packageName) {
return glob.sync(`${rootPath}/**/node_modules/${packageName}`);
}
@parshap
parshap / 0.md
Last active October 4, 2016 20:06
Babel 5 vs Babel 6 Difference

Babel 5 will incorrectly allow a let declration shadow an outter var declaration. See below and note the user of var _filters on line 7 by Babel 6 instead of var filters by Babel 5 (which shadows the var filters declared on line 2).

@parshap
parshap / cpus.rb
Last active August 25, 2021 21:34
Determine number of cpu cores to use in Vagrant
# Determines how many cpus the virtual machine should be given. Uses half of
# what's available on the host with a default of 4.
def numvcpus
begin
os_cpu_cores / 2
rescue
4
end
end
@parshap
parshap / mdn-search.md
Last active January 24, 2024 17:56
Chrome shortcut to search MDN

mdn Chrome Search Shortcut

Shortcut to perform a Google I'm Feeling Lucky search on https://developer.mozilla.org.

MDN search animation

1. Settings: Manage search engines...

Google Chrome Settings Page

@parshap
parshap / stops.txt.patch
Created January 28, 2016 07:18
Caltrain GTFS 1/25/2006 Update
diff --git a/data/stops.txt b/data/stops.txt
index 4e9c24e..200a82d 100644
--- a/data/stops.txt
+++ b/data/stops.txt
@@ -1,96 +1,68 @@
-stop_id,stop_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,location_type,parent_station,platform_code
-70011,70011,"San Francisco Caltrain",, 37.776390,-122.394992,1,,0,ctsf,NB
-70012,70012,"San Francisco Caltrain",, 37.776348,-122.394935,1,,0,ctsf,SB
-70021,70021,"22nd St Caltrain",, 37.757599,-122.391880,1,,0,ct22,NB
-70022,70022,"22nd St Caltrain",, 37.757583,-122.392404,1,,0,ct22,SB
@parshap
parshap / README.md
Last active January 5, 2016 19:56
Newrelic crash in http instrumentation

I'm seeing this crash happen in a node http service running the newrelic agent. It seems to happen in this context:

  1. An http request causes an unrecoverable error (unrelated to newrelic)
  2. req.end() and req.destroy() are called on the request that caused the error
  3. server.close() is called on the http server
  4. The newrelic agent throws the above error

I am using node v4.2.3 and newrelic agent 1.24.0.