Tuesday, May 11, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【VUE JS】Upload and Preview PDF

Posted: 10 May 2021 09:16 AM PDT

【VISUAL VB NET】Internet Properties

Posted: 10 May 2021 09:13 AM PDT

Public Class Form1 Dim cmdProcess As Process = New Process() Dim fileArgs As String Dim path As String = "C:\Windows\System32\" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click fileArgs = "Shell32.dll,Control_RunDLL Inetcpl.cpl,,6" cmdProcess.StartInfo.Arguments = fileArgs cmdProcess.StartInfo.WorkingDirectory = path cmdProcess.StartInfo.FileName = "RunDll32.exe" cmdProcess.Start() cmdProcess.WaitForExit() Me.Show() End SubEnd Class

【FLUTTER ANDROID STUDIO and IOS】Remove all multiple checked checkbox items

Posted: 10 May 2021 09:11 AM PDT

 import "package:flutter/material.dart";void main() => runApp(MyApp());


class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.deepPurple[400],
title: Text(
"Remove all checked checkbox",
),
),
body: SafeArea(
child: Center(
child: DynamicallyCheckbox(),
))),
);
}
}

class DynamicallyCheckbox extends StatefulWidget {
@override
DynamicallyCheckboxState createState() => new DynamicallyCheckboxState();
}

class DynamicallyCheckboxState extends State {
Map<String, bool> List = {
"Eggs": false,
"Chocolates": false,
"Flour": false,
"Flower": false,
"Fruits": false,
};

var holder_1 = [];

removeAllCheckItems() {
List.forEach((key, value) {
if (value == true) {
holder_1.add(key);
}
});
holder_1.forEach((element) {
setState(() {
List.remove(element);

});
});

holder_1.clear();
print(holder_1);



}

getItems() {
print(holder_1);
}

@override
Widget build(BuildContext context) {
return Column(children: <Widget>[
RaisedButton(
child: Text("Remove all Checked Items "),
onPressed: removeAllCheckItems,
color: Colors.pink,
textColor: Colors.white,
splashColor: Colors.grey,
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
),
Expanded(
child: ListView(
children: List.keys.map((String key) {
return new CheckboxListTile(
title: new Text(key),
value: List[key],
activeColor: Colors.deepPurple[400],
checkColor: Colors.white,
onChanged: (bool value) {
setState(() {
List[key] = value;
});
},
);
}).toList(),
),
),
]);
}
}

【VISUAL VB NET】Safely Remove Hardware

Posted: 10 May 2021 09:09 AM PDT

 Public Class Form1

Dim cmdProcess As Process = New Process() Dim fileArgs As String Dim path As String = "C:\Windows\System32\" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click fileArgs = "Shell32.dll,Control_RunDLL HotPlug.dll" cmdProcess.StartInfo.Arguments = fileArgs cmdProcess.StartInfo.WorkingDirectory = path cmdProcess.StartInfo.FileName = "RunDll32.exe" cmdProcess.Start() cmdProcess.WaitForExit() Me.Show() End SubEnd Class

【PYTHON OPENCV】Saving a linear regression model using SavedModelBuilder in TensorFlow

Posted: 10 May 2021 09:06 AM PDT

 """

Saving a linear regression model using SavedModelBuilder in TensorFlow
"""

# Import required packages:
import numpy as np
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from tensorflow.python.saved_model import signature_constants
from tensorflow.python.saved_model import signature_def_utils


def export_model():
  """Exports the model"""
  trained_checkpoint_prefix = 'linear_regression'
  loaded_graph = tf.Graph()
  with tf.Session(graph=loaded_graph) as sess:
    sess.run(tf.global_variables_initializer())
    # Restore from checkpoint:
    loader = tf.train.import_meta_graph(trained_checkpoint_prefix + '.meta')
    loader.restore(sess, trained_checkpoint_prefix)

    # Add signature:
    graph = tf.get_default_graph()
    inputs = tf.saved_model.utils.build_tensor_info(graph.get_tensor_by_name('X:0'))
    outputs = tf.saved_model.utils.build_tensor_info(graph.get_tensor_by_name('y_model:0'))

    signature = signature_def_utils.build_signature_def(inputs={'X': inputs},
                                                        outputs={'y_model': outputs},
                                                        method_name=signature_constants.PREDICT_METHOD_NAME)
    
    signature_map = {signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY: signature}
    
    # Export model:
    builder = tf.saved_model.builder.SavedModelBuilder('./model')
    builder.add_meta_graph_and_variables(sess, signature_def_map=signature_map,tags=[tf.saved_model.tag_constants.SERVING])
    builder.save()
                                         
                                         
# Export the model:
export_model()

