- Create a new Key Pair in Network & Security > Key Pairs, let’s name it “new_key_pair”: https://prnt.sc/YF3IKFzFZYtD
- Use PuTTYgen to convert the PEM file to PPK file. The PPK file will be used in PuTTY to connect in your instance. Click “Load” and open the new PEM file created from AWS. Then click “Save private key” button. It will ask for a paraphrase so click “No” if you don’t want to add extra complexity in your key: https://prnt.sc/hwXJ1aHsg02H
- Open PuTTY and connect to your instance using the PPK file.
- Once connected, type the command: cd ~/.ssh and press enter, Then type ls and press enter. You’ll see a file authorized_keys, this is the file where we are going to our new key pair.
- Let’s create a new file “new_key_pair.pem” by typing the command vi new_key_pair.pem. This will create an open the new file. Once in there, copy and paste the content of the new key pair we just created from EC2.
- Change the permission of the file by typing the command chmod 600 new_key_pair.pem.
- Next, type the command ssh-keygen -f new_key_pair.pem -y
- Copy the generated key and open the file authorized_keys by typing the command: vi authorized_keys
- Remove all the content and replace it with the generated code by ssh-keygen, make sure by the end of the content add the name “new_key_pair”
- Close session and connect using the new key pair, make sure to generate a new PPK for the new key pair PEM file.
Category: misc
Changing Alt Attribute of images
I tumbled an issue recently that the elements don’t have an alt attribute, so I added a code that will set all empty alt with a random value.
function set_empty_img_alt_attribute( $filtered_image, $context, $attachment_id ) { $string = $filtered_image; $dom = new DOMDocument(); @$dom->loadHTML($string); $image = $dom->getElementsByTagName('img')->item(0); if($image->hasAttribute('alt')) { if( $image->getAttribute('alt') == "" ) { $image->setAttribute('alt', 'dummy alt attribute'); return($dom->saveXML($image)); } } return $filtered_image; } add_filter( 'wp_content_img_tag', 'set_empty_img_alt_attribute', 10, 3 );
Changing Decimal places in Event Tickets plugin
This solution is for the WordPress plugin called Event Tickets.
Simply add these codes in your functions.php
add_filter( 'tribe_format_amount_decimals', 'change_decimal_places' ); function change_decimal_places() { return 0; // all amounts will return as a whole number }
TESDA Web Development NCIII and Regional Lead Assessor Passer
Last May 29, 2019, we have successfully passed the assessment!
CryptoGame Development using Ethereum BlockChain
Training was held at Western Visayas State University
CS10 PHP Quiz March 10
- Create a variable named ‘items’ with a value of 100.9
- Create an associative array with indexs “name”, “age”, “height” and values of “jose”, 28, “128cm” respectively, then assign it to a variable named ‘person’.
- Using the variable in #2, print the value of index ‘name’.
- Write an If statement that checks if the variable in #1 is greater than 50 then print “You have enough balance.”
- Using Foreach, loop each items in #2 and print their values.
- Create a class Ball with public property color and owner with public function named bounce.
- Create a new variable ‘spalding’ that reference to the class of #6.
- Use the variable in #7 and assign a value of “red” to property color
- Call the function bounce in variable #7
- Use the variable in #7 and assign a value of “John” to property owner.
<?php // #1 $items = 100.9 // #2 $person = array( "name" => "jose", "age" => 28, "height" => "128cm" ); // #3 echo $person[ "name" ]; // #4 if( $items > 50 ) { echo "You have enough balance."; } // #5 foreach( $person as $p ) { echo $p[ "name" ]; echo $p[ "age" ]; echo $p[ "height" ]; } // #6 class Ball { public color; public owner; public function bounce() { } } // #7 $spalding = new Ball(); // #8 $spalding->color = "red"; // #9 $spalding->bounce(); // #10 $spalding->owner = "John"; ?>
Happy Holiday!
Just a quick post saying Merry Christmas to all!!