Skip to content

Instantly share code, notes, and snippets.

View rafdls's full-sized avatar
👨‍💻

Rafael Delos Santos rafdls

👨‍💻
View GitHub Profile
@rafdls
rafdls / atom_clojure_setup.md
Created October 21, 2017 07:13 — forked from jasongilman/atom_clojure_setup.md
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

@rafdls
rafdls / pubspec.yaml
Created January 6, 2020 23:13
pubspec file for writing unit tests in flutter
dev_dependencies:
flutter_test:
sdk: flutter
mockito: 4.1.1
@rafdls
rafdls / geolocator_mock_setup.dart
Last active January 12, 2020 08:06
location repository implementation
when(mockGeolocator.getCurrentPosition(
desiredAccuracy: anyNamed('desiredAccuracy'),
locationPermissionLevel: anyNamed('locationPermissionLevel')))
.thenAnswer((_) {
return Future<Position>.value(Position(latitude: 20, longitude: 30));
});
@rafdls
rafdls / group_test.dart
Last active January 9, 2020 05:03
flutter unit test basics
import 'package:flutter_test/flutter_test.dart';
void main() {
group('This list of numbers', () {
List numberList = [1, 2, 3, 4, 5];
test('should have the right length', () {
expect(numberList.length, equals(5));
});
test('should have the correct order', () {
@rafdls
rafdls / metaweather_util.dart
Last active January 9, 2020 05:34
Metaweather json parser util
import 'package:flutter/material.dart';
import 'package:flutter_unit_testing/bloc/weather_model.dart';
import 'package:intl/intl.dart';
import 'package:weather_icons/weather_icons.dart';
class MetaweatherUtil {
String jsonToLocationId(List<dynamic> jsonList) {
return jsonList[0]['woeid'].toString();
}
}
@rafdls
rafdls / bloc_mock_setup.dart
Last active January 17, 2020 11:43
weather app bloc
final expectedWeatherModel = WeatherModel(20, 'Sydney', 'Sunny', Icons.cloud, []);
final mapCoordinate = MapCoordinate(1.0, -1.0);
when(mockLocationRepository.getCurrentLocation())
.thenAnswer((_) {
return Future.value(mapCoordinate);
});
when(mockWeatherRepository.getWeatherWithLocation(mapCoordinate))
.thenAnswer((_) {
return Future.value(expectedWeatherModel);
});
@rafdls
rafdls / future_callback_test.dart
Last active September 9, 2022 18:25
Code snippets for how to write unit tests in flutter
test('testing future callback', () {
int number = 10;
Future<int> futureNumber = Future.value(number);
futureNumber.then((val) {
expect(val, 10);
});
});
@rafdls
rafdls / GIF-Screencast-OSX.md
Created January 25, 2020 07:02 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@rafdls
rafdls / app.dart
Last active August 29, 2022 07:28
Simple Bloc Pattern examples
class App extends StatelessWidget {
final MusicPlayer musicPlayer = DummyMusicPlayer();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Music Player',
theme: ThemeData(
primarySwatch: Colors.blue,
),
@rafdls
rafdls / home_screen.dart
Last active March 11, 2020 08:58
How to make an online radio app in Flutter part 1
class HomeScreen extends StatelessWidget {
final _planetRockUrl = 'https://stream-mz.planetradio.co.uk/planetrock.mp3';
final _planetRockImage = 'assets/images/planet_rock.png';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Online Radio'),
),