# Define 'M' more points to get the predictions using the trained model:
new_x = np.linspace(50 + 150 + 103)

with tf.Session(graph=tf.Graph()) as sess:
  tf.saved_model.loader.load(sess, [tf.saved_model.tag_constants.SERVING], './my_model')
  graph = tf.get_default_graph()
  x = graph.get_tensor_by_name('X:0')
  model = graph.get_tensor_by_name('y_model:0')
  print(sess.run(model, {x: new_x}))

【VISUAL VB NET】Total Physical Memory

Posted: 10 May 2021 09:04 AM PDT

 Public Class Form1

Private Shared Function GetTotalPhysicalMemory() As ULong Return New Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory End Function Private Shared Function ConvertBytesToMegabytes(bytes As Long) As Long Return (bytes \ 1024) \ 1024 End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click MessageBox.Show(ConvertBytesToMegabytes(CLng(GetTotalPhysicalMemory())).ToString() & " MB") End SubEnd Class

【GAMEMAKER】Player Directions

Posted: 10 May 2021 09:02 AM PDT

 Information about object: objPlayer

Sprite: sprStand
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable ShotTimer to 0
set variable BulletType to 6
Step Event:
execute code:

hspeed=0;
vspeed=0;

if keyboard_check(vk_left) hspeed=-4;
if keyboard_check(vk_right) hspeed=4;
if keyboard_check(vk_up) vspeed=-4;
if keyboard_check(vk_down) vspeed=4;

if hspeed<0 && vspeed=0 {
sprite_index = sprWest;
BulletType=4;
}
if hspeed<0 && vspeed<0 {
sprite_index =(sprNorthWest);
BulletType=3;
}

if hspeed<0 && vspeed>0 {
sprite_index =(sprSouthWest);
BulletType=5;
}

if hspeed>0 && vspeed=0 {
sprite_index =(sprEast);
BulletType=0;
}
if hspeed>0 && vspeed<0 {
sprite_index =(sprNorthEast);
BulletType=1;
}
if hspeed>0 && vspeed>0 {
sprite_index =(sprSouthEast);
BulletType=7;
}

if hspeed=0 && vspeed<0 {
sprite_index =(sprNorth);
BulletType=2;
}
if hspeed=0 && vspeed>0 {
sprite_index =(sprSouth);
BulletType=6;
}

if hspeed!=0 or vspeed!=0 {
image_single=-1;
} else {
image_single=1;
}
set variable ShotTimer relative to -1
Collision Event with object objBullet2:
play sound sound0; looping: false
create instance of object objExplode at relative position (0,0)
for all objRestartRoom: set variable restart to true
destroy the instance
Keyboard Event for <Alt> Key:
if expression ShotTimer<0 is true
      create instance of object objOtherBullet at relative position (0,0)
      set variable ShotTimer to 5
Keyboard Event for <Space> Key:
if expression ShotTimer<0 is true
      create instance of object objBullet at relative position (0,0)
      set variable ShotTimer to 25
Key Press Event for X-key Key:
set Alarm 0 to 30

Information about object: objPlayer2
Sprite: sprStand
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

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

hspeed=0;
vspeed=0;

if keyboard_check(ord("D")) hspeed=-4;
if keyboard_check(ord("G")) hspeed=4;
if keyboard_check(ord("R")) vspeed=-4;
if keyboard_check(ord("F")) vspeed=4;

if hspeed<0 && vspeed=0 {
sprite_index =(sprWest);
BulletType=4;
}
if hspeed<0 && vspeed<0 {
sprite_index =(sprNorthWest);
BulletType=3;
}

if hspeed<0 && vspeed>0 {
sprite_index =(sprSouthWest);
BulletType=5;
}

if hspeed>0 && vspeed=0 {
sprite_index =(sprEast);
BulletType=0;
}
if hspeed>0 && vspeed<0 {
sprite_index =(sprNorthEast);
BulletType=1;
}
if hspeed>0 && vspeed>0 {
sprite_index =(sprSouthEast);
BulletType=7;
}

if hspeed=0 && vspeed<0 {
sprite_index =(sprNorth);
BulletType=2;
}
if hspeed=0 && vspeed>0 {
sprite_index =(sprSouth);
BulletType=6;
}

if hspeed!=0 or vspeed!=0 {
image_single=-1;
} else {
image_single=1;
}
set variable ShotTimer relative to -1
Collision Event with object objBullet:
play sound sound0; looping: false
create instance of object objExplode at relative position (0,0)
for all objRestartRoom: set variable restart to true
destroy the instance
Collision Event with object objOtherBullet:
play sound sound0; looping: false
create instance of object objExplode at relative position (0,0)
for all objRestartRoom: set variable restart to true
destroy the instance
Keyboard Event for <Ctrl> Key:
if expression ShotTimer<0 is true
      create instance of object objBullet2 at relative position (0,0)
      set variable ShotTimer to 25

