Author Archives: Ronnie Diaz

Evolution of Communication and Human Language

The content of this post is not yet enough to match the daunting title at this time, however, I wanted to express some thoughts I’ve had over the last few months regarding language.

I am of the opinion that human language, which has evolved and changed over time, is of course still changing, into a more strictly defined language almost in the fashion of a computer protocol.

The advent and increasing frequency of short message communications such as cellular or internet text messages, instant messaging applications and/or chatrooms, etc, has brought along shortened versions of words which we have now become very familiar with, such as “IMO”, “LOL”, “BRB”, etc. This in and of itself suggests a trend of evolving language. While this “Internet Slang” is far from proper English, I think this over time will open the door towards establishing standard words and phrases of communication, whether indirectly or directly, that will become known and used worldwide.

From an outside perspective in our current point in time, this may have the appearance of a “computer like” language, being spoken between one another. Ergo, Artificial Intelligence and Speech Recognition technology will meet in the middle with evolving human language.

I watched a film awhile back called Cosmopolis, an adaption of the novel, and while many viewers I spoke with found the use of language to be erring, I think the direction of the film and the novel emphasize that in a world of data, commonalities and natural grouping are inevitable and will affect our spoken language in ways that we may now have difficulty grasping.

MIT Professor Develops NSA-like Email Data Visualization Software

See for yourself:
https://immersion.media.mit.edu/

mssql aes function encrypt decrypt in microsoft sql

Simple symmetric encryption in MSSQL. Copied from MS references below:

USE AdventureWorks2012;
--If there is no master key, create one now. 
IF NOT EXISTS 
    (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
    CREATE MASTER KEY ENCRYPTION BY 
    PASSWORD = '23987hxJKL95QYV4369#ghf0%lekjg5k3fd117r$$#1946kcj$n44ncjhdlj'
GO

CREATE CERTIFICATE Sales09
   WITH SUBJECT = 'Customer Credit Card Numbers';
GO

CREATE SYMMETRIC KEY CreditCards_Key11
    WITH ALGORITHM = AES_256
    ENCRYPTION BY CERTIFICATE Sales09;
GO

-- Create a column in which to store the encrypted data.
ALTER TABLE Sales.CreditCard 
    ADD CardNumber_Encrypted varbinary(128); 
GO

-- Open the symmetric key with which to encrypt the data.
OPEN SYMMETRIC KEY CreditCards_Key11
   DECRYPTION BY CERTIFICATE Sales09;

-- Encrypt the value in column CardNumber using the
-- symmetric key CreditCards_Key11.
-- Save the result in column CardNumber_Encrypted.  
UPDATE Sales.CreditCard
SET CardNumber_Encrypted = EncryptByKey(Key_GUID('CreditCards_Key11')
    , CardNumber, 1, HashBytes('SHA1', CONVERT( varbinary
    , CreditCardID)));
GO

-- Verify the encryption.
-- First, open the symmetric key with which to decrypt the data.

OPEN SYMMETRIC KEY CreditCards_Key11
   DECRYPTION BY CERTIFICATE Sales09;
GO

-- Now list the original card number, the encrypted card number,
-- and the decrypted ciphertext. If the decryption worked,
-- the original number will match the decrypted number.

SELECT CardNumber, CardNumber_Encrypted 
    AS 'Encrypted card number', CONVERT(nvarchar,
    DecryptByKey(CardNumber_Encrypted, 1 , 
    HashBytes('SHA1', CONVERT(varbinary, CreditCardID))))
    AS 'Decrypted card number' FROM Sales.CreditCard;
GO

References:

http://msdn.microsoft.com/en-us/library/bb669072.aspx

http://msdn.microsoft.com/en-us/library/ms179331.aspx

asp .net repeater itemcommand command name common repeater control item operations

This is only one small snippet illustrating some functionality. I will add to this blog from my previous usage with Repeater control over time or per request.

In many deployments, I prefer to use Repeater or ListView rather than Grids. The code pattern is the same, but the output is slightly different as well as some of the inherent features/functionality.

Notice the example below simulates table output similar to a Grid, or it may also be used for non-table type of output. Repeater is therefore IMO more adaptable to different needs, and allows more re-usability code patterns across projects.

page side:

<asp:Repeater ID="rptRobotsInFactories" runat="server" OnItemCommand="rptRobotsInFactories_ItemCommand">
        <HeaderTemplate>
<table>
<tr>
<td>factory name</td>
<td>robot name</td>
<td>factory location</td>
<td>manufacture date</td>
<td colspan="2">commands</td>
</tr>
   </HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("factoryname")%>
<asp:TextBox ID="tbRobotName" runat="server" Text='<%# Eval("robotname")%>'></asp:TextBox>
</td>
<td>
<%# Eval("factorylocation")%>
</td>
<td>
<%# Eval("manufacturedate")%>
</td>
<td>
<asp:LinkButton ID="lbtnRename" runat="server"> CommandName="rename" CommandArgument='<%# Eval("robotname")%>'>rename</asp:LinkButton>
</td>
<td>
<asp:LinkButton ID="lbtnDeelte" runat="server"> CommandName="delete" CommandArgument="">delete</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
        </HeaderTemplate>
<FooterTemplate>
<!-- insert pager here if you like-->
        </table>
        </FooterTemplate>
		</asp:Repeater>

code behind:

//you can also intercept item databind as i've listed in another previous article on nested repeaters

 protected void rptRobotsInFactories_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "rename")
        {
            string newname = ((TextBox)rptRobotsInFactories.Items[e.Item.ItemIndex].FindControl("tbFileName")).Text;
            //string newname = ((TextBox)e.Item.FindControl("tbFileName")).Text; //equal to the above
            //string index = (string)e.CommandArgument; //useful to pass in index values also. can split the values passed in or pass in class obj
            //var rif = ((List<robotinfactory>)rptRobotsInFactories.DataSource)[e.Item.ItemIndex];
//var rif = Session_RobotsInFactories().Select(r=>r.id==Convert.ToInt32(e.CommandArgument)); //compare to using viewstate/page repeater above
            string oldname = (string)e.CommandArgument;
            if ((newname.ToLower().Trim().Replace(" ","") != "") && (newname!=oldname))
            {
//dowork_rename(oldname,newname);
            }
        }
