Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
@anaisbetts
anaisbetts / stat-cache.js
Last active April 11, 2019 05:07
Make your Electron apps load faster, with this One Weird Trick
// Include this at the very top of both your main and window processes, so that
// it loads as soon as possible.
//
// Why does this work? The node.js module system calls fs.realpathSync a _lot_
// to load stuff, which in turn, has to call fs.lstatSync a _lot_. While you
// generally can't cache stat() results because they change behind your back
// (i.e. another program opens a file, then you stat it, the stats change),
// caching it for a very short period of time is :ok: :gem:. These effects are
// especially apparent on Windows, where stat() is far more expensive - stat()
// calls often take more time in the perf graph than actually evaluating the
is64BitOperatingSystem: () => {
if (process.arch === 'x64') return true;
let sysRoot = 'C:\\Windows';
if (fs.statSyncNoException(process.env.SYSTEMROOT || 'C:\\__nothere__')) {
sysRoot = process.env.SYSTEMROOT;
}
// If %SystemRoot%\SysNative exists, we are in a WOW64 FS Redirected application.
return !!fs.statSyncNoException(path.join(sysRoot, 'sysnative'));
  • Ditch the status page
  • Expose the entire thing as a library
  • 📝 the world
  • Update the main README
  • Finish the install PR
  • Fix up surf-clean and add remote clean
  • Remove the ref server concept and rename surf-client
@anaisbetts
anaisbetts / deferred-require.js
Created June 23, 2016 08:49
A failed attempt to make a lazy require
const emptyFunc = () => {};
emptyFunc.prototype = {};
// On initial call, we just return the proxy
// On next tick or >1 call, we make getters call require
// Until then getters have to create a proxy too
//
// cases:
// require('foo')();
// const {foo} = require('bar');
Activation of app microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail failed with error: The remote procedure call failed. See the Microsoft-Windows-TWinUI/Operational log for additional information.
---
Faulting application name: HxMail.exe, version: 16.0.6769.4079, time stamp: 0x57038033
Faulting module name: KERNELBASE.dll, version: 10.0.14316.1000, time stamp: 0x5700c87e
Exception code: 0x00000004
Fault offset: 0x0000000000048658
Faulting process id: 0x1e8c
Faulting application start time: 0x01d19a5d686e86cf
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using ReactiveUI;
using Splat;
#!/bin/sh
#
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# This script is part of the slack package, modified from the google-chrome package.
#
# It creates the repository configuration file for package updates, since
# we cannot do this during the google-chrome installation since the repository
import {Observable, Subject} from 'rx';
import _ from 'lodash';
export default class TimedLocalStorage {
constructor(originalLocalStorage) {
this.inner = originalLocalStorage;
this.tick = new Subject();
this.count = 0;
this.elapsed = 0;
#!/usr/bin/env node
'use strict';
var main = function () {
var ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee2() {
var testServer = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
var testRepo = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var testCmdWithArgs = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var cmdWithArgs, repo, server, _nwo, jobs, refInfo, nwo, surfUrl, fetchRefs, buildMonitor;
@anaisbetts
anaisbetts / Dockerfile
Created February 11, 2016 07:38
Docker + Surf + Electron
# VERSION: 0.1
# DESCRIPTION: Build an Electron app in a container
# AUTHOR: Paul Betts <[email protected]>
# COMMENTS:
# Use Surf to build an Electron app in a container and upload the result
# Originally based on the Atom Dockerfile by Jessica
# Frazelle <[email protected]>
# USAGE:
# # Download atom Dockerfile
# wget https://raw.githubusercontent.com/atom/atom/master/Dockerfile