Skip to content

Instantly share code, notes, and snippets.

Avatar

Parsha Pourkhomami parshap

View GitHub Profile
@parshap
parshap / get-export-1.js
Created Feb 3, 2018
Get a module's default export from a Babel AST
View get-export-1.js
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 Jun 5, 2017
Learning JavaScript and React
View learning-javascript-and-react.md

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 Mar 10, 2022
Running Node Modules in React Native
View node-modules-in-react-native.md

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 Jul 12, 2021
Fonts in React Native
View react-native-fonts.md

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 Mar 12, 2017
Fix readable-stream in React Native
View patch-readable-stream.js
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 Oct 4, 2016
Babel 5 vs Babel 6 Difference
View 0.md

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 Aug 25, 2021
Determine number of cpu cores to use in Vagrant
View cpus.rb
# 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 Jan 13, 2022
Chrome shortcut to search MDN
View mdn-search.md

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 Jan 28, 2016
Caltrain GTFS 1/25/2006 Update
View stops.txt.patch
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 Jan 5, 2016
Newrelic crash in http instrumentation
View README.md

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.