Skip to content

Instantly share code, notes, and snippets.

@liemvo
liemvo / BiggerAndSmaller.java
Last active March 28, 2018 00:09
Simple TDD
package lv.tdd;
public class BiggerAndSmaller {
private int bigger = Integer.MIN_VALUE;
private int smaller = Integer.MAX_VALUE;
public void find(int[] numbers){
for (int n : numbers) {
if (n > bigger) bigger = n;
if (n < smaller) smaller = n;
@liemvo
liemvo / RomanNumeral.java
Last active March 28, 2018 08:10
Roman Numeral
package lv.roman;
import java.util.HashMap;
import java.util.Map;
public class RomanNumeral {
Map<String, Integer> table;
public RomanNumeral() {
table = new HashMap<String, Integer>();
table.put("I", 1);
from IPython.display import clear_output
import random
def display_board(board):
clear_output()
print(" | |")
print(board[7] + ' | ' + board[8] + ' | ' + board[9])
print(" | |")
@liemvo
liemvo / BlackJack.py
Last active August 31, 2019 15:07
Black Jack in Python
import random
suits = ('🖤','◆','♠','♣')
ranks = ( '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A')
values = { '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, '10':10, 'J':10, 'Q':10, 'K':10, 'A':11}
playing = True
class Card:
/*Given 2 strings, return 2 character iterables (Iterable<Character> in Java) such that:
The first Iterable iterates over the characters that exist in the first string but not in the second string
The second Iterable iterates over the characters that exist in the second string but not in the first string
*/
package com.company;
import java.util.*;
TextFormField(
...
textInputAction: TextInputAction.next,
...
)
var _formKey = GlobalKey<FormState>();
var _formview = Container(
color: Colors.grey.shade300,
margin: EdgeInsets.all(8.0),
padding: EdgeInsets.all(8.0),
child: SingleChildScrollView(
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
RaisedButton calculateButton() {
return RaisedButton(
onPressed: _calculator,
color: Colors.pinkAccent,
child: Text(
'Calculate',
style: TextStyle(fontSize: 16.9),
),
textColor: Colors.white70,
);
import 'dart:convert';
import 'package:http/http.dart' show Client;
import '../model/item_model.dart';
final _root = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0';
class WakeProvider {
Client client = Client();
fetchFeatures() async {
import 'geometry.dart';
import 'properties.dart';
class ItemModel {
final String type;
final Properties properties;
final Geometry geometry;
final String id;
ItemModel.fromJson(Map<String,dynamic> parsedJson):
type = parsedJson['type'],