MVP Tweets of the Week – April 26, 2015

This is a collection of some Tweets by our MVPs over the last week. They are from all around the world and in various languages.

This first one was technically from the week before, but I was on the other side of the international dateline then so it all gets wibbly wobbly timey wimey.

HOSOKAWA Jun @pik retweeeted:


Translation: Blog update: [C++ Builder, Delphi XE8/C Builder XE8-compliant components and tools

Almost as if Cary is answering Nick here:

Anders Ohlsson @suited_aces retweeted:

Andrea Magni @AndreaMagni82 retweeted:

Also retweeted by Anders Ohlsson and discussed by others. An addage that has been around a while, but still relevant:

Ricardo Boaro rewteeted:

Welcome to the Internet of Things Nick. My Beacon’s emailed me too!

That is just some of the Tweets from our MVPs. You should really follow them to keep up to date. You can view their latest Tweets here:


Not all of our MVPs are active on Twitter, check out the MVP directory for details on each of them. In the future I’ll highlight updates from different sources.

Posted in MVP | Leave a comment

CORS on DataSnap REST Server

Cross-origin resource sharing (CORS) is a mechanism that enables resources to be shared across domains. Typically this isn’t allowed to prevent security issues. To enable on your DataSnap REST server you can use the following code per MVP Nirav Kaku from India.

All you need to do is add a custom header in the Response before dispatching the result on the DataSnap server…

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  //allows cross domain calls
  Response.SetCustomHeader('Access-Control-Allow-Origin','*');
  if FServerFunctionInvokerAction <> nil then
    FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker;
end;

It is useful for DataSnap server developers who want
their REST calls to be supported via AJAX using JavaScript from a
different server.

[Reference]

Note: CORS is security feature of the browser so there could be some
dependency there. Tested with Firefox, Chrome and IE and it seems to
be working fine.

Posted in News, REST, Source Code | 2 Comments

An Interview with Ray Konopka

Ray KonopkaIn this episode we talked to Ray Konopka during Delphi Week. Topics include the upcoming Delphi Developer Days, some of his work for DisneyRaize Software, including his new Radiant Shapes, Windows 10 and HoloLense (even though I wish they would rename it).

Looking forward to seeing everyone at Delphi Developer Days in Chicago, but if you can’t meet me there, they have some other locations too.

[Download]

Posted in Audio podCast, podcast | Leave a comment

FireDAC: Local SQL

Here are the additional resources for the FireDAC: Local SQL Skill Sprint from this morning. The TFDLocalSQL provides a powerful engine allowing you to run local SQL queries against any TDataSet descendant.

Here is the video replay. It is about half Q&A and half presentation.

If you want to download my sample application: LocalSQL-demo

Slides:

The demo and full replay are coming soon.

DocWiki

Videos

 

 

Posted in Source Code, webinar | Leave a comment

FireDAC In-Memory DataSet: TFDMemTable

More information and resources on TFDMemTable from the FireDAC Skill Sprint.

If you missed the Skill Sprint, or want to review it, here is the video with the recording of the Q&A. The presentation is 15-20 minutes, and the other 30 minutes is from the Q&A.

Here are the slides for now, the replay will be available soon.

Common code samples:

Delphi / Object Pascal

// Create Field Definitions
FDMemTable1.FieldDefs.Add('ID', ftInteger, 0, False);
FDMemTable1.FieldDefs.Add('Name', ftString, 20, False);
FDMemTable1.CreateDataSet;

// Append data
FDMemTable1.Open;
FDMemTable1.AppendRecord([1, 'Jim']);

// Load from another DataSet
FDMemTable1.CopyDataSet(DataSet1, [coStructure, coRestart, coAppend]);

C++

// Create Field Definitions
FDMemTable1->FieldDefs->Add("ID", ftInteger, 0, False);
FDMemTable1->FieldDefs->Add("Name", ftString, 20, False);
FDMemTable1->CreateDataSet();

// Append Data
FDMemTable1->Open();
FDMemTable1->Append();
FDMemTable1->FieldByName("ID")->AsInteger = 1;
FDMemTable1->FieldByName("Name")->AsString = "Jim";
FDMemTable1->Post();

// Load from another DataSet
FDMemTable1->CopyDataSet(DataSet1, TFDCopyDataSetOptions() << coStructure << coRestart << coAppend);

More information:

  • Samples
    • C:\Users\Public\Documents\Embarcadero\Studio\15.0\Samples\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDMemTable
    • C:\Users\Public\Documents\Embarcadero\Studio\15.0\Samples\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDLocalSQL
  • DocWiki

Cary Jensen’s CodeRage 9 Video: TFDMemTable & ClientDataSet Compared [Q&A Log]

Dmitry Arefiev’s CodeRage 9 FireDAC Tips, Tricks and News

Posted in Source Code, webinar | 1 Comment

Brian Alexakis and Virtual Reality

IBrian Alexakisn this episode I talk with Brian Alexakis about his role and what exactly it means to be a Knowledge Marketer. We also talk about the similarities between FireMonkey and some web development tools, and discuss virtual reality and what it holds in store for our near future. You can follow Brian Alexakis and his tutorials and C++ examples on blog.appmethod.com or on Twitter as @IoTBrian.

Here are some links that Brian mentioned during the podcast:

A few items of recent news:

Buy XE7 and get the Next Major Release Free!

 

[Download]

Posted in Audio podCast, podcast | 2 Comments

Code Monkey in Delphi Code

In this special musical number I’ve created a music video based on Jonathan Coulton’s Code Monkey written in Delphi’s Object Pascal.

[Download the code] [Download the video (mp4)]

Posted in Android, Funny, iOS, Source Code, Video podCast | 3 Comments

Deep Dive into Futures and the Parallel Programming Library

To follow-up with my Parallel For Loops skill sprint last week (lots of good resources there), today I did a deep dive into the Parallel Programming Library (PPL) including Futures, Tasks and custom thread pools.

Here are the slides:

And you can download my Tasks and Futures sample to see how to create, start, check and cancel both Tasks and Futures. Check out the C++ Parallel Examples to see how to use Futures and the PPL in C++.

Until the replay of my Skill Sprint is posted, you can watch this video from Allen Bauer covering the Parallel Programming Library Architecture from CodeRage 9.

Be sure to sign up for and check out the other Skill Sprints.

Posted in Source Code | Leave a comment

Factorials, Combinations & Permutaions

This is some code I wrote a long time ago as part of the TDAG mailing list. It calculates Factorials, the number of Combinations and Permutations. This is the mathematics, it calculates the number of Combinations and Permutations, it doesn’t create each different Combination and Permutation.

They take Cardinals as parameters because it doesn’t make sense to accept negative numbers. Keep in mind that factorials get big really, really quickly, so if you use too large of numbers then it will overflow even the Int64.

unit FactCombPerm;

interface

// Parameters are Cardinal because Int64 isn't Ordinal
//  Besides, Factorial(100) will overflow Int64 already.
function Factorial(const ANumber: Cardinal): Int64; overload;
function Factorial(const ANumber: Cardinal;
                   const AStop: Cardinal): Int64; overload;
function CombinationUnOpt(const ACount, AChoose: Cardinal): Int64;
function Combination(const ACount, AChoose: Cardinal): Int64;
function Permutation(const ACount, AChoose: Cardinal): Int64;

implementation

function Factorial(const ANumber: Cardinal): Int64; overload;
// n! = n * (n-1) . . . n(2)
var
  lCtr: Cardinal;
begin
  Result := 1;
  for lCtr := ANumber downto 2 do
    Result := Result * lCtr;
end;

function Factorial(const ANumber: Cardinal;
                   const AStop: Cardinal): Int64; overload;
// Factorial with a stop point (needed in the optimized Combination routine
// if no AStop is specified then is the same as Factorial
var
  lCtr: Cardinal;
begin
  Result := 1;
  if ANumber >= AStop then
    for lCtr := ANumber downto AStop do
      Result := Result * lCtr;
end;

function CombinationUnOpt(const ACount, AChoose: Cardinal): Int64;
// n!
// n_C_k = ----------
// k!(n - k)!
begin
  if AChoose < ACount then
    Result := Factorial(ACount)
      div (Factorial(AChoose) * Factorial(ACount - AChoose))
  else
    Result := 0;
end;

function Combination(const ACount, AChoose: Cardinal): Int64;
// n!
// n_C_k = ----------
// k!(n - k)!
// with optimizations even!
begin
  if AChoose < ACount then
    Result := Factorial(ACount, succ(ACount - AChoose))
      div (Factorial(AChoose))
  else
    Result := 0;
end;

function Permutation(const ACount, AChoose: Cardinal): Int64;
// n!
// n_P_k = --------
// (n - k)!
begin
  if AChoose < ACount then
    Result := Factorial(ACount)
      div Factorial(ACount - AChoose)
  else
    Result := 0;
end;

end.

My original optimization had a bug in it, but Bryan Mayland fixed it for me. This is old code, and there are probably some options to optimize it better. I’d love input, suggestions, etc.

Posted in Source Code | 2 Comments

DelphiWeek and CodeBattles

I hope you are all as excited about DelphiWeek as we are. On Wednesday we have CodeBattles scheduled. These are a fun way to show off your programming skills. We all use a Google, DocWiki and Stack Overflow during programming. The coding challenge isn’t a trivia competition, but an opportunity for you to show off your problem solving skills and use some of the latest features in XE7.

It will take place Wednesday 11-Feb-2015 from 8 AM to 10 AM PST. All coding will be done online during this time window via GoToWebinar.

The scoring is a combination of points based on features implemented and public voting. David I. is planning to make plaques to send the winner. I think it would be great to hang a plaque in the office with the winner’s names too.

If you want to take part in the CodeBattle, complete this short survey with your information. We are considering working with both teams and individuals, if we get enough sign ups for both. So far we already have a few individuals. It is open to all Delphi developers everywhere. Even if you are not comfortable with English, we can chat via Google Translate.

Interested? Sign-up today!

Posted in News | 3 Comments