Skip to content

Instantly share code, notes, and snippets.

View Pajn's full-sized avatar

Rasmus Eneman Pajn

View GitHub Profile
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
#px {
width: 37.8px;
height: 37.8px;
background: red;
}
#cm {
Future<Response> helloPost(HttpRequest request) {
return request.toList().then((List<List<int>> buffer) {
var name = new String.fromCharCodes(buffer.expand((i) => i).toList());
name = name.isNotEmpty ? name : 'World';
return new Response("Hello, $name!");
});
}
@Pajn
Pajn / gist:9263f0d1802fe5f9ec1a
Created May 3, 2014 14:34
openshift-cartridge-dart
Name: dart
Cartridge-Short-Name: DART
Display-Name: Dart Cartridge
Description: A dart cartridge
Version: 0.6.3
License: MIT
Vendor: google
Cartridge-Version: 0.0.1
Cartridge-Vendor: filirom1
Categories:
register(Request request) {
var user = new User.fromJson(request.json);
if (!user.emailIsValid || !user.hashIsValid) {
return new Response('invalid data', status: Status.ERROR);
}
return db.open().then((_) {
DbCollection users = db.collection('Users');
part of cogito;
class User {
/// Email validation according to WHATWGs HTML5 type="email" standard.
final EMAIL_REGEX = new RegExp(r'''^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$''');
String email = '';
String password = '';
String hash = '';
new RestServer()
..clientRoutes = ['/page']
..static(STATIC_PATH, jailRoot: false)
..route(new Route('/api/auth')
..post = authorization.register
..put = authorization.login)
..preprocessor(authorization.checkLogin)
..route(new Route('/api/checkAuth')
..get = authorization.success)
..route(new Route('/api/page/{id}')
@Pajn
Pajn / is_assignable_to_test.dart
Created March 16, 2015 10:01
Test Darts TypeMirror isAssignableTo
import 'dart:mirrors';
import 'package:guinness/guinness.dart';
class Test {
Iterable iterable;
Iterable<int> typedIterable;
}
main() {
describe('Dart', () {
@Pajn
Pajn / gist:400867d3d6373ed975f2
Last active August 29, 2015 14:17
Cypher in Dart?
Match (Movie, {'name': 'Avatar'}) -[#r]>> n(#actor, Actor).
Where ([#r, {'role': Do.exist}]).
Optional (Match (#actor) -['actedIn']- n(#movie, Movie)).
Return ([#actor, #movie]);
Match (Movie, {'name': 'Avatar'}) <<_([#r, 'rated'])- n(User).
Where ([#r, {'rating': Is.greaterThan(4.5)}]).
Return ([#r]);
[layout] {
display: flex;
}
[layout="row"] {
flex-direction: row;
}
[layout="column"] {
flex-direction: column;
@Pajn
Pajn / react-native.d.ts
Last active September 25, 2015 06:42 — forked from bparadie/react-native.d.ts
Incomplete react-native.d.ts, requires react.d.ts from DefinitelyTyped
declare module "react-native" {
import * as React from 'react';
import {ComponentClass, ReactType, ReactNode, ReactElement} from 'react';
export * from 'react';
/**
* Represents the completion of an asynchronous operation
* @see lib.es6.d.ts