Skip to content

Instantly share code, notes, and snippets.

View dhei's full-sized avatar

Di Hei dhei

  • GitHub Staff
  • Seattle
  • 17:06 (UTC -07:00)
View GitHub Profile
@dhei
dhei / npm-parse.js
Created December 5, 2023 19:12
Compare latency of JSONStream.parse and JSON.parse
#!/usr/bin/env node
const https = require('node:https')
const JSONStream = require('JSONStream')
const JSONStreamWithDestroyTest = async () => {
const r = []
for (let i = 0; i < 10; i++) {
r.push(new Promise((resolve, reject) => {
const start = Date.now()
const req = https.request(new URL('https://registry.npmjs.org/npm'), function (res) {
@dhei
dhei / .md
Last active May 3, 2023 20:30
How to Remove Microsoft AutoUpdate from MacOS
@dhei
dhei / macos-setup.md
Created December 9, 2018 22:35
macOS developer setup
  • Visual Studio Code
  • Git
  • Homebrew
  • Node.js & NPM
  • CocoaPods
@dhei
dhei / cocoapods-local-cache.md
Created October 31, 2018 17:06
CocoaPods local cache

CocoaPods local cache location:

/Users/{user}/Library/Caches/CocoaPods/Pods/Release/AppCenterReactNativeShared/

@dhei
dhei / Stackoverflow Highest Voted C# Questions.md
Last active April 8, 2018 22:43
Stackoverflow Highest Voted C# Questions

Question: Which method performs better: .Any() vs .Count() > 0? (SO link)

Answer: In general .Any() is more performant with better clarity of intention on IEnumerable<T>. If you are starting with something that has a .Length or .Count (such as ICollection, IList, List, etc) - then this will be the fastest option.

Question: Using LINQ to remove elements from a List (SO link)

Answer: .RemoveAll() from IList or .Where() will do the trick.

Example of LINQ Select and ToDictionary with parallel execution of tasks

var dataSource = new List<object>() { "aaa" , "bbb" };
var tasks = dataSource.Select(async data => new { Key = data.ToString(), Value = await AsyncDoSomething(data.ToString()) });
var results = await Task.WhenAll(tasks);
Dictionary<string, int> dictionary = results.ToDictionary(pair => pair.Key, pair => pair.Value);

Adapted from this Stackoverflow answer.

@dhei
dhei / gist:7973176545dd5283ecd4067cd40546a4
Created March 23, 2018 07:23
Azure Storage Explorer installed location
C:\Program Files (x86)\Microsoft Azure Storage Explorer\StorageExplorer.exe
@dhei
dhei / readme.md
Created January 27, 2018 19:13
[Pro Tip] How to stop application to auto-start on macOS