Skip to content

Instantly share code, notes, and snippets.

🤘
I got a new job.

Yuya Matsuo niusounds

🤘
I got a new job.
Block or report user

Report or block niusounds

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@niusounds
niusounds / async_data.dart
Last active Sep 19, 2019
Asynchronous data management widget.
View async_data.dart
import 'package:flutter/material.dart';
typedef AsyncDataBuilder<T> = Widget Function(BuildContext, T);
typedef AsyncErrorBuilder = Widget Function(BuildContext, dynamic);
/// 非同期データの取得を管理するWidget。
/// 初回ビルド時に非同期データを取得し、[builder]が返却するWidgetをビルドする。
/// その後、必要に応じて非同期データの再取得を行い、Widgetを再構築する。
///
/// [refreshOnDidPopNext]をtrueにすると、[Navigator.pop]でこのWidgetが含まれる画面に戻ってきた時に再取得する。
View AndroidManifest.xml
<activity
android:name=".MainActivity"
...>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="handle" android:scheme="myscheme" />
</intent-filter>
</activity>
@niusounds
niusounds / main.dart
Created Jun 18, 2019
CustomMultiChildLayoutの使い方
View main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@niusounds
niusounds / deep_merge_map.dart
Last active May 27, 2019
Map deep merge in Dart.
View deep_merge_map.dart
Map<String, dynamic> deepMergeMap(Map<String, dynamic> a, Map<String, dynamic> b) {
b.forEach((k, v) {
if (!a.containsKey(k)) {
a[k] = v;
} else {
// TODO handle List type
if (a[k] is Map) {
deepMergeMap(a[k], b[k]);
} else {
a[k] = b[k];
@niusounds
niusounds / ffserver.js
Created Apr 19, 2019
ffmpeg live transcode test
View ffserver.js
const express = require('express')
const app = express()
const { spawn } = require('child_process');
const URL = 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8'
app
.get('/video.webm', (req, res) => {
res.type('video/webm')
@niusounds
niusounds / gist:51c9c23f349f492c29957f98e0adbfd7
Created Mar 28, 2019
convert video to animation WebP with infinite loop and appropriate size for web (ex. width=640px).
View gist:51c9c23f349f492c29957f98e0adbfd7
ffmpeg -y -i .\video.mp4 -loop 0 -vf scale=640:-1 output.webp
@niusounds
niusounds / rsa_pem.dart
Last active Dec 25, 2018 — forked from proteye/rsa_pem.dart
How to encode/decode RSA private/public keys to PEM format in Dart with asn1lib and pointycastle
View rsa_pem.dart
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "package:asn1lib/asn1lib.dart";
List<int> decodePEM(String pem) {
var startsWith = [
"-----BEGIN PUBLIC KEY-----",
"-----BEGIN PRIVATE KEY-----",
@niusounds
niusounds / GetContext.cs
Last active Dec 14, 2018
Get Android Activity (Context) reference from Unity C#
View GetContext.cs
var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
@niusounds
niusounds / OrientationLiveData.kt
Created Jun 29, 2018
Device orientation sensor data for LiveData.
View OrientationLiveData.kt
import android.arch.lifecycle.LiveData
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
data class Orientation(
val azimuth: Float,
val pitch: Float,
@niusounds
niusounds / LocationLiveData.kt
Created Jun 29, 2018
Location wrapper for LiveData
View LocationLiveData.kt
import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.arch.lifecycle.LiveData
import android.content.Context
import android.content.pm.PackageManager
import android.location.Location
import android.os.Looper
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
You can’t perform that action at this time.