Information about object: objBullet
Sprite: sprBullet
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

if objPlayer.BulletType=4 sprite_index =(sprBulletW);
if objPlayer.BulletType=3 sprite_index =(sprBulletNW);
if objPlayer.BulletType=5 sprite_index =(sprBulletSW);

if objPlayer.BulletType=0 sprite_index =(sprBulletE);
if objPlayer.BulletType=1 sprite_index =(sprBulletNE);
if objPlayer.BulletType=7 sprite_index =(sprBulletSE);

if objPlayer.BulletType=2 sprite_index =(sprBulletN);
if objPlayer.BulletType=6 sprite_index =(sprBulletS);
set speed to 8 and direction to objPlayer.BulletType*45
Other Event: Outside Room:
destroy the instance

Information about object: objBullet2
Sprite: sprBullet
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

if objPlayer2.BulletType=4 sprite_index =(sprBulletW);
if objPlayer2.BulletType=3 sprite_index =(sprBulletNW);
if objPlayer2.BulletType=5 sprite_index =(sprBulletSW);

if objPlayer2.BulletType=0 sprite_index =(sprBulletE);
if objPlayer2.BulletType=1 sprite_index =(sprBulletNE);
if objPlayer2.BulletType=7 sprite_index =(sprBulletSE);

if objPlayer2.BulletType=2 sprite_index =(sprBulletN);
if objPlayer2.BulletType=6 sprite_index =(sprBulletS);
set speed to 8 and direction to objPlayer2.BulletType*45
Other Event: Outside Room:
destroy the instance

Information about object: objExplode
Sprite: sprExplodeE
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

if objPlayer2.BulletType=4 sprite_index =(sprExplodeW);
if objPlayer2.BulletType=3 sprite_index =(sprExplodeNW);
if objPlayer2.BulletType=5 sprite_index =(sprExplodeSW);

if objPlayer2.BulletType=0 sprite_index =(sprExplodeE);
if objPlayer2.BulletType=1 sprite_index =(sprExplodeNE);
if objPlayer2.BulletType=7 sprite_index =(sprExplodeSE);

if objPlayer2.BulletType=2 sprite_index =(sprExplodeN);
if objPlayer2.BulletType=6 sprite_index =(sprExplodeS);
Other Event: Animation End:
destroy the instance

Information about object: objOtherBullet
Sprite: sprBullet
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
set speed to 8 and direction to objPlayer.BulletType*45

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

No Physics Object

Create Event:
set variable restart to false
Alarm Event for alarm 0:
Restart the current room
Alarm Event for alarm 1:
play sound sound1; looping: false
set Alarm 1 to 10
Step Event:
if restart is equal to true
      set Alarm 0 to 30
      set Alarm 1 to 10
      set variable restart to false

【VISUAL VB NET】Threads

Posted: 09 May 2021 08:52 AM PDT

 Imports System.Threading

Public Class Form1 Public Sub first_thread_procedure() Thread.Sleep(500) MessageBox.Show("Hello from first thread :) ... ") End Sub Public Sub second_thread_procedure() Thread.Sleep(1000) MessageBox.Show("Hello from second thread :) ... ") End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim first_thread As New Thread(New ThreadStart(AddressOf first_thread_procedure)) Dim second_thread As New Thread(New ThreadStart(AddressOf second_thread_procedure)) first_thread.Start() second_thread.Start() first_thread.Join() End SubEnd Class

【FLUTTER ANDROID STUDIO and IOS】circular menu

Posted: 09 May 2021 08:51 AM PDT

 import 'package:flutter/material.dart';

import 'package:circular_menu/circular_menu.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: CircularMenuDemo(),
);
}
}
class CircularMenuDemo extends StatefulWidget {
@override
_CircularMenuDemoState createState() => _CircularMenuDemoState();
}

