Monday, April 26, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【VISUAL VB NET】Stored Username and Password

Posted: 26 Apr 2021 03:24 AM PDT

 Public Class Form1

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

【PYTHON OPENCV】Testing a linear regression model using Keras

Posted: 25 Apr 2021 08:52 AM PDT

 """

Testing a linear regression model using Keras """ # Import required packagesfrom keras.models import Sequentialfrom keras.layers import Densefrom keras.optimizers import Adamimport numpy as npimport matplotlib.pyplot as plt # Number of points:N = 50 # 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) # Make random numbers predictable:np.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) def get_weights(model): m = model.get_weights()[0][0][0] b = model.get_weights()[1][0] return m, b def create_model(): """Create the model using Sequential model""" # Create a sequential model: model = Sequential() # All we need is a single connection so we use a Dense layer with linear activation: model.add(Dense(input_dim=1, units=1, activation="linear", kernel_initializer="uniform")) # Compile the model defining mean squared error(mse) as the loss model.compile(optimizer=Adam(lr=0.1), loss='mse') # Return the created model return model # Get the created modellinear_reg_model = create_model() # Load weights:linear_reg_model.load_weights('my_model.h5') # Show weights when the training is done (learned parameters):m_final, b_final = get_weights(linear_reg_model)print('Linear regression model is trained with weights w: {}, b: {}'.format(m_final, b_final)) # Get the predictions of the training data:predictions = linear_reg_model.predict(x) # Get new predictions:new_predictions = linear_reg_model.predict(new_x) # Create the dimensions of the figure and set title:fig = plt.figure(figsize=(12, 5))plt.suptitle("Linear regression using Keras", 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") # 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】Memory Puzzle

Posted: 25 Apr 2021 08:45 AM PDT

 Information about object: obj_level

Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///set up cards

//set random seed
randomize();
deck=ds_list_create();//create a list
//add 2 of each card to deck:
ds_list_add(deck,spr_1,spr_1);
ds_list_add(deck,spr_2,spr_2);
ds_list_add(deck,spr_3,spr_3);
ds_list_add(deck,spr_4,spr_4);
ds_list_add(deck,spr_5,spr_5);
ds_list_add(deck,spr_6,spr_6);
ds_list_add(deck,spr_7,spr_7);
ds_list_add(deck,spr_8,spr_8);
ds_list_add(deck,spr_9,spr_9);
ds_list_add(deck,spr_10,spr_10);
ds_list_add(deck,spr_11,spr_11);
ds_list_add(deck,spr_12,spr_12);
ds_list_add(deck,spr_13,spr_13);
ds_list_add(deck,spr_14,spr_14);
ds_list_add(deck,spr_15,spr_15);
ds_list_add(deck,spr_16,spr_16);
ds_list_add(deck,spr_17,spr_17);
ds_list_add(deck,spr_18,spr_18);
//shuffle the deck:
ds_list_shuffle(deck);

//create a grid of cards with this list
var i;
for (i = 0; i <= 35; i += 1)
{

card=instance_create(70+(i mod 6)*70,70+(i div 6)*70,obj_card);
card.sprite_index=deck[| i];
card.xx=i mod 6;
card.yy=i div 6;
card.flipped=false;
}

//create a list to hold player's selections
global.selected=ds_list_create();Information about object: obj_card
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Mouse Event for Left Pressed:
execute code:

///allow flipping if only none or one card selected
if !flipped && global.plays<2
{
flipped=true;//set flag so face can be shown
ds_list_add(global.selected,id);//add the id to a list
global.plays++;//mark as a selection made
}
Draw Event:
execute code:

///draw front or back of card
if flipped
{
draw_sprite(spr_front_med,0,x,y);//show back
draw_self();//show front
}
else
draw_sprite(spr_back_med,0,x,y);//show back
Information about object: obj_control
Sprite:
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

///set up
goes=25;//how many attempts the player gets
global.plays=0;
matches=0;
Alarm Event for alarm 0:
execute code:

///flip cards back to showing back if not matched
card1.flipped=false;
card2.flipped=false;
global.plays=0;//allow playing again
Step Event:
execute code:

///check cards
if ds_list_size(global.selected)==2//check if two cards selected
{
if global.selected[|0].sprite_index == global.selected[|1].sprite_index //check if cards face image matches
{
//if matched:
ds_list_clear(global.selected);
goes--;
global.plays=0;
matches++;
}
else
{
//if not matched
card1=global.selected[|0];//these two cards are to store id for alarm event
card2=global.selected[|1];
ds_list_clear(global.selected);
goes--;
alarm[0]=room_speed;
}
}

//check for game end
if goes==0
{
show_message("You Lose");
game_restart();
}

if matches==18
{
show_message("You Win");
game_restart();
}
Draw Event:
execute code:

draw_text(10,10,"Tries remainging "+string(goes));

【VISUAL VB NET】open and Write a new ms word or document

Posted: 25 Apr 2021 08:39 AM PDT

Imports SystemImports 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 Microsoft.Office.Interop.Word; is included & added references Office 14 version Imports Microsoft.Office.Interop.Word ' make sure that using System.IO; Imports System.IO ' make sure that using System.Threading; Imports System.Threading Public Class Form1 Public filePath As String = "c:\msword.docx" Public Sub New() MyBase.New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click Process.Start("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Word 2010.lnk") End Sub Public Sub openWordDocument(filePath As String) Dim missing As Object = System.Reflection.Missing.Value 'create a document in this path Dim fileName As Object = filePath Dim wordApp As Object = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application")) 'Setup our Word.Document Dim wordDoc As Object = wordApp.[GetType]().InvokeMember("Documents", System.Reflection.BindingFlags.GetProperty, Nothing, wordApp, Nothing) 'Set Word to be not visible wordApp.[GetType]().InvokeMember("Visible", System.Reflection.BindingFlags.SetProperty, Nothing, wordApp, New Object() {True}) 'Open the word document fileName Dim activeDoc As Object = wordDoc.[GetType]().InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, Nothing, wordDoc, New [Object]() {fileName}) End Sub Private Sub button2_Click(sender As Object, e As EventArgs) Handles button2.Click ' create file If Not File.Exists(filePath) Then Using st As FileStream = System.IO.File.Create(filePath) Thread.Sleep(700) End Using openWordDocument(filePath) Else MessageBox.Show("Document already exists!" & vbLf & "Delete """ & filePath & """ to create new document!") End If End SubEnd Class

【JAVASCRIPT】native component random paragraph size placeholder

Posted: 25 Apr 2021 03:31 AM PDT

No comments:

Post a Comment