Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
#!/bin/bash
git branch --merged | while read line
do
# If the line is in the format '* master' (indicating the current branch),
# this will be effectively empty, so we don't somehow delete the current
# branch
BRANCH=`echo "$line" | awk -F '*' '{ print $1 }'`
if [ -z "$BRANCH" ]
@anaisbetts
anaisbetts / Example.cs
Created August 28, 2017 05:15
Observe changes to top-level windows
var watchThatWindow = new ObservableWindow();
watchThatWindow.WindowCreated
.Select(hwnd => NativeMethods.GetWindowTitle(hwnd))
.Subscribe(x => Console.WriteLine($"Say hello to '{x}'!"));
import android.app.Activity
import android.bluetooth.BluetoothGattCharacteristic
import android.os.Bundle
import android.util.Log
import com.github.ivbaranov.rxbluetooth.RxBluetooth
import com.polidea.rxandroidble.RxBleClient
import com.polidea.rxandroidble.RxBleConnection
import com.polidea.rxandroidble.RxBleDevice
import com.polidea.rxandroidble.scan.ScanSettings
import rx.Observable
@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;
}
/*