class _CircularMenuDemoState extends State<CircularMenuDemo> {
String _colorName;

Color _color;

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBar(

automaticallyImplyLeading: false,
backgroundColor: Colors.cyan[200],
title: Text('Flutter Animated Circular Menu Demo'),
),
body: Text(""),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
},
child:CircularMenu(
alignment: Alignment.center,
backgroundWidget: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(100.0),
child: RichText(
text: TextSpan(
style: TextStyle(color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.bold),
children: <TextSpan>[
TextSpan(text: 'Press the menu button'),
],
),
),
),
),
],
),
curve: Curves.bounceOut,
reverseCurve: Curves.bounceInOut,
toggleButtonColor: Colors.cyan[400],
items: [
CircularMenuItem(
icon: Icons.home,
color: Colors.brown,
onTap: () {
setState(() {
_color = Colors.brown;
_colorName = 'Brown';
});
}),
CircularMenuItem(
icon: Icons.search,
color: Colors.green,
onTap: () {
setState(() {
_color = Colors.green;
_colorName = 'Green';
});
}),
CircularMenuItem(
icon: Icons.settings,
color: Colors.red,
onTap: () {
setState(() {
_color = Colors.red;
_colorName = 'red';
});
}),
CircularMenuItem(
icon: Icons.chat,
color: Colors.orange,
onTap: () {
setState(() {
_color = Colors.orange;
_colorName = 'orange';
});
}),
CircularMenuItem(
icon: Icons.notifications,
color: Colors.purple,
onTap: () {
setState(() {
_color = Colors.purple;
_colorName = 'purple';
});
})
],
),
backgroundColor: Colors.green,
),
),
);
}
}

【FLUTTER ANDROID STUDIO and IOS】Dinner Chooser

Posted: 09 May 2021 08:50 AM PDT

import 'package:flutter/material.dart';
import 'dart:math';
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 dinnerChooser = [
'dairy',
'seafood',
'pasta',
'vegetable',
'egg',
'fish a'
],
incrementDinner = 0,
randomDinnerChoose = "";


final inputDinner = TextEditingController();

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

// Start listening to changes.
inputDinner.addListener(_printLatestValue);
}

_printLatestValue() {

}

List shuffle(List items) {
var random = new Random();
for (var i = items.length - 1; i > 0; i--) {
var n = random.nextInt(i + 1);

var temp = items[i];
items[i] = items[n];
items[n] = temp;
}

return items;
}

randomDinner() {
if (incrementDinner == dinnerChooser.length - 1) {
incrementDinner = 0;
dinnerChooser = shuffle(dinnerChooser);
} else {
//else continue the process of increment dinner
setState(() {
incrementDinner++;
randomDinnerChoose = dinnerChooser[incrementDinner];
});


}
}

addDinner() {
if(inputDinner.text.length != 0){
dinnerChooser.add(inputDinner.text);
inputDinner.clear();
}


}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
controller: inputDinner,
),
RaisedButton(
onPressed: addDinner, child: Text("Add Dinner to the list")),
RaisedButton(onPressed: randomDinner, child: Text("Choose Dinner")),
Text(randomDinnerChoose.toString())
],
),
),

);
}
}

【JAVASCRIPT】Integration Stripe checking out with the payment request API

Posted: 09 May 2021 08:47 AM PDT

【JAVASCRIPT】draw graph an equation or graphing calculator

Posted: 09 May 2021 08:46 AM PDT

【VISUAL VB NET】System Font

Posted: 09 May 2021 08:45 AM PDT

 Imports System

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Threading.TasksImports System.Windows.Forms' make sure that using System.Diagnostics; is included Imports System.Diagnostics' make sure that using System.Security.Principal; is included Imports System.Security.Principal Imports System.Runtime.InteropServices Public Class Form1 <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _ Public Class LOGFONT Public lfHeight As Integer = 0 Public lfWidth As Integer = 0 Public lfEscapement As Integer = 0 Public lfOrientation As Integer = 0 Public lfWeight As Integer = 0 Public lfItalic As Byte = 0 Public lfUnderline As Byte = 0 Public lfStrikeOut As Byte = 0 Public lfCharSet As Byte = 0 Public lfOutPrecision As Byte = 0 Public lfClipPrecision As Byte = 0 Public lfQuality As Byte = 0 Public lfPitchAndFamily As Byte = 0 <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _ Public lfFaceName As String = String.Empty End Class Public Sub New() MyBase.New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click For Each font As FontFamily In FontFamily.Families listBox1.Items.Add(font.Name) Next End SubEnd Class

【PYTHON OPENCV】Testing a linear regression model using TensorFlow