else if (e.CommandName=="delete") {
            robotinfactory rif = ((List<robotinfactory>)rptRobotsInFactories.DataSource)[e.Item.ItemIndex];
//dowork_delete(rif.id);
}
    }

//added below funcs for clarity
public class robotinfactory() {
public string factoryname {get;set;}
public string robotname {get;set;}
public string factorylocation {get;set;}
public string manufacturedate {get;set;}
}

protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
//these would normally load from your LINQ dbml SP, view, select statement, stored procedure etc
var rifs = new List<robotinfactory>();

rifs.Add(new rif {
factoryname="a",
robotname="bob",
factorylocation="florida",
manufacturedate="7/1/2013"
});

rifs.Add(new rif {
factoryname="b",
robotname="sam",
factorylocation="not florida",
manufacturedate="7/4/2013"
});

rptRobotsInFactories.DataSource = rifs;
rptRobotsInFactories.DataBind();
}
}

directory info get files show directories C# .Net

There is sometimes a misunderstanding between a “file” and a “folder” in filesystems. In C# .Net the following is often used to list all “files” in a folder.

DirectoryInfo di = new DirectoryInfo("yourpath");

foreach (FileInfo fi in di.GetFiles()) {
//do work
}

However, even though you can specify to search containing subdirectories, the above function will not inherently list folders. If you are looking for the equivalent to “dir” or “ls”, instead use “GetFileSystemInfos()”.

            DirectoryInfo di = new DirectoryInfo("yourpath");
		
//note the difference here with getfilesysteminfos
		foreach (dynamic d in di.GetFileSystemInfos()) {
}

Note the usage of dynamic in the above example compared to the first example. This avoids any potential issues with inheritance and choosing the right class for your temp iterator variable for unboxing etc.

Race at the Pump – Electric vs Gas

Watch this quick video showcasing Tesla’s new tech that could give the gas giants a run for their money:
http://www.pcmag.com/article2/0,2817,2420802,00.asp

Wall Street Journal – CIA Chooses: Amazon or IBM

Showcases how large Amazon’s Cloud infrastructure has become.

http://online.wsj.com/article/SB10001424127887324904004578539722533829106.html

Google and NASA Team Up to Tackle AI, D-Wave quantum computing

Read the full article here: http://www.technologyreview.com/news/514846/google-and-nasa-launch-quantum-computing-ai-lab/

android debug vm virtual virtualbox images ova eclipse

As an alternative to the default android virtual machines that come with the Android SDK and/or Eclipse, try the images from the site below:

http://androvm.org/blog/

The format is ova, which is easily opened by virtualbox, and there only two simple things to keep in mind.

1) After adding into virtualbox, add a port forwarding rule to the first ethernet device. Even though this defaults to “not attached” I changed this to NAT and added rules for 5555, 8600 and 8601.

Make sure you do not turn off the second ethernet device as this virtual machine is configured to use both of these adapters.

From Eclipse you can change your settings (window->properties->android) to always prompt you to select a device. Run your virtual machine and go into settings and enable developer mode, then run your app in Eclipse and you should see the device in the top box of the devices window that appears.

If for any reason you can no longer see the device, go into the DDMS perspective and click on the restart adb button and you should now see it again.

That’s it! Fast, simple and better IMO than the out of the box config that comes with Eclipse for android development. Enjoy.

android app cannot connect to internet

To allow your custom app to connect to the internet, add the following in your AndroidManifest.xml file right before (outside) the application tag.

<uses-permission android:name="android.permission.INTERNET" />