Ethereum and Blockchain Programming with Solidity

Got a nice read of Ethereum and Blockchain today. Downloaded the Ethereum Wallet and Mist.
Still got a lot of things to read before I can start building applications for this Decentralized Application concept. Got a new Hobby now with blockchain and cryptocurrency. whewww!

Cheers to New Wave and Synthpop!

File Upload Get MIME Type using JavaScript

<html>
<body>

    <input type="file" id="upload-files" multiple>
    <script>
    var control = document.getElementById("upload-files");
    control.addEventListener("change", function(event) {      
        var files = control.files;
        for (var i = 0; i < files.length; i++) {
            console.log("Filename: " + files[i].name);
            console.log("Type: " + files[i].type);
            console.log("Size: " + files[i].size + " bytes");
        }
    }, false);
    </script>

</body>
</html>

Printing Directly from Asp.Net MVC Controller Action to Printer in the Network

public async Task<ActionResult> Generate(string id)
{
     PrintDocument pd = new PrintDocument();
     pd.DefaultPageSettings.Margins.Left = 30;
     pd.DefaultPageSettings.Margins.Top = 10;
     pd.DefaultPageSettings.Margins.Right = 10;
     pd.DefaultPageSettings.Margins.Bottom = 10;
     pd.OriginAtMargins = true;
     pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
     // Set the printer name.
     //pd.PrinterSettings.PrinterName = "\\NS5\hpoffice
     //pd.PrinterSettings.PrinterName = "HP LaserJet 200 color M251 PCL6 Class Driver";
     pd.PrinterSettings.PrinterName = "EPSON LX-310";
     pd.Print();

     return RedirectToAction("Index", "Payslip", new { area = "Accounting", id = "", code = 801 });
}

void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
     Font printFont = new Font("3 of 9 Barcode", 18);
     Font printFont1 = new Font("Times New Roman", 11, FontStyle.Bold);
     SolidBrush br = new SolidBrush(Color.Black);
     ev.Graphics.DrawString("hello", printFont, br, 10, 65);
     ev.Graphics.DrawString("world", printFont1, br, 10, 85);
}

LAMP DB Backup from Command Line Tips

  mysqldump --databases database_one database_two > two_databases.sql
 
  scp your_username@remotehost.edu:foobar.txt /local/dir
  scp -i key_file.pem your_username@remotehost.edu:/remote/dir/foobar.txt /local/dir

  some git tips
  git push https://[username]@github.com/repo.git origin [branchhere]
  git clone -b [branchhere] --single-branch https://github.com/repo.git

Adding Custom Hook on Contact Form 7

How to add Custom Hook on Contact Form 7

/*
    Prevent the email sending step for specific form
*/

add_action("wpcf7_before_send_mail", "wpcf7_do_something_else");  
function wpcf7_do_something_else($cf7) {
    // get the contact form object
    $wpcf = WPCF7_ContactForm::get_current();

    // if you wanna check the ID of the Form $wpcf->id  
    $submission = WPCF7_Submission::get_instance();

    $yourname   = $submission->get_posted_data('your-name');    
    $youremail  = $submission->get_posted_data('your-email');


    return $wpcf;
}

General Steps on setting up SSL in your Website

1. Buy SSL
2. Generate CSR
3. Copy Generated CSR to SSL location setup
4. download crt from ssl location
5. update install crt to hosting server
6. Install SSL

Once SSL in installed. Force make a 301 redirection to all links via .htaccess

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRUle ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Setting Virtual Host with XAMPP

<VirtualHost *:8080>
    DocumentRoot "C:\DIR"
    ServerName domain.localhost
    <Directory "C:\DIR">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
 php_flag display_errors on
    php_value error_reporting 6143
    php_flag log_errors on
    php_value error_log "C:\DIR"
</VirtualHost>

(e.g. for Xampp 1.7.7. )

<VirtualHost *:80>
 DocumentRoot C:/DIR
 ServerName domain.local

 <Directory "C:/DIR">
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
 </Directory>
</VirtualHost>