Skip to content

Instantly share code, notes, and snippets.

View adam-singer's full-sized avatar
👾

Adam Singer adam-singer

👾
View GitHub Profile
@munificent
munificent / gist:8700021
Created January 30, 2014 00:12
A new pub command?

I'm starting to work on a new pub command. I've got two goals for it.

Use case 1: Pre-populating your cache (bug #16265)

The first is that it can be used to install a package into your system cache. For example, maybe you're about to go off the grid and you want to make sure you have a bunch of stuff cached locally before you fall off the Internet. pub get does this implicitly, of course, but you may not have any packages that depend on the stuff you're downloading. You just want to pull it down.

Our specific use case is that we are starting to run tests of packages. Since hitting the network can fail, we'd like to do that separately from running pub get so that we can handle the failure more gracefully.

The idea is you could do:

@adam-singer
adam-singer / dart-deploy-script.sh
Created March 21, 2014 05:32
Example of deploying dart to google compute engine without having to compile the dart-sdk from source.
#!/usr/bin/env bash
set +o xtrace
USER=$USER
PROJECT=dart-compute-project
INSTANCE_NAME=dart-compute
TAGS=dart
MACHINE_TYPE=f1-micro
NETWORK=default
IP=ephemeral
anonymous
anonymous / gist:58c2395eef9daf6be7e8
Created June 12, 2014 08:39
dart_sfml test
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "include/dart_api.h"
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Window.hpp>
@vsavkin
vsavkin / angular_dart_rest_client_spike.md
Last active August 29, 2015 14:02
AngularDart REST Client

Hammock

I released a library based on this spike. You you can find it here: https://github.com/vsavkin/hammock.

SPIKE: AngularDart REST Client

Every client-side applications has to talk to REST APIs. At the moment AngularDart does not provide any high-level abstractions to help you do that. You can send http requests, but that's it.

This post is about a spike I did a few days ago to explore possible ways of building such a library. It also shows that you can do quite a bit in just one hundred lines of Dart.

@criminy
criminy / AbstractMockitoMultipartHttpServletRequestUnitTest.java
Created July 21, 2011 14:02
Abstract Unit test for a @controller with MultipartHttpServletRequest
import static org.mockito.Mockito.*;
/**
* Boostraps a MultipartHttpServletRequest using mockito.
* To add a request parameter, define a method called 'parameterName', where request attribute is 'name'.
* To add a multipart file, define a method called 'fileName', where the multipart file is called 'name'.
* Class is very limited but works as it should providing you use a specific subset of the methods on {@link MultipartHttpServletRequest}.
* Subset:
* MultipartHttpServletRequest.getParameter
* MultipartHttpServletRequest.getFileMap
@sethladd
sethladd / IndexedDBSample.dart
Created February 23, 2012 01:46
Dart IndexedDB sample
#import('dart:dom', prefix:'dom');
#import('dart:html');
String VERSION = "1";
String TODOS_STORE = 'todos';
initDb(db) {
if (VERSION != db.version) {
dom.IDBVersionChangeRequest versionChange = db.setVersion(VERSION);
versionChange.addEventListener('success', (e) {
@pjako
pjako / docsGen.dart
Created April 3, 2012 13:05
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";
@atebitftw
atebitftw / Dart_Singleton_Maybe
Created April 26, 2012 20:54
Dart Singleton?
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();
@greenido
greenido / DartCrawlerExample.dart
Created April 28, 2012 08:00
Dart Crawler (server side example)
#import('dart:io');
#import('dart:uri');
#import('dart:json');
// Dart Hackathon TLV 2012
//
// A simple example to fetch JSON and parse it on the server side
// This is a good start for a crawler and/or any other web service
// we wish to create using dart on the server side.
//
@iggymacd
iggymacd / FileHandler.dart
Created April 30, 2012 18:39
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);
}