Posted: 09 May 2021 08:43 AM PDT

 """

Testing a linear regression model using TensorFlow """ # Import required packages:import numpy as npimport tensorflow as tfimport matplotlib.pyplot as plt # Number of points:N = 50 # Make random numbers predictable:np.random.seed(101)tf.set_random_seed(101) # Generate random data composed by 50 (N = 50) points:x = np.linspace(0, N, N)y = 3 * np.linspace(0, N, N) + np.random.uniform(-10, 10, N) # Number of points to predict:M = 3 # Define 'M' more points to get the predictions using the trained model:new_x = np.linspace(N + 1, N + 10, M) # Restore the model.# First step when loading a model is to load the graph from '.meta':tf.reset_default_graph()imported_meta = tf.train.import_meta_graph("linear_regression.meta") # The second step when loading a model is to load the values of the variables:# Note that values only exist within a sessionwith tf.Session() as sess: imported_meta.restore(sess, './linear_regression') # Run the model to get the values of the variables W, b and new prediction values: W_estimated = sess.run('W:0') b_estimated = sess.run('b:0') new_predictions = sess.run(['y_model:0'], {'X:0': new_x}) # Reshape for proper visualization:new_predictions = np.reshape(new_predictions, (M, -1)) # Calculate the predictions:predictions = W_estimated * x + b_estimated # Create the dimensions of the figure and set title:fig = plt.figure(figsize=(12, 5))plt.suptitle("Linear regression using TensorFlow", fontsize=14, fontweight='bold')fig.patch.set_facecolor('silver') # Plot training data:plt.subplot(1, 3, 1)plt.plot(x, y, 'ro', label='Original data')plt.xlabel('x')plt.ylabel('y')plt.title("Training Data")plt.legend() # Plot results:plt.subplot(1, 3, 2)plt.plot(x, y, 'ro', label='Original data')plt.plot(x, predictions, label='Fitted line')plt.xlabel('x')plt.ylabel('y')plt.title('Linear Regression Result')plt.legend() # Plot new predicted data:plt.subplot(1, 3, 3)plt.plot(x, y, 'ro', label='Original data')plt.plot(x, predictions, label='Fitted line')plt.plot(new_x, new_predictions, 'bo', label='New predicted data')plt.xlabel('x')plt.ylabel('y')plt.title('Predicting new points')plt.legend() # Show the Figure:plt.show()

【GAMEMAKER】Get Color

Posted: 09 May 2021 08:40 AM PDT

 Information about object: objController

Sprite: sprController
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable Color to 0
Step Event:
execute code:

Color=draw_getpixel(mouse_x,mouse_y)
Draw Event:
execute code:

draw_text(10,10,"Color="+string(Color));
r=floor(Color mod 256);
g=floor((Color/256)mod 256);
b=floor(Color/65536);
draw_text(10,30,"Red ="+string(r));
draw_text(10,50,"Green="+string(g));
draw_text(10,70,"Blue ="+string(b));

pen_color=make_color_rgb(r,g,b);
brush_color=make_color_rgb(r,g,b);
draw_rectangle(10,300,50,400, true);
Information about object: objColorBar
Sprite: sprColorBar
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object
Information about object: objColorBar2
Sprite: sprColorBar2
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

【PYTHON OPENCV】Training a linear regression model using TensorFlow

Posted: 08 May 2021 09:42 AM PDT

 """

Training a linear regression model using TensorFlow """ # Import required packages:import numpy as npimport tensorflow as tfimport matplotlib.pyplot as plt # Path to the folder that we want to save the logs for Tensorboard:logs_path = "./logs"# Number of points:N = 50 # Make random numbers predictable:np.random.seed(101)tf.set_random_seed(101) # Generate random data composed by 50 (N = 50) points:x = np.linspace(0, N, N)y = 3 * np.linspace(0, N, N) + np.random.uniform(-10, 10, N) # You can check the shape of the created training data:print(x.shape)print(y.shape) # Create the placeholders in order to feed our training examples into the optimizer while training:X = tf.placeholder("float", name='X')Y = tf.placeholder("float", name='Y') # Declare two trainable TensorFlow Variables for the Weights and Bias# We are going to initialize them randomly. Another way can be to set '0.0':W = tf.Variable(np.random.randn(), name="W")b = tf.Variable(np.random.randn(), name="b") # Define the hyperparameters of the model:learning_rate = 0.01training_epochs = 1000 # This will be used to show results after every 25 epochs:disp_step = 100 # Construct a linear model:y_model = tf.add(tf.multiply(X, W), b, name="y_model") # Define cost function, in this case, the Mean squared error# (Note that other cost functions can be defined)cost = tf.reduce_sum(tf.pow(y_model - Y, 2)) / (2 * N) # Create the gradient descent optimizer that is going to minimize the cost function modifying the# values of the variables W and b:optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) # Initialize all variables:init = tf.global_variables_initializer() # Create a Saver object:saver = tf.train.Saver() # Start the training procedure inside a TensorFlow Session:with tf.Session() as sess: # Run the initializer: sess.run(init) # Uncomment if you want to see the created graph # summary_writer = tf.summary.FileWriter(logs_path, sess.graph) # Iterate over all defined epochs: for epoch in range(training_epochs): # Feed each training data point into the optimizer: for (_x, _y) in zip(x, y): sess.run(optimizer, feed_dict={X: _x, Y: _y}) # Display the results every 'display_step' epochs: if (epoch + 1) % disp_step == 0: # Calculate the actual cost, W and b: c = sess.run(cost, feed_dict={X: x, Y: y}) w_est = sess.run(W) b_est = sess.run(b) print("epoch {}: cost = {} W = {} b = {}".format(epoch + 1, c, w_est, b_est)) # Save the final model saver.save(sess, './linear_regression') # Storing necessary values to be used outside the session training_cost = sess.run(cost, feed_dict={X: x, Y: y}) weight = sess.run(W) bias = sess.run(b) print("Training finished!") # Calculate the predictions:predictions = weight * x + bias # Create the dimensions of the figure and set title:fig = plt.figure(figsize=(8, 5))plt.suptitle("Linear regression using TensorFlow", fontsize=14, fontweight='bold')fig.patch.set_facecolor('silver') # Plot training data:plt.subplot(1, 2, 1)plt.plot(x, y, 'ro', label='Original data')plt.xlabel('x')plt.ylabel('y')plt.title("Training Data") # Plot results:plt.subplot(1, 2, 2)plt.plot(x, y, 'ro', label='Original data')plt.plot(x, predictions, label='Fitted line')plt.xlabel('x')plt.ylabel('y')plt.title('Linear Regression Result')plt.legend() # Show the Figure:plt.show()

