Monday, June 20, 2016

Transparent background with GIMP

One of the simplest way to transfer a solid filled background into transparent background. First thing first, download GIMP.

This is the source file, and I want to turn the white background into transparent.


Quickly go to Colors > Color to Alpha


Here is where is the magic happens 


voilĂ  !!




Saturday, January 23, 2016

How to fix 100% disk usage in Windows 10


How to fix 100% disk usage in Windows 10
This is caused by a common combination of Skype as well Google Chrome. Similar issue with other programs could also cause 100% disk usage. To fix this do the following:
Google Chrome:
In Google Chrome, go to Settings > Show Advanced Settings ... > Privacy > Prefetch resources to load pages more quickly

Skype:
Make sure you have exited Skype and it is not running in the taskbar (if it is running in the taskbar then quit it).
Open Windows Explorer and open the following folder:
"C:\Program Files (x86)\Skype\Phone\"
Now right click "Skype.exe" file and then click "Properties" and open the "Security" tab.
Click the "Edit" button and then highlight "ALL APPLICATION PACKAGES" and place a tick in the "Write" box.


Thursday, August 6, 2015

Get next number sequence in Axapta

//Axapta Job Code Snippet

static void GetNextNumber(Args _args)
{

NumberSeq                   numberSeq;
MyTempTable tempTable ;

;

ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode("ItemId");

tempTable.clear();
tempTable.ItemId = numberSeq.num();
tempTable.insert();

ttscommit;

}

Wednesday, June 17, 2015

Sending email with Google AppEngine





import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

void email()
{
        Properties props = new Properties();
        Session session = Session.getDefaultInstance(props, null);
     
        String msgBody = name + "\n" + description + "\n" + email;

        try {
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress("sender@email.com",
                    "sender"));
            msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
                    "recipientEmail", "recipientName"));
            msg.setSubject("Greetings");
            msg.setText("Hello");
            Transport.send(msg);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }

}

Updating entity in Datastore

//https://cloud.google.com/appengine/docs/java/datastore/transactions

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Transaction;
import com.google.appengine.api.datastore.TransactionOptions;

void myTxn() {
 DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
 TransactionOptions options = TransactionOptions.Builder.withXG(true);
 Transaction txn = datastore.beginTransaction(options);

 Entity a = new Entity("EntityName");
 a.setProperty("Property", "Value");
 datastore.put(txn, a);

 txn.commit();
}

Monday, May 18, 2015

Populating an excel worksheet with a ADO recordset


Private Sub ImportTable(ByVal Rs As ADODB.Recordset, ByVal worksheetName As String, Optional ByVal appendMode As Boolean = False, Optional ByVal PrintFieldHeader As Boolean = True)

 
        'Date: 9 April, 2009
        'Author: David Tsang
 
        Dim ws As Worksheet
        Dim rowStart As Double
     
        Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
 
        If worksheetName = "$" Then
     
            Exit Sub
     
        End If
     
 
        Set ws = Worksheets(worksheetName)
             
        If appendMode = False Then
         
            ws.Cells.ClearContents
            rowStart = 1
     
        Else
             
            rowStart = ws.UsedRange.Rows.Count + 1
     
        End If
       
     
        With ws
     
          If PrintFieldHeader = True Then
     
            For x = 1 To Rs.Fields.Count
         
                .Cells(rowStart, x).Value = "'" & Rs.Fields(x - 1).Name
 
            Next
         
            rowStart = rowStart + 1
       
          End If
           
          With .Cells(rowStart, 1)
             
                numberOfRows = .CopyFromRecordset(Rs)
       
          End With
       
          .Columns.AutoFit
       
        End With
             
        Do Until ws.UsedRange.Rows.Count >= Rs.RecordCount
            DoEvents
        Loop

     
        Application.Calculation = xlCalculationAutomatic
             
End Sub

Applying SMA10/20, SMA20/50 as trading signals

This is the comparison for results before and after applying SMA10/20 and SMA20/50 in the stock trader. Background Trading 3 stock ma...