Skip to content

Instantly share code, notes, and snippets.

View peiris's full-sized avatar
🍃

Kasun Peiris peiris

🍃
View GitHub Profile
@peiris
peiris / better-font-smoothing.css
Created October 15, 2018 06:12 — forked from hsleonis/better-font-smoothing.css
Better font smoothing in cross browser
html {
/* Adjust font size */
font-size: 100%;
-webkit-text-size-adjust: 100%;
/* Font varient */
font-variant-ligatures: none;
-webkit-font-variant-ligatures: none;
/* Smoothing */
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
@peiris
peiris / CountryCodes.json
Created October 4, 2018 11:40 — forked from aosunbiyi/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@peiris
peiris / OSX Secure Disk Wipe.md
Created September 26, 2018 07:56 — forked from joeblau/OSX Secure Disk Wipe.md
Securely erase an external disk using dd on OSX

Securely erase an external disk using dd on OSX

  1. Plug in your SD card, HDD, or other block device and then use the following command to see which /dev/diskN node it's located on:
diskutil list
  1. Unmount the disk where “N� is the number of the disk taken from the above command:
@peiris
peiris / cryptor.php
Created September 13, 2018 19:35 — forked from petermuller71/cryptor.php
cryptor : PHP Encryption and decryption based on libsodium (standard lib >php7.2)
<?php
print "<h1>PHP Encryption with libsodium</h1>";
$message = "This text is secret";
$ciphertext = cryptor::encrypt("password", $message);
$plaintext = cryptor::decrypt("password", $ciphertext);
print "Message:<br />$message <br /><br />Ciphertext:<br />$ciphertext<br /><br />Plaintext:<br />$plaintext";
@peiris
peiris / openssl_encrypt_decrypt.php
Created September 13, 2018 19:32 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@peiris
peiris / php-best-pratices.md
Created September 13, 2018 19:19
PHP Best Practices

PHP Best Practices

Principles and rules

All code must follow:

  • Clean Code by Uncle Bob.
  • DRY, KISS and SOLID.
  • Continuous refactor. If you edit a method clean it: Boy scout rule.
@peiris
peiris / AES-256 encryption and decryption in PHP and C#.md
Created September 13, 2018 19:18
AES-256 encryption and decryption in PHP and C#

AES-256 encryption and decryption in PHP and C#

Update: There is a more secure version available. Details

PHP

<?php

$plaintext = 'My secret message 1234';
@peiris
peiris / modal-layout.blade.php
Created August 22, 2018 13:32 — forked from webinfinita/modal-layout.blade.php
Bootstrap modal blade partial view for Laravel
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Titulo</h4>
</div>
<div class="modal-body">
Contenido
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="submit" class="btn btn-primary">Actualizar</button>