【VISUAL VB NET】Source Code from URL or website

Posted: 08 May 2021 09:40 AM PDT

 Imports System

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Threading.TasksImports System.Windows.Forms' make sure that using System.Diagnostics; is included Imports System.Diagnostics' make sure that using System.Security.Principal; is included Imports System.Security.Principal ' make sure that using System.Net; is included Imports System.Net ' make sure that using System.IO; is included Imports System.IO Public Class Form1 Public Sub New() MyBase.New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click Dim Url As String = textBox2.Text Dim Request As HttpWebRequest = DirectCast(WebRequest.Create(Url), HttpWebRequest) Dim Response As HttpWebResponse = DirectCast(Request.GetResponse(), HttpWebResponse) Dim Stream As New StreamReader(Response.GetResponseStream()) richTextBox1.Text = Stream.ReadToEnd() Stream.Close() End SubEnd Class

【VISUAL VB NET】Delete or Clear Cookies

Posted: 08 May 2021 09:38 AM PDT

  Public Class Form1

Dim ans As String Dim cmdProcess As Process = New Process() Dim fileArgs As String Dim path As String = "C:\Windows\System32\" Private Sub Form1_Load(sender As Object, e As EventArgs) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ans = CStr(MsgBox("Are you sure you want to delete these files?", MsgBoxStyle.YesNo, "Ready to Delete Files?")) If CDbl(ans) = vbYes Then fileArgs = "InetCpl.cpl,ClearMyTracksByProcess 8" cmdProcess.StartInfo.Arguments = fileArgs cmdProcess.StartInfo.WorkingDirectory = path cmdProcess.StartInfo.FileName = "RunDll32.exe" cmdProcess.Start() cmdProcess.WaitForExit() Me.Show() Else MessageBox.Show("Process Cancelled!") Exit Sub End If End SubEnd Class

【FLUTTER ANDROID STUDIO and IOS】checked and unchecked all checkbox

Posted: 08 May 2021 09:37 AM PDT

 import "package:flutter/material.dart";

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.deepPurple[400],
title: Text(
"Multiple Checkbox Dynamically",
),
),
body: SafeArea(
child: Center(
child: DynamicallyCheckbox(),
))),
);
}
}

class DynamicallyCheckbox extends StatefulWidget {
@override
DynamicallyCheckboxState createState() => new DynamicallyCheckboxState();
}

class DynamicallyCheckboxState extends State {
Map<String, bool> List = {
"Eggs": false,
"Chocolates": false,
"Flour": false,
"Flower": false,
"Fruits": false,
};

var holder_1 = [];

checkAllItems() {
List.forEach((key, value) {
if (value == false) {
setState(() {
List[key] = true;
holder_1.add(key);
});
}
});
print(holder_1);
}

uncheckCheckAllItems() {
List.forEach((key, value) {
if (value == true) {
setState(() {
List[key] = false;
holder_1.remove(key);
});
}
});
print(holder_1);
}

getItems() {
print(holder_1);
}

@override
Widget build(BuildContext context) {
return Column(children: <Widget>[
RaisedButton(
child: Text("Checked All Checkbox Items "),
onPressed: checkAllItems,
color: Colors.pink,
textColor: Colors.white,
splashColor: Colors.grey,
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
),
RaisedButton(
child: Text("UnChecked All Checkbox Items "),
onPressed: holder_1.length != 0 ? uncheckCheckAllItems : null,
color: Colors.pink,
textColor: Colors.white,
splashColor: Colors.grey,
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
),
RaisedButton(
child: Text(" Get Checked Checkbox Items "),
onPressed: getItems,
color: Colors.pink,
textColor: Colors.white,
splashColor: Colors.grey,
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
),
Expanded(
child: ListView(
children: List.keys.map((String key) {
return new CheckboxListTile(
title: new Text(key),
value: List[key],
activeColor: Colors.deepPurple[400],
checkColor: Colors.white,
onChanged: (bool value) {
setState(() {
List[key] = value;
if (value == false) {
holder_1.remove(key);
} else {
holder_1.add(key);
}
});
},
);
}).toList(),
),
),
]);
}
}

