Skip to content

Instantly share code, notes, and snippets.

View ashphy's full-sized avatar
😃
Happy Coding

Kazuki Hamasaki ashphy

😃
Happy Coding
View GitHub Profile
Map<T, int> uniqCount<T>(List<T> list) {
return list.fold<Map<T, int>>({}, (prev, element) {
prev.update(element, (value) => value + 1, ifAbsent: () => 1);
return prev;
});
}
void main() {
print(uniqCount([1, 1, 1, 2, 3, 4, 4, 5]));
}
import 'package:intl/intl.dart';
void main() {
print(DateFormat('yyyy-MM-dd').parseStrict('2022-07-27'));
print(DateFormat('yyyyMMdd').parseStrict('20220727'));
}
@ashphy
ashphy / main.dart
Created July 25, 2022 10:11
Dart2.17 enhanced-enums implements interface sample
abstract class Abstract {
void foo();
}
enum Categoly implements Abstract {
sample1,
sample2;
@override
foo() { print(this); }
@ashphy
ashphy / mastodon_poll_max_customize.patch
Last active April 18, 2020 08:12
Custom patch for the maximum number of options of mastodon poll. (v3.1.3)
diff --git a/app/javascript/mastodon/features/compose/components/poll_form.js b/app/javascript/mastodon/features/compose/components/poll_form.js
index 01df31d3a..afd0ca2d0 100644
--- a/app/javascript/mastodon/features/compose/components/poll_form.js
+++ b/app/javascript/mastodon/features/compose/components/poll_form.js
@@ -153,7 +153,7 @@ class PollForm extends ImmutablePureComponent {
</ul>
<div className='poll__footer'>
- <button disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></
+ <button disabled={options.size >= 100} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} />
@ashphy
ashphy / .drone.yml
Created January 1, 2018 14:10
ARM build
platform: linux/arm
pipeline:
build:
image: arm32v7/busybox:latest
commands:
- uname -a
@ashphy
ashphy / docker-compose.yml
Created January 1, 2018 14:08
ARM drone agent
version: '2'
services:
drone-agent:
image: drone/agent:linux-arm
command: agent
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
@ashphy
ashphy / .drone.yml
Created December 30, 2017 07:38
KitchenCI Infrastructure Spec on drone.io
pipeline:
build:
image: aberrios85/drone-kitchen
commands:
- kitchen test
services:
docker:
image: plugins/docker
image: docker:1.12-dind
@ashphy
ashphy / .kitchen.yml
Created December 30, 2017 07:25
kitchen-docker plugin uses dind socket
driver:
name: docker
socket: tcp://docker:2375
@ashphy
ashphy / .drone.yml
Created December 30, 2017 07:24
Using docker in docker socket from other containers.
pipeline:
build:
image: docker:latest
environment:
- DOCKER_HOST=tcp://docker:2375
commands:
- docker info
@ashphy
ashphy / .drone.yml
Created December 30, 2017 07:23
docker in docker on drone.io
services:
docker:
image: docker:stable-dind
privileged: true
command: [ "--storage-driver=vfs", "--tls=false" ]