Skip to content

Instantly share code, notes, and snippets.

View parshap's full-sized avatar

Parsha Pourkhomami parshap

View GitHub Profile
@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 / 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 / install-vbox-guest-additions.sh
Created July 31, 2014 19:35
Install VirtualBox Guest Additions on a headless server
wget http://download.virtualbox.org/virtualbox/4.3.12/VBoxGuestAdditions_4.3.12.iso
sudo mkdir /media/iso
sudo mount -o loop ./VBoxGuestAdditions_4.3.12.iso /media/iso
sudo bash /media/iso/VBoxLinuxAdditions.run --nox11
sudo umount /media/iso
@parshap
parshap / pivot.js
Created December 18, 2013 09:19
Find pivot index
// Return the "pivot index" of the given array of numbers. The pivot index is
// the index where the sum of the numbers on the left is equal to the sum of
// the numbers on the right.
function pivot(numbers) {
validateInput(numbers);
// Find a pivot index by testing each index
for (var i = 0; i < numbers.length; i++) {
var leftSum = sum(numbers.slice(0, i));
var rightSum = sum(numbers.slice(i + 1));
@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 / jsx-html-differences.md
Last active May 11, 2020 16:40
Difference between JSX and HTML
  • className attribute instead of class
  • htmlFor attribute instead of for
  • <textarea value="something"> instead of <textarea>something</textarea> (see Why Textarea Value)
  • <select value="something"><option value="something"></select> instead of <select><option selected value="something"></select> (see Why Select Value)
  • Whitespace (see discussion)
  • [Tags must be closed and all tags can be self-closing][closing tags]
@parshap
parshap / remote-address-undefined.md
Created August 13, 2014 19:04
Node.js socket remoteAddress is undefined

Node socket remoteAddress is undefined

If the underlying socket is destroyed, a socket's remoteAddress is no longer accessible and undefined.

@parshap
parshap / Vagrantfile
Created December 8, 2013 23:49
Vagrant hooks
class Plugin < ::Vagrant.plugin("2")
name "build"
action_hook('build') do |hook|
hook.after(Vagrant::Action::Builtin::Provision, 2) do
system("bash build.sh")
end
end
end
@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');