React

React JSX and Helmet

tarihinde yayınlandı

Wearing a helmet saves you from coming harm!

Well, not always! (d’oh)

But, using Helmet(npm plugin) in a React JSX application saves time 🙂

It’s usage is pretty simple;  install the plugin, import the library and implement the structure.

First things first, we start with installing  the helmet plugin:

Import the library:

Note that we’ve also imported “react”. Any React plugin needs its core library defined first. So;  if you haven’t already, don’t forget to add it.

Next thing is its usage form. Let’s add these html code to our Helmet:

Helmet form:

which will give the same output once it runs via web browser:

That’s it folks!

Talked to many people about the JSX in React. Some people like to mix HTML with React code and some don’t. Honestly, I find this form pretty and easy to understand (even for front-end developers)

 

But, this is a matter for another blog post.

Thanks for reading

 

 

 

React

React JSX and Comments

tarihinde yayınlandı

HTML-guys hate it when their comment code do not work in JSX.

 

It’s because JSX tries to render anything within HTML thinking as all the code is a part of DOM.

You can’t use HTML comments but you can use Javascript comments under one condition -and it’s using with {curly braces} while mixing html-

Here’s an example (FAIL)

and Here’s an example (SUCCESS)

Note that; This piece of code uses 2 variants of commenting: one of them uses with curly braces and other one doesn’t.


So whats the difference?

In JSX; before writing some html code in a render function, you can use:

But, once the HTML is implemented you need to put the “React-specific code” under {curly braces} to tell parser that it’s not part of the DOM but part of React code.

I know it is annoying but why would you care about commenting system in any platform, framework or library instead of other functionalities

 

AI

AI HowTo Series #2 : Programming Emotions

tarihinde yayınlandı

Previously,we kickstarted our new article series “AI HowTo” and talked about how to register for Emotion API Preview(Project Oxford) through Azure Portal.

Now, I’d suggest we should start coding and learning the ways of emotions via codes

 

PROGRAMMING EMOTIONS

Before we start,make sure you get your “key” ready.If you havent already, read previous article to learn how it is done.

 

Emotion Analyzing in Images

This project requires an image to be processed at startup,makes some calculations on which emotion is stronger and then according to that calculation it posts the emotion on the screen.Let’s start with step by step

 

1-) Create a new Visual Studio project. Preferably Console Application.Install NewtonSoft JSON Parser from NUGET command line.

2-) Create a method to calculate the maximum number on a dictionary/collection:

 

3-) Create a method to convert image to byte array.It’s needed while posting image as byte to Emotion REST API

 

4-) Make a REST POST request to the emotion service url and parse json to display values from it

 

5-) Call main method

 

6-) Run

 

 
 
 
 

  
That’s All!

Well done in Kick-Starting Azure Cognitive Services Emotion API

Remember that, Emotion API(Project Oxford) is still in “Preview Stage” , so not all your images are meant to work (Tried like 10 happiness emotion images and only 1 got processed)

FINAL THOUGHTS

Emotion Analysis is essential for all industries.We live in a world where emotions are changed instantly so if we analyze and take precautions before bad things happen, we can avoid dramas or even deaths.

There used to be emotion reading in police departments.These men/women could easily read one’s emotions in an interrogation.I don’t know if police stations upgraded to use AI but Artificial Intelligence can also help to avoid crime.

 

 

Emotion-reading AI spots if potential criminals are stressed or nervous and alerts police BEFORE they act

Read it from here: http://www.dailymail.co.uk/sciencetech/article-4494994/New-technology-reads-emotions-potential-terrorists.html

 

 

Analyzing Emotions must be a top priority for all companies and governmental organizations.

For governments; to secure public life and avoid terrorist,anarchist attacks.
For companies; to increase happiness among employees and solving their problems before it gets bigger.

Companies nowadays trying to convince employees not to leave by increasing their wage,giving car or improving working style but companies most of the time missing the point where problems occur.Emotion Analysis will also help managers to discover if employees are happy within the company or not.

So my advice to the companies/governments is;
You should absolutely plan for Emotional Test daily/weekly/monthly without others realizing it.

Future is AI, use it!

 

AI

AI HowTo Series #1 : Registering for Emotion API

tarihinde yayınlandı

1-) Access your Azure account via “portal.azure.com”

2-) Search for term “Cog..” The list will show you the shortcut to Cognitive Services

 

 

 

 

 

 

 

 

 

 

 

3-)  Click Add and fill the search box with term “Emotion…” . Auto-completion box will find what we’re looking for: “Emotion API (preview)”

 

 

 

 

 

 

 

 

4-) Click and create a resource in WestUS servers (by the time I wrote this article, only WestUS is supported,im pretty sure other servers will start supporting it as well as soon as beta preview phase gone)

