Friday, May 21, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【FLUTTER ANDROID STUDIO and IOS】form password strength validation

Posted: 20 May 2021 09:07 AM PDT

 import 'package:flutter/material.dart';


void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Validation',
home: HomePage(),
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
final _formKey = GlobalKey<FormState>();

String _userEmail = '';
String _userName = '';
String _password = '';
String _confirmPassword = '';

void _trySubmitForm() {
final isValid = _formKey.currentState.validate();
if (isValid) {
print('Everything looks good!');
print(_userEmail);
print(_userName);
print(_password);
print(_confirmPassword);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
alignment: Alignment.center,
child: Center(
child: Card(
margin: EdgeInsets.symmetric(horizontal: 35),
child: Padding(
padding: const EdgeInsets.all(20),
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextFormField(
decoration: InputDecoration(labelText: 'Email'),
validator: (value) {
if (value
.trim()
.isEmpty) {
return 'Please enter your email address';
}
if (!RegExp(r'\S+@\S+\.\S+').hasMatch(value)) {
return 'Please enter a valid email address';
}
return null;
},
onChanged: (value) => _userEmail = value,
),

TextFormField(
decoration: InputDecoration(labelText: 'Username'),
validator: (value) {
if (value
.trim()
.isEmpty) {
return 'This field is required';
}
if (value
.trim()
.length < 4) {
return 'Username must be at least 4 characters in length';
}
return null;
},
onChanged: (value) => _userName = value,
),

TextFormField(
decoration: InputDecoration(labelText: 'Password'),
obscureText: true,
validator: (value) {
if (value
.trim()
.isEmpty) {
return 'This field is required';
}
if (value
.trim()
.length < 8) {
return 'Password must be at least 8 characters in length';
}

if (!RegExp(r'[a-z]').hasMatch(value) == true) {
return "Password must be at least Lower case letter";
}
if (!RegExp(r'\d').hasMatch(value) == true) {
return "Password must be at least have number";
}

if (!RegExp(r'[A-Z]').hasMatch(value) == true) {
return "Password must be at least have Uppercase letter";
}
return null;
},
onChanged: (value) => _password = value,
),
TextFormField(
decoration:
InputDecoration(labelText: 'Confirm Password'),
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'This field is required';
}

if (value != _password) {
return 'Confimation password does not match the entered password';
}

return null;
},
onChanged: (value) => _confirmPassword = value,
),
SizedBox(height: 20),
Container(
alignment: Alignment.centerRight,
child: OutlinedButton(
onPressed: _trySubmitForm,
child: Text('Sign Up')))
],
)),
)),
),
),
),
);
}
}

【JAVASCRIPT】canvas realizes colorful clock effect

Posted: 20 May 2021 09:06 AM PDT

【VUEJS】 slide able delete function

Posted: 20 May 2021 09:04 AM PDT

【ANDROID STUDIO】View Model With Data Binding

Posted: 20 May 2021 09:02 AM PDT

 package com.example.databinding


import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.example.databinding.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding
private lateinit var viewModel: MainActivityViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
viewModel = ViewModelProvider(this).get(MainActivityViewModel::class.java)
binding.myViewModel = viewModel
viewModel.count.observe(this, Observer {
binding.countText.text = it.toString()
})

}
}
package com.example.databinding

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class MainActivityViewModel : ViewModel() {
var count = MutableLiveData<Int>()

init {
count.value = 0
}

fun updateCount() {
count.value = (count.value)?.plus(1)
}
}

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
name="myViewModel"
type="com.example.databinding.MainActivityViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView android:id="@+id/count_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="66sp"
android:textStyle="bold"
android:typeface="serif"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.262" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Here"
android:textSize="30sp"
android:onClick="@{()->myViewModel.updateCount()}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>

【FLUTTER ANDROID STUDIO and IOS】Permutation App

Posted: 20 May 2021 09:00 AM PDT

 import 'package:flutter/material.dart';


void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);