【GAMEMAKER】Bomb

Posted: 07 May 2021 09:10 AM PDT

Information about object: objPlayer
Sprite: sprStand
Solid: false
Visible: true
Depth: -10
Persistent: false
Parent:
Children:
Mask: sprStand
No Physics Object
Create Event:
set variable sprite to sprStand
set variable BombNumber to 0
set variable DetonateNumber to 0
set variable ShotTimer to 0
Step Event:
execute code:

hspeed=0;
vspeed=0;

if keyboard_check(vk_left) hspeed=-4;
if keyboard_check(vk_right) hspeed=4;
if keyboard_check(vk_up) vspeed=-4;
if keyboard_check(vk_down) vspeed=4;

if hspeed<0 && vspeed=0 {
sprite=sprWest;
}
if hspeed<0 && vspeed<0 {
sprite=sprNorthWest;
}

if hspeed<0 && vspeed>0 {
sprite=sprSouthWest;
}

if hspeed>0 && vspeed=0 {
sprite=sprEast;
}
if hspeed>0 && vspeed<0 {
sprite=sprNorthEast;
}
if hspeed>0 && vspeed>0 {
sprite=sprSouthEast;
}

if hspeed=0 && vspeed<0 {
sprite=sprNorth;
}
if hspeed=0 && vspeed>0 {
sprite=sprSouth;
}

sprite_index = sprite
if hspeed!=0 or vspeed!=0 {
image_single=-1;
} else {
image_single=1;
}
set variable ShotTimer relative to -1
Keyboard Event for <Space> Key:
execute code:

if ShotTimer<0 {
BombNumber+=1;
Bombs[BombNumber]=instance_create(x,y,objBomb);
ShotTimer=10;
}

Keyboard Event for D-key Key:
execute code:

if ShotTimer>0 exit;

if DetonateNumber<BombNumber {
DetonateNumber+=1;
while !instance_exists(Bombs[DetonateNumber]) {
DetonateNumber+=1;
}

score=DetonateNumber;

if floor(random(10))=1 {
with Bombs[DetonateNumber] instance_change(objDud,false);
sound_play(Dud);
} else {
with Bombs[DetonateNumber] instance_change(objExplode,false);
sound_play(Explode);
}
ShotTimer=5; 

}


Information about object: objBomb
Sprite: sprBomb
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:

No Physics Object


Information about object: objExplode
Sprite: sprExplode
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Collision Event with object objBomb:
for other object: change the instance into object objExplode, not performing events
Other Event: Animation End:

destroy the instance


Information about object: objDud
Sprite: sprDud
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Other Event: Animation End:

destroy the instance 

【FLUTTER ANDROID STUDIO and IOS】filter an array object by checking multiple values

Posted: 07 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(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: ListPage(),
);
}
}



class Car {
final String carName;
final String color;

Car({this.carName, this.color});
}
class ListPage extends StatefulWidget {
@override
_listPageState createState() => new _listPageState();
}

