Skip to content

Instantly share code, notes, and snippets.

View filiph's full-sized avatar
:shipit:

Filip Hracek filiph

:shipit:
View GitHub Profile
@filiph
filiph / fio-api-fetch.js
Created March 13, 2013 07:41
A simple script that fetches the Fio bank transaction data for you and pastes them into your spreadsheet. I'm afraid you're on your own while getting this to work for you, but here are the pre-requisites: 1) the Fio API token from the bank should be set in File > Project properties > User properties as `fioApiToken`. 2) The sheet 'rawData' must …
/**
* Fetch JSON from the API.
*/
function fetchLatestJson() {
var token = UserProperties.getProperty("fioApiToken");
if (token === null) {
throw "Fio API Token not set. Please go to File > Project properties > User properties and create token fioApiToken.";
}
var response = UrlFetchApp.fetch("https://www.fio.cz/ib_api/rest/last/"+token+"/transactions.json");
if (response.getResponseCode() !== 200) {
@filiph
filiph / distribute.js
Last active March 2, 2020 10:09
Google Apps Script custom function (https://developers.google.com/apps-script/guides/sheets/functions) that takes an integer count and a partition (array of percentages that sum to 1.0) and distributes the count according to the partition. Returns an array of integers (the restricted weighted integer composition). Works well for very small value…
// Takes [count] of items and the [partition] (array of percentages) to
// distribute against. Returns an array of integers that sums to [count]:
// an integer composition weighted by the partition.
//
// We don't use the Bresenham algorithm because it doesn't provide the best
// results for low values of [count].
function DISTRIBUTE(count, partition) {
// Custom function in Apps Script takes a 2D array. We're only interested in
// the first row.
partition = partition[0];
@filiph
filiph / index.html
Last active December 19, 2020 11:58
The most minimal 'Hello World' web app in Dart
<html>
<head>
<script type="application/dart" src="main.dart"></script>
<script src="packages/browser/dart.js"></script>
</head>
</html>
@filiph
filiph / helloworld.dart
Created June 18, 2016 00:28
The smallest possible hello world program in Dart.
main() => print("Hello World!");
@filiph
filiph / spanify.dart
Last active June 1, 2017 22:36
A tool used for CSS-fading in a site without any client-side scripting
import 'dart:io';
import 'dart:math';
import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'package:markdown/markdown.dart' as md;
main(args) {
var mdSource = new File(args.single).readAsStringSync();
var html = md.markdownToHtml(mdSource);
@filiph
filiph / are_we_there_yet.sh
Created September 20, 2018 21:00
A script that tells you whether a commit has landed to which Flutter branch.
#!/usr/bin/env bash
DEFAULT_HASH=76468dd
if [ -z "$1" ]
then
echo "You can provide the commit hash you're interested in as argument."
echo "Defaulting to $DEFAULT_HASH."
HASH=$DEFAULT_HASH
else
@filiph
filiph / are_we_there_yet.sh
Last active September 20, 2018 23:33
A script that tells you whether a commit has landed to any of the Flutter channels (`master`, `dev` and `beta`). Useful when you're waiting to use a feature or remove a workaround to a bug.
#!/usr/bin/env bash
set -o vi
# Change this accordingly.
# You may have github.com/flutter/flutter named as "upstream".
REMOTE_NAME=origin
# The hash we search for when no argument is given.
DEFAULT_HASH=76468dd
@filiph
filiph / main.dart
Created November 21, 2018 22:44
Hot reload time out
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:sliver_fbs/src/names.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@filiph
filiph / main.dart
Created November 30, 2018 00:46
ScopedModel counter app
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
void main() {
// The app state.
final myModel = CounterModel(42);
// A timer, to simulate updates coming from outside the app.
@filiph
filiph / main.dart
Last active December 20, 2018 00:54
The starter Flutter app rewritten using ScopedModel
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
void main() {
// Initialize the model. Can be done outside a widget, like here.
var counter = Counter();
// Just because we can: wait five seconds after the start of the app ...