5-) Access your Emotion API blade(Pages/Windows in Azure Portal),

 

 

 

 

 

 

 

 

 

 

 

 

 

create your keys by clicking at keys at 1st step named “Grab your keys”

and start using Emotion API from Cognitive Services in Azure Platform

 

 

Next article will be about developing your very 1st Emotion Application.

Office 365

Solution of Problem “403 (Forbidden) with SP.RequestExecutor.js”

tarihinde yayınlandı

Well, Every day I learn something.

Today,when I was deploying some apps to Office 365,I’ve come across a situation interesting and wanted to dig in.

I was developing an app that uses a list to retrieve specific items and it was working perfect in my On-Premise environment.

When I deployed the same app to Office 365 Developer Site,I have received this error in my Chrome’s Developer Tools threw error something similar to “403 (Forbidden)” linking “SP.RequestExecutor.js” file.

Well that ruined me for a sec,I didnt expect it at all.

Then after some research I’ve found that: “Tenant” needs to be added as “Read” permission in “ApplicationManifest.xml” configuration.

Capture16

And the other problem for me was using Chrome Browser.When you deploy app to Office 365,you should always use “Internet Explorer” as default browser because by default it lets you to select “Trust-Don’t Trust” option which is needed to run the app which Chrome doesn’t.

Thats all.If you have come across the same situation,this is the trick.

SharePoint 2010

Export-SPWeb script to get backup all lists and libraries

tarihinde yayınlandı

Wrote this Powershell script according to my company’s needs,but you can fork and use it if you like

Export-SPWeb Script to get backup of all lists/libraries in a site collection.

But I’ll also share it here:

[code language=”powershell”]
Add-PSSnapin Microsoft.Sharepoint.Powershell

$site = Get-SPSite
$path = "C:\Backup2015\ListBackups"
$serverurlpath =""
$listurlpath=""
$listurlwithoutformat=""
$dosyapath =""
$itemURLNEW=""

foreach($web in $site.AllWebs){
$serverurlpath=$web.Url
$serverlistsurlpath=$web.ServerRelativeUrl -replace "/","\"
$serverurlport = ([System.Uri]$serverurlpath).Port
$serverurlhost = ([System.Uri]$serverurlpath).Host.Split(‘.-‘) -join "_"

if($serverurlport -eq "80")
{
if(!(Test-Path -Path ($path + "\" + $serverurlport)))
{
New-Item -Path ($path + "\" + $serverurlport) -Type Directory
}

if(!(Test-Path -Path (($path + "\" + $serverurlport + "\" + $serverurlhost))))
{
New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost) -Type Directory
}

foreach($list in $web.lists)
{

If (!(Test-Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath))) {
New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath) -Type Directory
}

$itemURLNEW= "$($list.RootFolder.ServerRelativeUrl)"
if($serverlistsurlpath -eq "\")
{
$dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)$($list -replace "/","\").cmp"
}

else
{
$dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)\$($list-replace "/","\").cmp"
}

if(!(Test-Path ($dosyapath)) -and $list.Hidden -eq $false)
{
export-spweb $web.URL -ItemUrl $itemURLNEW -IncludeUserSecurity -IncludeVersions All -path "$dosyapath" -nologfile
}
}
}

if($serverurlport -eq "1111")
{
if(!(Test-Path -Path ($path + "\" + $serverurlport)))
{
New-Item -Path ($path + "\" + $serverurlport) -Type Directory
}

if(!(Test-Path -Path (($path + "\" + $serverurlport + "\" + $serverurlhost))))
{
New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost) -Type Directory
}

foreach($list in $web.lists)
{

If (!(Test-Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath))) {
New-Item -Path ($path + "\" + $serverurlport + "\" + $serverurlhost + $serverlistsurlpath) -Type Directory
}

$itemURLNEW= "$($list.RootFolder.ServerRelativeUrl)"

if($serverlistsurlpath -eq "\")
{
$dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)$($list -replace "/","\").cmp"
}

else
{
$dosyapath = "$path\$($serverurlport)\$($serverurlhost)$($serverlistsurlpath)\$($list -replace "/","\").cmp"
}

if(!(Test-Path ($dosyapath)) -and $list.Hidden -eq $false)
{
export-spweb $web.URL -ItemUrl $itemURLNEW -IncludeUserSecurity -IncludeVersions All -path "$dosyapath" -nologfile
}
}
}
}
[/code]

Uncategorized

Multiline in LinkLabel Control

tarihinde yayınlandı

LinkLabel control doesn’t have a property named “Multiline” perhaps but there’s a similar behaviour that does the job: “MaximumSize”

You just need to assign a number of characters allowed in a line:

linklabel

Set it to a number and it will show as Multiline.