final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
var lastdivnum = 1,
permObj = [
],
output = '',
order = 1,
prefix = {
"setprefix": '',
"setsuffix": '',
"objdelimiter": '',
"objjoin": ''
};
final controllerOutput = TextEditingController();

@override
void initState() {
super.initState();
}

@override
void dispose() {
controllerOutput.dispose();
super.dispose();
}

permute() {
var permute = (v, {m = false}) {
var p = -1,
j,
k,
f,
r,
l = v.length,
q = 1,
i = l + 1;
--i;
q *= i;
var x = [new List(l), new List(l), new List(l), new List(l)];
j = q;
k = l + 1;
i = -1;
for (; ++i < l; x[2][i] = i, x[1][i] = x[0][i] = j /= --k) {

}

for (r = new List(q); ++p < q;) {
r[p] = new List(l);
i = -1;
for (; ++i < l; --x[1][i] != --x[1][i]) {
x[1][i] = x[0][i];
x[2][i] = (x[2][i] + 1) % l;
if (x[3][i] != null) r[p][i] = m ? x[3][i] : v[x[3][i]];
f = 0;

for ((x[3][i] = x[2][i]); !(f == 0); f = !f) {
for (j = i; j == true; x[3][--j] == x[2][i] &&
(x[3][i] = x[2][i] = (x[2][i] + 1) % l && f == 1)) {

}
}
}
}

return r;
};
var perobjs = new List();
var perobjscnt = 0;
var permobj = '';

for (var x = 0; x < permObj.length; x++) {
permobj = permObj[x]["value"];
if (permobj != '') {
perobjs.add(permobj);
perobjscnt++;
}
}
var pre = prefix["setprefix"].replaceAll(r'/\\x/g', '\n');
var suf = prefix["setsuffix"].replaceAll(r'/\\x/g', '\n');
var joinobjs = prefix["objdelimiter"].replaceAll(r'/\\x/g', '\n');
var joinperms = prefix["objjoin"].replaceAll(r'/\\x/g', '\n');

var out = permute(perobjs).map((objs) {
return objs[0] != null ? objs.join(joinobjs) + "\n" : perobjs.join(
joinobjs) + "\n";
});

setState(() {
output = out = out.join(joinperms);
});

controllerOutput.text = output;
print(output);
}

var todo = List<Widget>();
int _index = 0;

void _add() {
int keyValue = _index;
permObj.add({'id': _index, 'value': '',});
var _formdataIndex = permObj.indexWhere((data) => data['id'] == keyValue);

todo = List.from(todo)
..add(Column(
key: Key("${keyValue}"),
children: <Widget>[
ListTile(
leading: Text('Name: '),
title: TextField(
onChanged: (val) {
permObj[_formdataIndex]['value'] = val;
},
),
),
],
));
setState(() => ++_index);
}


@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: permute,
child: Icon(Icons.link),
),
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
FlatButton(
child: Icon(Icons.add, color: Colors.white,),
onPressed: _add,
),
],
),
body: Center(
child: SingleChildScrollView(
child: Column(
children: [
...todo,
TextField(controller: controllerOutput, maxLines: 10,)],
),
),
),
);
}
}

【Visual Studio Visual Csharp】HTTP Download

Posted: 20 May 2021 08:58 AM PDT

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Net; // make sure that using System.Net; is included using System.Diagnostics; // make sure that using System.Diagnostics; is included namespace HttpDownloadC{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } WebClient webClient = new WebClient(); private void button1_Click(object sender, EventArgs e) { webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webclient_DownloadFileCompleted); // start download webClient.DownloadFileAsync(new Uri(textBox1.Text), @"C:\\MYRAR.EXE"); } void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { double bytesIn = double.Parse(e.BytesReceived.ToString()); double totalBytes = double.Parse(e.TotalBytesToReceive.ToString()); double percentage = bytesIn / totalBytes * 100; progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString()); } void webclient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { MessageBox.Show("Saved as C:\\MYRAR.EXE", "Httpdownload"); } }}

【PYTHON】metric log loss

Posted: 20 May 2021 08:57 AM PDT

