domliang / blog Goto Github PK
View Code? Open in Web Editor NEWhexo blog
Home Page: https://domliang.github.io/blog/
hexo blog
Home Page: https://domliang.github.io/blog/
wget -O - https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh | INSTALLONLINE=1 sh
source .bashrc
# domain
acme.sh --issue -d example.com -d *.example.com --dns dns_ali --force --keylength ec-384
# --keylength ec-384 指的是使用ECDSA 证书 (384 Bits)
dns使用dns_ali 的同学请注意, 阿里云域名不支持RAM角色访问API请使用老的AccessKey进行配置
mkdir *.example.com
acme.sh --install-cert -d *.example.com \
--cert-file ~/*.example.com/cert.pem \
--key-file ~/*.example.com/key.pem \
--fullchain-file ~/*.example.com/fullchain.pem \
--reloadcmd "systemctl reload nginx.service"
使用aws china的同学注意了, 由于aws**无法申请证书所以我们需要将我们的证书换上去, 需要注意的一点是证书链 key.pem填入密钥, cert.pem填入证书, 证书链中我们填的并不是fullchain.pem, 而是我们要从fullchain.pem 中去掉 cert.pem的其他部分, 否则会报错
acme.sh --renew -d *.example.com -d example.com --force --ecc
# --ecc 指定ECDSA证书
$ npx egg-init --type=ts showcase
$ cd showcase && npm i
$ npm run dev
showcase
├── app
│ ├── controller
│ │ └── home.ts
│ ├── service
│ │ └── news.ts
│ └── router.ts
├── config
│ ├── config.default.ts
│ ├── config.local.ts
│ ├── config.prod.ts
│ └── plugin.ts
├── test
│ └── **/*.test.ts
├── typings
│ └── **/*.d.ts
├── README.md
├── package.json
├── tsconfig.json
└── tslint.json
// app/controller/home.ts
import { Controller } from 'egg';
export default class HomeController extends Controller {
public async index() {
const { ctx, service } = this;
const page = ctx.query.page;
const result = await service.news.list(page);
await ctx.render('home.tpl', result);
}
}
// app/router.ts
import { Application } from 'egg';
export default (app: Application) => {
const { router, controller } = app;
router.get('/', controller.home.index);
};
// app/service/news.ts
import { Service } from 'egg';
export default class NewsService extends Service {
public async list(page?: number): Promise<NewsItem[]> {
return [];
}
}
export interface NewsItem {
id: number;
title: string;
}
import { Context } from 'egg';
// 这里是你自定义的中间件
export default function fooMiddleware(): any {
return async (ctx: Context, next: () => Promise<any>) => {
// 你可以获取 config 的配置:
// const config = ctx.app.config;
// config.xxx....
await next();
};
}
主要用到3个库flutter_localizations
intl
intl_translation
dependencies:
flutter_localizations:
sdk: flutter
intl: 0.15.7
dev_dependencies:
intl_translation: 0.17.4
return MaterialApp(
onGenerateTitle: (BuildContext context) =>
AppLocalizations.of(context).title,
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: routes.buildPage('login', null),
localizationsDelegates: [
// ... app-specific localization delegate[s] her
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
// 支持语言设置
const Locale('en', 'US'), // English
const Locale('zh', 'CH'), // Chinese
// ... other locales the app supports
],
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute<Object>(builder: (BuildContext context) {
return routes.buildPage(settings.name, settings.arguments);
});
},
);
Lib/localizations.dart
import 'package:flutter/material.dart';
// import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart';
import 'l10n/messages_all.dart';
class AppLocalizations {
static Future<AppLocalizations> load(Locale locale) {
final String name =
locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
final String localeName = Intl.canonicalizedLocale(name);
return initializeMessages(localeName).then((_) {
Intl.defaultLocale = localeName;
print(
'the local code of $localeName ${locale.countryCode.isEmpty} ${locale}');
return AppLocalizations();
});
}
static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
String get title {
return Intl.message(
'Hello World',
name: 'title',
desc: 'Title for the Demo application',
);
}
}
class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
const AppLocalizationsDelegate();
@override
bool isSupported(Locale locale) => ['en', 'zh'].contains(locale.languageCode);
@override
Future<AppLocalizations> load(Locale locale) => AppLocalizations.load(locale);
@override
bool shouldReload(AppLocalizationsDelegate old) => false;
}
导出命令
flutter pub pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/localizations.dart
导出的文件 l10n/intl_messages.arb
{
"@@last_modified": "2019-04-28T15:58:14.536252",
"title": "Hello World",
"@title": {
"description": "Title for the Demo application",
"type": "text",
"placeholders": {}
}
}
l10n/intl_en.arb
{
"@@last_modified": "2019-04-28T15:58:14.536252",
"title": "Hello World",
"@title": {
"description": "Title for the application",
"type": "text",
"placeholders": {}
}
}
l10n/intl_zh.arb
{
"@@last_modified": "2019-04-28T15:58:14.536252",
"title": "你好世界",
"@title": {
"description": "Title for the application",
"type": "text",
"placeholders": {}
}
}
命令
flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n \
--no-use-deferred-loading lib/localizations.dart lib/l10n/intl_*.arb
import 'localizations.dart';
...
AppLocalizations.of(context).title
打开ios/Runner.xcworkspace
找到Runner的Info.plist
添加一个key为Localizations
value为你支持的语言
good luck
[Flutter/Dart] The class can’t be used as a mixin because it extends a class other than Object. Error [mixin_inherits_from_not_object]
# pubspec.yaml
analyzer:
strong-mod: true
language:
enableSuperMixins: true
# analysis_options.yaml
analyzer:
errors:
mixin_inherits_from_not_object: ignore
2019年1月1日收到一个新年礼物, 打开发现是一个树莓派. 真的很开心收到这个礼物, 但是这也意味着我要分一部分时间去找个这个小可爱了
到手第一件事, 就是给他装一个系统, 我收到的树莓派是 Raspberry Pi 3B+, 我看到官网上支持一直想尝试的Snappy Ubuntu Core于是我就开始了土坑模式.
按照文档把系统装好后发现, 换了网络后每次用本 ssh 链接 树莓派很麻烦, 由于3B+自带网卡所以起个ap不是啥难事(无外接硬件), 所以上网搜了一下还真的很简单
snap set wifi-ap automatic-setup.disable=true
如果没有安装wifi-ap会出现如下错误
Command "wifi-ap" not found, but can be installed with:
sudo snap install wifi-ap
See 'snap info <snap name>' for additional versions.
好吧缺少包 执行安装
sudo snap install wifi-ap
wifi-ap 21 from Canonical✓ installed
设置打开
sudo snap set wifi-ap automatic-setup.disable=true
交互式设置更多
sudo wifi-ap.setup-wizard
have fun ❤️
配置完flutter之后执行
flutter doctor -v
执行结果是
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G4015, locale zh-Hans-CN)
• Flutter version 1.0.0 at /Users/Dom/development/flutter
• Framework revision 5391447fae (2 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /usr/local/Cellar/android-sdk/24.4.1_1
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.2.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.30.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.21.1
[✓] Connected device (1 available)
• DOM • 00008020-000D78960A82002E • ios • iOS 12.1
! Doctor found issues in 1 category.
WFT
✗ Android license status unknown.
是什么鬼
然后我就执行了
flutter doctor --android-licenses
同意licenses就好了
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G4015, locale zh-Hans-CN)
• Flutter version 1.0.0 at /Users/Dom/development/flutter
• Framework revision 5391447fae (2 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /usr/local/Cellar/android-sdk/24.4.1_1
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.2.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.30.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.21.1
[✓] Connected device (1 available)
• DOM • 00008020-000D78960A82002E • ios • iOS 12.1
• No issues found!
enjoy it ❤️
如果我们使用mon-put-instance-data.pl上传内存,当我们配置好crontab后创建ami然后新建新的实例后,上传的任然是上一个instance的id.
确切的说是会有6个小时的错误.
参见文档最下面
所以我们在创建ami之前应该先执行
rm /var/tmp/aws-mon/instance-id
这样新建的instance就不会受缓存影响
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.