class _listPageState extends State<ListPage> {
List<Car> AllCars = [
new Car(carName: "Abarth", color: "red"),
new Car(carName: "Acura", color: "orange"),
new Car(carName: "Alfa Romeo", color: "rusty"),
];
List<Car> _RedCars = null;

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


String dropdownValue;

List spinnerItems;
List _selectedView = ['red', 'orange'];

@override
Widget build(BuildContext context) {
spinnerItems = AllCars.map((e) => e.color).toList();
spinnerItems = spinnerItems.toSet().toList();
_RedCars =
_selectedView != null ? AllCars.where((i) {
var selected,
isTrue = false;
for (selected = 0; selected < _selectedView.length; selected++) {
if (i.color == _selectedView[selected]) {
isTrue = true;
break;
} else {
isTrue = false;
}
}

return isTrue;
}).toList() : AllCars.toList();
return new Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
actions: <Widget>[
new PopupMenuButton(
onSelected: (value) =>
setState(() {
_selectedView.contains(value)
? _selectedView.remove(value)
: _selectedView.add(value);
}),
itemBuilder: (_) =>
[
new CheckedPopupMenuItem(
checked: _selectedView.contains('red'),
value: 'red',
child: new Text('red'),
),
new CheckedPopupMenuItem(
checked: _selectedView.contains('orange'),
value: 'orange',
child: new Text('orange'),
),
new CheckedPopupMenuItem(
checked: _selectedView.contains('rusty'),
value: 'rusty',
child: new Text('rusty'),
),
],
),

],
),
body: new Container(
child: new ListView.builder(
itemCount: _RedCars.length,
itemBuilder: (context, index) {
return new Card(
child: new ListTile(
leading: new Text(_RedCars[index].color),
title: new Text(_RedCars[index].carName),
),
margin: const EdgeInsets.all(0.0),
);
},
),
),
);
}
}

【FLUTTER ANDROID STUDIO and IOS】Snapshot like AR face filter

Posted: 07 May 2021 09:04 AM PDT

 import 'package:flutter/material.dart';

import 'package:camera_deep_ar/camera_deep_ar.dart';


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

const apiKey =
'357e97a8f4885d89efedbde9342e62a15f6cfe36e49fd27c2edbfde530d92af48853c542c324e230';

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
CameraDeepArController cameraDeepArController;
int count = 0;

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
body: Stack(
children: <Widget>[
CameraDeepAr(
onCameraReady: (isReady) {
setState(() {});
},
onImageCaptured: (path) {
setState(() {});
},
onVideoRecorded: (path) {
setState(() {});
},
androidLicenceKey: apiKey,
iosLicenceKey: apiKey,
cameraDeepArCallback: (c) async {
cameraDeepArController = c;
setState(() {});
}),
Align(
alignment: Alignment.bottomRight,
child: Container(
padding: EdgeInsets.all(20),
child: FloatingActionButton(
child: Icon(Icons.navigate_next_outlined),
onPressed: () {
cameraDeepArController.changeMask(count);
count == 7 ? count = 0 : count++;
}),
),
),
],
),
),
);
}
}

【PYTHON OPENCV】Basic Operations example using TensorFlow library creating scopes

Posted: 07 May 2021 09:03 AM PDT

 """

Basic Operations example using TensorFlow library creating scopes """ # Import required packages:import tensorflow as tf # Path to the folder that we want to save the logs for Tensorboard:logs_path = "./logs" # Define placeholders:X_1 = tf.placeholder(tf.int16, name="X_1")X_2 = tf.placeholder(tf.int16, name="X_2") # Define two operations encapsulating the operations into a scope making# the Tensorboard's Graph visualization more convenient:with tf.name_scope('Operations'): addition = tf.add(X_1, X_2, name="my_addition") multiply = tf.multiply(X_1, X_2, name="my_multiplication") # Start the session and run the operations with different inputs:with tf.Session() as sess: summary_writer = tf.summary.FileWriter(logs_path, sess.graph) # Perform some multiplications: print("2 x 3 = {}".format(sess.run(multiply, feed_dict={X_1: 2, X_2: 3}))) print("[2, 3] x [3, 4] = {}".format(sess.run(multiply, feed_dict={X_1: [2, 3], X_2: [3, 4]}))) # Perform some additions: print("2 + 3 = {}".format(sess.run(addition, feed_dict={X_1: 2, X_2: 3}))) print("[2, 3] + [3, 4] = {}".format(sess.run(addition, feed_dict={X_1: [2, 3], X_2: [3, 4]})))

【VISUAL VB NET】Shell About Dialog

Posted: 07 May 2021 08:48 AM PDT

 Imports System

Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.LinqImports System.TextImports System.Threading.TasksImports System.Windows.Forms' make sure that using System.Diagnostics; is included Imports System.Diagnostics' make sure that using System.Security.Principal; is included Imports System.Security.Principal ' make sure that using System.Runtime.InteropServices; is included Imports System.Runtime.InteropServices' make sure that using System.Reflection; is included Imports System.Reflection Public Class Form1 <DllImport("shell32.dll")> _ Private Shared Function ShellAbout(hWnd As IntPtr, szApp As String, szOtherStuff As String, hIcon As IntPtr) As Integer End Function Public Sub New() MyBase.New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click ShellAbout(Me.Handle, "AppName " & Assembly.GetExecutingAssembly().GetName().Version.ToString(), "", IntPtr.Zero) End SubEnd Class

【JAVASCRIPT】seamless carousel

Posted: 07 May 2021 08:46 AM PDT

No comments:

Post a Comment