Search This Blog

Wednesday, September 20, 2017

AJAX File Uploads

Introduction

Ajax files uploads used to be complex and mostly done with Flash which was uneasy and had a lot of problems.

Implementation


Today, we will show to do an AJAX Files uploads with only JQuery


var myfile= document.getElementById("UploadBatchFile").files; 
var data = new FormData();
data.append('file', myfile[0]);
data.append('id',$("#UploadBatchID").val());

$.ajax({"url":"load.php", 
         data:data,
         type:"POST",dataType:"JSON",
         contentType: false,
         processData: false,
         cache: false,
         success:function(data) {
          //Write your success code
         }
  }); 


Things to note:


  1. Getting the file input by $("#...") won't work and you have to use
    document.getElementByID 
  2. files is an array so it can work with multiple files as well.
  3.          contentType: false,
             processData: false,
             cache: false
    Must be added for it to work with $.ajax.







Thursday, April 12, 2012

Ubuntu 11.10 and Sony Vaio SB

After more than 2 weeks of Internet searching, I can now say that the performance of my new Sony Vaio is acceptable with Ubuntu. I'm writing this blog to save time spread to inforamtion.

SYMPTOMS:


1. Low CPU Cycles even though the Processor is i5 2.4GHz with Turbo boost 3.0GHz
2. High Temperature (70 C) even though of light computations (firefox and banshee).
3. Scroll is not working in Ubuntu


Regarding the cycles:


Diagnosis:
     i5 has a stepping technology to control the power consumption with the utilization, the default frequency is 800 MHz. the problem that the default power plan (ondemand) increases the frequency at 95% utilization which quite late.

Solution:

install the following packages

   sudo apt-get install cpufrequtils    

this will allow you to know/set the current CPU cycles for each core

to know the frequency write

    cpufreq-info     

You can do two things:

  • Change the plan from ondemand to performace, but this will increase the temperature and drain power faster.
    •    sudo cpufreq-set -g performance -r        
  • Decrease the threshold for stepping the frequency to 50% CPU utilization
    • # echo -n 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
      • to set this everytime Ubuntu starts add 'sleep 10;the above line' to /etc/rc.local before exit 0

Regarding the temperature:

Diagnosis:

The temperature of the laptop is always round 70 even with every low work load (firefox) and the fans are always work with a loud noise.
The laptop comes with 2 VGA cards (integrated Intel and an ATI Card).Windows is able to manage when to use each so using a word processor or writing this blog, it uses Intel. In 3D Games, it starts the ATI. Ubuntu is not as smart as Windows.

for best low heat production use: ATI propriety driver. In version 12 the driver is able to control the Intel card
  • Download the latest driver from AMD site.
  • Install it using the following command
    • sudo ./amd-driver-installer-12-3-x86.x86_64.run
    • For detailed instructions, visit this page http://cisight.com/install-amd-radeon-hd-6470m-and-solve-overheat-on-ubuntu-1110-oneiric/
      • The most important steps are:
        • sudo /usr/lib/fglrx/switchlibGL amd
        • sudo aticonfig --initial -f --adapter=all 
        • remove the 'Device' section from /etc/X11/xorg.conf
        • to use integrated card:
          • aticonfig --px-igpu
        • to use dedicated card (ATi):
          • aticonfig --px-dgpu
        • edit /etc/modprobe.d/blacklist.conf
          • add 'blacklist radeon' to stop open source driver
        • sudo /etc/init.d/lightdm restart
Regarding scroll:

follow the instruction is this blog.

Wednesday, July 20, 2011

AWS SES HTML Messages

This post will try to show you make Amazon Simple Email Service (SES) [http://aws.amazon.com/developertools/Amazon-SES/8945574369528337] to send HTML Mail rather than text mails.

This post consider that you are already able to send text mails using that tool. if not check Amazon SES tutorial online and README in the tool's zip.

To allow HTML Messaging:


Change Line 121 in ses-send-mail.pl

from
$params{'Message.Body.Text.Data'}                          = $opts{'m'};
To:
$params{'Message.Body.Html.Data'}                          = $opts{'m'};

Hope This helps