Skip to content

Instantly share code, notes, and snippets.

View danschultz's full-sized avatar
🇺🇦

Dan Schultz danschultz

🇺🇦
View GitHub Profile
@danschultz
danschultz / install_homebrew.rb
Created August 12, 2011 19:12 — forked from mxcl/install_homebrew.markdown
Installs Mixbook's forked Homebrew to /usr/local
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
@danschultz
danschultz / maven.rb
Created October 29, 2012 20:38
Brew Maven 2.2.1
require 'formula'
class Maven <Formula
url 'http://www.apache.org/dist/maven/maven-2/2.2.1/binaries/apache-maven-2.2.1-bin.tar.gz'
homepage 'http://maven.apache.org/'
md5 '3f829ed854cbacdaca8f809e4954c916'
def install
rm_f Dir["bin/*.bat"]
prefix.install %w[bin conf boot lib]
@danschultz
danschultz / gist:5817989
Last active December 18, 2015 17:19
Proposal for computed properties in Dart. Whenever `firstName` or `lastName` changes, I want `fullName` to also dispatch a change event. This'll be very useful for binding a read-only property in WebUI. Right now, I have to write some ugly boilerplate to get this to work. Ideally there'd be a way to set this up through metadata.
// Assumes that we're using mdv_observe
// Verbose way
class Person extends ObservableBase {
@observable
String firstName;
@observable
String lastName;
@danschultz
danschultz / rspec.dart
Last active December 20, 2015 19:29 — forked from vsavkin/rspec.dart
library test_framework;
import 'package:unittest/unittest.dart';
// RSpec like framework
typedef Closure();
class Example {
String name;
Closure body;
@danschultz
danschultz / movie_search.dart
Last active August 29, 2015 14:05
Frappe Movie Search Demo
ObservableList movieSuggestions = new ObservableList();
var searchInput = document.querySelector("#search-input");
var onInput = new EventStream(searchInput.onKeyUp).merge(searchInput.onChange)
.map((_) => searchInput.inputValue)
.debounce(new Duration(milliseconds: 250))
.distinct();
var suggestions = onInput.flatMapLatest((search) {
@danschultz
danschultz / Optionals.swift
Created October 26, 2014 22:26
A couple helpers for working with optionals
import Foundation
func ifOptionalHasValue<T>(optional: T?, then: (T) -> Void) {
ifOptionalHasValue(optional, { (value) -> Void in
then(value)
}) { () -> Void in
// do nothing
}
}
require 'formula'
class Librsvg < Formula
homepage 'https://live.gnome.org/LibRsvg'
url 'https://git.gnome.org/browse/librsvg/snapshot/librsvg-2.40.5.tar.xz'
sha256 '3d7d583271030e21acacc60cb6b81ee305713c9da5e98429cbd609312aea3632'
bottle do
cellar :any
revision 1
@danschultz
danschultz / gist:596d02d6f330e4ab7393
Created February 26, 2015 08:50
Frappe registration form
import 'dart:async';
import 'dart:html';
import 'dart:math';
import 'package:frappe/frappe.dart';
InputElement usernameInput = querySelector("#username");
Element usernameAvailable = querySelector("#usernameAvailable");
InputElement fullnameInput = querySelector("#fullname");
ButtonElement registerButton = querySelector("#register");
Element result = querySelector("#result");
import 'package:frappe/frappe.dart';
class SubClassStream extends EventStream {
SubClassStream(num n) : super(new Stream.fromIterable([n]));
}
@danschultz
danschultz / gist:5a2eec444352a6374c34
Last active August 29, 2015 14:22
event stream controller
import 'dart:async';
import 'package:frappe/frappe.dart';
class EventStreamController<T> implements StreamController {
final StreamController<T> _controller;
final EventStream<T> _stream;
EventStream<T> get stream => _stream;
StreamSink<T> get sink => _controller.sink;