This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LazyVariables { | |
def lazy(variables) { | |
variables.each { name, init -> | |
def chars = name.toCharArray() | |
chars[0] = Character.toUpperCase(chars[0]) | |
def getter = "get${new String(chars)}" | |
this.metaClass[getter] = { | |
def value = init() | |
this.metaClass[name] = value | |
this.metaClass[getter] = { value } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"provider": { | |
"name": "Animal Service" | |
}, | |
"consumer": { | |
"name": "Zoo App" | |
}, | |
"interactions": [ | |
{ | |
"description": "a request for animals", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>test eventTicks</title> | |
<script src="js/lib/zepto-1.1.4.js"></script> | |
<script src="js/lib/bacon-0.7.12.js"></script> | |
<script> | |
$(function() { | |
var ticks = new Bacon.Bus(); | |
ticks.plug($(".ticker").asEventStream("click", function() { | |
return {tick: 1}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def double(i): | |
return i*2 | |
def increment(i): | |
if i=='broken': | |
return None | |
return i+1 | |
def flatten(listOfOptions): | |
return reduce(list.__add__, listOfOptions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
RUN apt-get update | |
RUN apt-get install -y wget build-essential python python-dev | |
RUN wget https://bootstrap.pypa.io/get-pip.py | |
RUN python get-pip.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
def coles_price(): | |
r = requests.get('http://shop.coles.com.au/online/mobile/national/limes-loose') | |
if r.status_code == 200: | |
soup = BeautifulSoup(r.text, 'html.parser') | |
price_text = soup.find('p', {'class': 'price'}).get_text() | |
return float(price_text.replace('$', '')) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Dao[T] { | |
val tableName: String | |
def find(id:String): ConnectionIO[Option[T]] = | |
Fragment.const("select * from $tableName where id = ") ++ fr"$id".query[T] | |
} | |
case class Foo(id: String, data: String) | |
object Foos extends Dao[Foo] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for each tick | |
for each company | |
execute destruction orders | |
productionBuildings | |
add resourceSource inputs | |
add stockPile inputs | |
add autoBuy inputs | |
consume power |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:http/http.dart' as http; | |
import 'package:http_parser/http_parser.dart'; | |
Future<http.Response> uploadFile( | |
String url, | |
Map<String, String> headers, | |
Map<String, String> fields, | |
String fileName, | |
List<int> fileBytes) async { | |
var request = new http.MultipartRequest("POST", Uri.parse(url)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
import 'package:flutter/material.dart'; | |
import 'package:growdata_shared_web/component/gd_red_text.dart'; | |
class GdFileInput extends StatefulWidget { | |
final void Function(String, List<int>) fileSelected; | |
final List<String> extensions; | |
GdFileInput(this.fileSelected, {this.extensions}); |
OlderNewer