Skip to content

Instantly share code, notes, and snippets.

View adam-singer's full-sized avatar
👾

Adam Singer adam-singer

👾
View GitHub Profile
@adam-singer
adam-singer / SVGSamples.dart
Created February 27, 2012 18:22 — forked from ltackmann/SVGSamples.dart
SVG in Dart
#import('dart:html');
class SVGSamples {
void run() {
drawlines();
}
void drawlines() {
final int maxY = 250;
@adam-singer
adam-singer / docsGen.dart
Created April 3, 2012 22:50 — forked from pjako/docsGen.dart
Dart Docs generation Script
#import('dart:io');
final String PATH_TO_DARTSDK = "/Users/XYZ/dart-sdk";
final String SUBDIRECTORY = "";
final String LIBRARY_DARTFILE = "XYZ.dart";
class MyClass{
static MyClass _ref;
static MyClass get context() => _ref == null ? new MyClass() : _ref;
factory MyClass(){
if (_ref != null) return _ref;
_ref = new MyClass._internal();
@adam-singer
adam-singer / FileHandler.dart
Created May 1, 2012 02:34 — forked from iggymacd/FileHandler.dart
Sample FileHandler
class FileHandler {
FileHandler(){
}
void onRequest(HttpRequest request, HttpResponse response, [String fileName = null]){
final int BUFFER_SIZE = 4096;
if (fileName == null) {
fileName = request.path.substring(1);
}
@adam-singer
adam-singer / NotFoundHandler.dart
Created May 1, 2012 02:34 — forked from iggymacd/NotFoundHandler.dart
Sample NotFound Handler
class NotFoundHandler {
NotFoundHandler(){
}
List<int> _notFoundPage;
static final String notFoundPageHtml = """
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
@adam-singer
adam-singer / fannkuchredux.dart
Created July 6, 2012 03:47 — forked from gozzoo/fannkuchredux.dart
fannkuchredux benchmark implementation in dart
#import('dart:core');
class FannkuchreduxTest {
static int fannkuchredux(int n) {
var perm = new List(n);
var perm1 = new List(n);
var count = new List(n);
int maxFlipsCount = 0;
int permCount = 0;
@adam-singer
adam-singer / gist_tag.rb
Created November 24, 2012 08:11 — forked from BinaryMuse/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
// Given a stream of unsorted integers, find the median element in sorted order at any given time.
// http://www.ardendertat.com/2011/11/03/programming-interview-questions-13-median-of-integer-stream/
public class MedianOfIntegerStream {
public Queue<Integer> minHeap;
public Queue<Integer> maxHeap;
library MIME;
// get MIME type (returns null if there is no such extension)
String mimeType(String extension) => _mimeMaps[extension];
// default MIME type mappings
Map _mimeMaps = const {
'abs': 'audio/x-mpeg',
'ai': 'application/postscript',
'aif': 'audio/x-aiff',
/*
* Deployes dart packages.
*
* Takes the dart packages in directory
* /source/dir/packages/...
* which is configured in the configuration files build.json,
* i.e.
* {"packages-dir": "/source/dir(packages"}
*
* and copies them to the directory