from pandas import read_csv
from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression

filename = 'pima-indians-diabetes.csv'
names = ['preg''plas''pres''skin''test''mass''pedi''age''class']
dataframe = read_csv(filename, names=names)

array = dataframe.values

#splitting the array to input and output
X = array[:,0:8]
Y = array[:,8]



kfold = KFold(n_splits=10, random_state = 7)
model = LogisticRegression(solver='liblinear')
scoring = 'neg_log_loss'

results = cross_val_score(model, X, Y, cv=kfold, scoring=scoring)
print("Log Loss: %.3f (%.3f) " % (results.mean(), results.std()))

【GAMEMAKER】Invaders

Posted: 20 May 2021 08:55 AM PDT

 Information about object: objInvader1

Sprite: sprInvader1
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children
objInvader2
objInvader3
objInvader4
objInvader5
Mask:
No Physics Object
Create Event:
set variable global.Dir to 1
set variable image_speed to 0.1
Step Event:
execute code:

if floor(random(750))=1 instance_create(x+sprite_width/2,y,objEnemyBullet);
Collision Event with object objStopper:
set variable global.Dir to global.Dir*-1
for all objInvader1: jump relative to position (16*global.Dir,32)
for all objInvader2: jump relative to position (16*global.Dir,32)
for all objInvader3: jump relative to position (16*global.Dir,32)
for all objInvader4: jump relative to position (16*global.Dir,32)
for all objInvader5: jump relative to position (16*global.Dir,32)
Collision Event with object objPlayerBullet:
destroy the instance
for other object: destroy the instance
play sound sound0; looping: false
Other Event: Animation End:
jump relative to position ((16*global.Dir),0)

Information about object: objInvader2
Sprite: sprInvader2
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: objInvader1
Children:
Mask:

No Physics Object

Information about object: objInvader3
Sprite: sprInvader3
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: objInvader1
Children:
Mask:

No Physics Object
Information about object: objInvader4
Sprite: sprInvader4
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: objInvader1
Children:
Mask:

No Physics Object

Information about object: objInvader5
Sprite: sprInvader5
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: objInvader1
Children:
Mask:

No Physics Object

Information about object: objBarrier
Sprite: SprBarrier
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
set variable image to 0
Step Event:
set variable image_single to image
Collision Event with object objInvader1:
destroy the instance
Collision Event with object objPlayerBullet:
execute code:

image+=1;
if image>4 instance_destroy();
for other object: destroy the instance
Collision Event with object objEnemyBullet:
for other object: destroy the instance

Information about object: objPlayer
Sprite: sprPlayer
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
set variable ShotTimer to 0
Step Event:
execute code:

hspeed=0;
ShotTimer-=1;
if keyboard_check(vk_left) hspeed=-4;
if keyboard_check(vk_right) hspeed=4;
if keyboard_check(vk_space) {
if ShotTimer<0 {
instance_create(x+sprite_width/2,y,objPlayerBullet);
ShotTimer=15;
}
}

EnemyCount=instance_number(objInvader1)+instance_number(objInvader2)+instance_number(objInvader3)+instance_number(objInvader4)+instance_number(objInvader5);
if EnemyCount=0 {
//You would advance to the next level here
if show_question("You have completed the demo.## Would you like to play again?") {
game_restart();
} else {
game_end();
}
}

Collision Event with object objInvader1:
execute code:

if show_question("You have lost!##Would you like to play again?") {
game_restart();
} else {
game_end();
}

Collision Event with object objEnemyBullet:
execute code:

if show_question("You have lost!##Would you like to play again?") {
game_restart();
} else {
game_end();
}

Other Event: Game Start:
Open a URL: 0

Information about object: objStopper
Sprite: sprStopper
Solid: true
Visible: false
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Information about object: objPlayerBullet
Sprite: sprPlayerBullet
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
start moving in directions 000000010 with speed set to 8

Information about object: objEnemyBullet
Sprite: sprEnemyBullet
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
start moving in directions 010000000 with speed set to 8

No comments:

Post a Comment