Posts

Showing posts from September, 2020

Flutter - App Orientation

void main () => runApp( MyApp ()) ; class MyApp extends StatelessWidget { @override Widget build (BuildContext context) { SystemChrome. setPreferredOrientations ( [DeviceOrientation. landscapeLeft , DeviceOrientation. landscapeRight ]) ;

Flutter - Cocoapod update

Image
 20200921 pod repo update sudo gem install cocoapods pod setup

Flutter - change PRODUCT_BUNDLE_IDENTIFIER in 2020

20200920   1.app /  build.gradle defaultConfig  defaultConfig { applicationId "co.yourName.appName" 2.app/src/main/ AndroidManifest.xml  3.app/src/debug/ AndroidManifest.xml   4.app/src/profile/ AndroidManifest.xml   <manifest xmlns: android ="http://schemas.android.com/apk/res/android" package ="co.yourName.appName" > 5. app/main/kotlin/ co/yourName/ newName  6.app/main/kotlin/ co/ yourName / newName/  MainActivity.java   package co.yourName.appName ; 7.pubspec.yaml name : appName 8. lib all dart file  change appName 9.Runner.xcodeproj  /  project.pbxproj    (there are 3  PRODUCT_BUNDLE_IDENTIFIER ) must be changed.) PRODUCT_BUNDLE_IDENTIFIER = co.yourName.appName; 10. terminal  flutter clean 11. File >Invalidate Caches/Restart... 👍done

Flutter - AnimationController

class _WelcomeScreenState extends State<WelcomeScreen> with SingleTickerProviderStateMixin { AnimationController controller ; Animation animation ; @override void initState () { super .initState() ; controller = AnimationController ( duration: Duration (seconds: 1 ) , //0 to 1 in 60 steps tickers. vsync: this, //SingleTickerProviderStateMixin class is going to provide animation Ticker // upperBound: 100.0,有curve class必須小於1,以避免衝突 ) ; animation = CurvedAnimation ( parent: controller , curve: Curves. easeIn ) ; //upperBound 需小於1 controller .forward() ; //Get the animation to start. proceed the animation forward(small to big) controller .addStatusListener((status) { if (status == AnimationStatus. completed ) { controller .reverse(from: 1.0 ) ;//值由小到大 } else if (status == AnimationStatus. dismissed ) { controller .forward() ; } print( animation . status ) ; }) ; //Ca

Flutter - " control-flow-collections' experiment to be enabled "

environment sdk 改成2.6.0 後,重啟就不會出現錯誤了。 environment : sdk : ">=2.8.0 <3.0.0" items: [ for ( var i in currenciesList) DropdownMenuItem ( child: Text ( ' $i ' ) , value: ' $i ' , )], 

Dart syntax- Future,asyc,await

Image
import 'dart:io' ; void main () { performTasks() ; } void performTasks () async { //i have someone need a wait team1() ; String task2result = await team2() ; //my team there is someone need to wait. team3(task2result) ; } void team1 () { print( 'task 1 complete' ) ; } Future team2 () async { //in the future team2, there is someone who is call "await" need to wait. String result ; print( 'there is team2. Someone who is call "await" need a wait.' ) ; await Future . delayed ( //pls wait for me. Duration (seconds: 3 , ) , () { result = 'task 2 await \' s Data.' ; print( 'task 2 complete. \' await \' is giving his data to team3.' ) ; } , ) ; return result ; } void team3 (String task2Data) { print( 'task 3 complete, i got $task2Data ' ) ; } ☝ asychrony   等可能很耗時的程式設置好後再返回future/steam物件。從出發到結果中間無await標示的可以先執行。 ☝Future async + await 2.使用Futurn type 必須先聲明async ☝Steam 有兩個方法

Flutter - xylophone project

Image
import 'package:flutter/material.dart' ; import 'package:audioplayers/audio_cache.dart' ; void main () => runApp( XylophoneApp ()) ; class XylophoneApp extends StatelessWidget { void audioPlayer (int musicNum) { final player = AudioCache () ; player.play( 'note $musicNum .wav' ) ; } Expanded keyboard ({Color color , int musicNum}) { return Expanded ( child: FlatButton ( color: color , onPressed: () { audioPlayer(musicNum) ; } , ) , ) ; } @override Widget build (BuildContext context) { return MaterialApp ( debugShowCheckedModeBanner: false, home: Scaffold ( body: SafeArea ( child: Center ( child: Column ( crossAxisAlignment: CrossAxisAlignment. stretch , children: [ keyboard(color: Colors. red , musicNum: 1 ) , keyboard(color: Colors. orange , musicNum: 2 ) , keyboard

Flutter- Dicee project

Image
  import 'package:flutter/material.dart' ; import 'dart:math' ; void main () => runApp( MaterialApp ( debugShowCheckedModeBanner: false, home: Scaffold ( backgroundColor: Colors. red , appBar: AppBar ( backgroundColor: Colors. red , title: Text ( 'Dice' , style: TextStyle ( color: Colors. white , ) , ) , centerTitle: true, ) , body: DicePage ())) , ) ; class DicePage extends StatefulWidget { @override _DicePageState createState () => _DicePageState () ; } class _DicePageState extends State<DicePage> { int leftDiceNum = 1 ; int RightDiceNum = 1 ; void change () { setState(() { leftDiceNum = Random ().nextInt( 6 ) + 1 ; RightDiceNum = Random ().nextInt( 6 ) + 1 ; }) ; } @override Widget build (Bui

Python - with BIAS & RSI

from pandas_datareader import data as web from mpl_finance import candlestick_ohlc from matplotlib import pyplot as plt from matplotlib import style import matplotlib.dates as mdates import yfinance as yf import datetime as dt import pandas as pd import numpy as np import time style.use('dark_background') yf.pdr_override() ma1 = 5 ma2 = 20 print('Stock Number:') stock_no = input() csv_file = '/users/jht/Desktop/python/stockData/'+stock_no+'.csv' start = dt.datetime(2020, 1, 1) end = dt.datetime.now() df = web.get_data_yahoo(stock_no + '.TW', start, end) df.to_csv(csv_file) time.sleep(2) data = pd.read_csv(csv_file, parse_dates=True, index_col='Date') data.head() close = data["Close"] avg = sum(close)/len(close) top = plt.subplot2grid((21, 9), (0, 0), rowspan=9, colspan=9)#整個畫面共有(21row,9col),其位於(0row,0col),此占各9row&col bottom = plt.subplot2grid((21, 9), (12, 0), rowspan=3, colspan=9, sharex=top) bottom1 = plt.subplot2gr

Python - get data from yahoo

Image
  from matplotlib import pyplot as plt from matplotlib import style from pandas_datareader import data as web import yfinance as yf #需要yf.pdr_override() import pandas as pd import datetime as dt import csv yf.pdr_override() print ( 'Stock Number:' ) stock_no = input () csv_file = '/users/jht/Desktop/python/stockData/' +stock_no+ '.csv' start = dt.datetime( 2017 , 6 , 14 ) end = dt.datetime( 2020 , 9 , 1 ) get = web.get_data_yahoo(stock_no+ '.TW' , start , end) get.to_csv(csv_file) #得到的數據匯入csv檔 data = pd.read_csv(csv_file , parse_dates = True, index_col = 'Date' ) #以index_col對應依據 price = data[ 'Close' ] data = data.reset_index() #回到最初 plt.plot(price) plt.show()

Adobe XD

adobe XD wireframes For a transition to work the artboards must either be the same size or, if scrolling is enabled for the artboards, have the same "Viewport Height". Hope this helps!

Python -cvs vs txt

Image
from matplotlib import pyplot as plt from matplotlib import style import pandas as pd import csv #python內建 style.use( 'ggplot' ) #txt轉成csv #讀取數據 txtPath = '/users/jht/Desktop/python/stockData/2330.txt' readTxt = csv.reader( open (txtPath , 'r' ) , delimiter = ',' ) #以','符號定界分行delimiter #匯入並創建csv檔案 cvsPath = '/users/jht/Desktop/python/stockData/2330.csv' writeCsv = csv.writer( open (cvsPath , 'w' )) writeCsv.writerow([ 'NO' , 'price' ]) #設定row heaer writeCsv.writerows(readTxt) #匯入txt x=[] y=[] with open (txtPath , 'r' ) as txt2330: #以r唯讀,打開檔案,呼叫用txt2330 plots = csv.reader(txt2330 , delimiter = ',' ) for row in plots: x.append( float (row[ 0 ])) y.append( float (row[ 1 ])) plt.subplot( 211 ) plt.plot(x , y) plt.subplot( 212 ) data = pd.read_csv(cvsPath , parse_dates = True, index_col = 'NO' ) #以parse_dates判定x,y個數相等 print (data.head()) plt.plot(data[ 'price' ] ,