Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
@anaisbetts
anaisbetts / Example.cs
Last active July 26, 2017 21:56
Get a notification when someone changes the keyboard language
ObservableKeyboard.InputProfileChanged
.Subscribe(_ => Console.WriteLine("Hey it changed!"));
@anaisbetts
anaisbetts / save-mah-blog.ts
Created May 24, 2017 20:46
Live Coding 5/24/2017 - recovering blog posts with Cheerio
import * as fs from 'fs';
import * as path from 'path';
import * as glob from 'glob';
import * as cheerio from 'cheerio';
const files = glob.sync(path.join(__dirname, '**/*.html'));
const filesAndContent = files.reduce((acc, x) => {
let $ = cheerio.load(fs.readFileSync(x, 'utf8'));
export interface SortedArrayOpts {
filter?: Function;
compare?: Function | string;
unique?: boolean;
resume?: boolean;
}
export class SortedArray<T> extends Array<T> {
private readonly _filter: Function;
private readonly _compare: Function;
@anaisbetts
anaisbetts / sparse-map.ts
Created February 15, 2017 22:58
TypeScript Is Amazing
//
// WRONG
///
class InMemorySparseMap<K, V> implements SparseMap<K, V> {
private latest: Map<K, Updatable<V>>;
private factory: ((key: K) => Observable<V>) | undefined;
subscribe(key: K): Updatable<V> {
let ret = this.latest.get(key);
@anaisbetts
anaisbetts / .npmrc
Last active January 15, 2017 07:37
Copy this to root of project, then blow away node_modules and npm install
runtime = electron
target = 1.4.12 // REPLACE ME WITH VERSION
target_arch = x64 // REPLACE ME WITH WHATEVER process.arch IS
disturl = https://atom.io/download/atom-shell
tag-version-prefix = ""
build_from_source = true
This file has been truncated, but you can view the full file.
@anaisbetts
anaisbetts / subscription.rs
Created December 7, 2016 18:40
Rx Subscription in Rust
use std::cell::RefCell;
use std::collections::LinkedList;
use std::sync::atomic::*;
pub trait Subscription {
fn unsubscribe(&mut self);
fn closed(&self) -> bool;
}
/*
@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