πΌ Rescale Image In Java πΌ
An image can rescaled using AffineTransform. First of all, Image Buffer of input image is created and then scaled image is rendered. βοΈ
#java #image
@ProgrammingTip
An image can rescaled using AffineTransform. First of all, Image Buffer of input image is created and then scaled image is rendered. βοΈ
BufferedImage imgSource =
ImageIO.read(new File("myImage.jpg"));
BufferedImage imgDest =
new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = imgDest.createGraphics();
AffineTransform affinetransformation =
AffineTransform.getScaleInstance(2, 2);
g2d.drawRenderedImage(imgSource,
affinetransformation);
ImageIO.write(imgDest, "JPG",
new File("outImage.jpg"));
#java #image
@ProgrammingTip
JavaScript Clean Code π
Functions should do one thing π‘
Bad :
Good :
ββββββ
#JSTips #CleanCode
@ProgrammingTip
Functions should do one thing π‘
Bad :
function emailClients(clients) {
clients.forEach((client) => {
const clientRecord = database.lookup(client);
if (clientRecord.isActive()) {
email(client);
}
});
}Good :
function emailActiveClients(clients) {
clients
.filter(isActiveClient)
.forEach(email);
}
function isActiveClient(client) {
const clientRecord = database.lookup(client);
return clientRecord.isActive();
}ββββββ
#JSTips #CleanCode
@ProgrammingTip
Media is too big
VIEW IN TELEGRAM
C# Events & Delegates βοΈ
Instructor : Mosh Hamedani π₯
#CSharp #Events #Delegates
@ProgrammingTip
Instructor : Mosh Hamedani π₯
#CSharp #Events #Delegates
@ProgrammingTip
π¦ Macro To Get Array Size Of Any Data Type In C π¦
The following macro will help you in getting the size of an array of any data type. It works by dividing the length of the array to the size of its field. π‘
Code:
Output:
#c #cpp #array
@ProgrammingTip
The following macro will help you in getting the size of an array of any data type. It works by dividing the length of the array to the size of its field. π‘
Code:
#define num(x) (sizeof (x) / sizeof (*x))
int _tmain() {
int numbers[10] =
{1,1,1,1,1,1};
char *chars[20] =
{"","","","","","","","",""};
printf("Size of numbers[10] is %d\n",
num(numbers));
printf("Size of chars[20] is %d\n",
num(chars));
}
Output:
Size of numbers[10] is 10
Size of chars[20] is 20
Press any key to continue . . .
#c #cpp #array
@ProgrammingTip
JavaScript Clean Code π
Don't use flags as function parameters π‘
Bad :
Good :
ββββββ
#JSTips #CleanCode
@ProgrammingTip
Don't use flags as function parameters π‘
Bad :
function createFile(name, temp) {
if (temp) {
fs.create(`./temp/${name}`);
} else {
fs.create(name);
}
}Good :
function createFile(name) {
fs.create(name);
}
function createTempFile(name) {
createFile(`./temp/${name}`);
}ββββββ
#JSTips #CleanCode
@ProgrammingTip
Axios πΎ
Promise based HTTP client for the browser and node.js .
Features :
πΈMake XMLHttpRequests from the browser
πΉMake http requests from node.js
πΈSupports the Promise API
πΉIntercept request and response
πΈTransform request and response data
πΉCancel requests
πΈAutomatic transforms for JSON data
πΉClient side support for protecting against XSRF
https://github.com/mzabriskie/axios
Use it instead of old AJAX, it's very simple & handy π₯
#JavaScript #Ajax
@ProgrammingTip
Promise based HTTP client for the browser and node.js .
Features :
πΈMake XMLHttpRequests from the browser
πΉMake http requests from node.js
πΈSupports the Promise API
πΉIntercept request and response
πΈTransform request and response data
πΉCancel requests
πΈAutomatic transforms for JSON data
πΉClient side support for protecting against XSRF
https://github.com/mzabriskie/axios
Use it instead of old AJAX, it's very simple & handy π₯
#JavaScript #Ajax
@ProgrammingTip
GitHub
GitHub - axios/axios: Promise based HTTP client for the browser and node.js
Promise based HTTP client for the browser and node.js - axios/axios
Online VS Code IDE for Angular & React & Ionic π
Features :
πΈIntellisense, Project Search, Go to Definitions.
πΉHot reloading as you type.
πΈImport NPM packages into your project.
πΉKeep editing while offline
πΈHosted app URL where you can see (or share) your live application at any time.
https://stackblitz.com/
Try it, it's awesome π
#Angular #React #Ionic
@ProgrammingTip
Features :
πΈIntellisense, Project Search, Go to Definitions.
πΉHot reloading as you type.
πΈImport NPM packages into your project.
πΉKeep editing while offline
πΈHosted app URL where you can see (or share) your live application at any time.
https://stackblitz.com/
Try it, it's awesome π
#Angular #React #Ionic
@ProgrammingTip
JavaScript Clean Code π
Avoid negative conditionals π‘
Bad :
Good :
ββββββ
#JSTips #CleanCode
@ProgrammingTip
Avoid negative conditionals π‘
Bad :
function isDOMNodeNotPresent(node) {
// ...
}
if (!isDOMNodeNotPresent(node)) {
// ...
}Good :
function isDOMNodePresent(node) {
// ...
}
if (isDOMNodePresent(node)) {
// ...
}ββββββ
#JSTips #CleanCode
@ProgrammingTip
Google Material GuideLines for Implementation UI π
The Material Design guidelines are a living document of visual, interactive, and motion guidance. π
https://material.io/guidelines/
#Android #Material
@ProgrammingTipβ
The Material Design guidelines are a living document of visual, interactive, and motion guidance. π
https://material.io/guidelines/
#Android #Material
@ProgrammingTipβ
Material Design
Build beautiful, usable products faster. Material Design is an adaptable systemβbacked by open-source codeβthat helps teams build high quality digital experiences.
Async & Await in JavaScript π₯
Async/Await will make your code simpler even more than you think. β
Stop writing callback functions and love JavaScript ES7. π
https://blog.patricktriest.com/what-is-async-await-why-should-you-care/
#JavaScript #CleanCode
@ProgrammingTip
Async/Await will make your code simpler even more than you think. β
Stop writing callback functions and love JavaScript ES7. π
https://blog.patricktriest.com/what-is-async-await-why-should-you-care/
#JavaScript #CleanCode
@ProgrammingTip
Break | Better
Async/Await Will Make Your Code Simpler
Or How I Learned to Stop Writing Callback Functions and Love Javascript ES8.
Announcing .NET Core 2.0 π₯
.NET Core 2.0 is available today as a final release. π¦
You can start developing with it at the command line, in your favorite text editor, in Visual Studio 2017 15.3, Visual Studio Code or Visual Studio for Mac.
It is ready for production workloads, on your own hardware or your favorite cloud, like Microsoft Azure.
Microsoft also released ASP.NET Core 2.0 and Entity Framework Core 2.0 π
https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-net-core-2-0/
Download SDK :
https://www.microsoft.com/net/download/core
γ°γ°γ°γ°γ°γ°
#DotNet #ASPNET #Core
@ProgrammingTip
.NET Core 2.0 is available today as a final release. π¦
You can start developing with it at the command line, in your favorite text editor, in Visual Studio 2017 15.3, Visual Studio Code or Visual Studio for Mac.
It is ready for production workloads, on your own hardware or your favorite cloud, like Microsoft Azure.
Microsoft also released ASP.NET Core 2.0 and Entity Framework Core 2.0 π
https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-net-core-2-0/
Download SDK :
https://www.microsoft.com/net/download/core
γ°γ°γ°γ°γ°γ°
#DotNet #ASPNET #Core
@ProgrammingTip
.NET Blog
Announcing .NET Core 2.0 | .NET Blog
.NET Core 2.0 is available today as a final release. You can start developing with it at the command line, in your favorite text editor, in Visual Studio 2017 15.3, Visual Studio Code or Visual Studio for Mac. It is ready for production workloads,
π¦ Grab The Stack Trace Of An Exception π¦
Checking your code for errors is one of the most Painstaking β and frustrating β parts of the development process. ππ»ββοΈ
Itβs also horrendously Time-Consuming, particularly if youβve a pesky error whose source isnβt immediately clear. π‘
Using this code, you can more easily track down where an Exception is occurring β and bring yourself that much closer to being rid of it. β
Code
#java #exception #error #trick
@ProgrammingTip
Checking your code for errors is one of the most Painstaking β and frustrating β parts of the development process. ππ»ββοΈ
Itβs also horrendously Time-Consuming, particularly if youβve a pesky error whose source isnβt immediately clear. π‘
Using this code, you can more easily track down where an Exception is occurring β and bring yourself that much closer to being rid of it. β
Code
Exception e = β¦;
java.io.StringWriter sw = new java.io.StringWriter();
e.printStackTrace(new java.io.PrintWriter(sw));
String trace = sw.getBuffer().toString();
#java #exception #error #trick
@ProgrammingTip
Use String.valueOf() instead of toString() π
If obj needs to be converted to string then the result of obj.toString() and String.valueOf(obj) will be same.
But String.valueOf() is Null Safe, means it will never throw NullPointerException. π―
γ°γ°γ°γ°γ°γ°
#java #string
@ProgrammingTip
If obj needs to be converted to string then the result of obj.toString() and String.valueOf(obj) will be same.
But String.valueOf() is Null Safe, means it will never throw NullPointerException. π―
Test test = null;
// Below statement will not throw NPE
System.out.println(String.valueOf(test));
// Next statement will throw NPE
System.out.println(test.toString())
γ°γ°γ°γ°γ°γ°
#java #string
@ProgrammingTip
JavaScript Clean Code π
Use getters and setters π‘
Bad :
Good :
ββββββ
#JSTips #CleanCode
@ProgrammingTip
Use getters and setters π‘
Bad :
function makeBankAccount() {
return {
balance: 0,
// ...
};
}
const account = makeBankAccount();
account.balance = 100;Good :
function makeBankAccount() {
let balance = 0;
function getBalance() {
return balance;
}
function setBalance(amount) {
balance = amount;
}
return {
getBalance,
setBalance,
};
}
const account = makeBankAccount();
account.setBalance(100);ββββββ
#JSTips #CleanCode
@ProgrammingTip
Value Types in the Real World π
Suppose youβre reading something fantastic, and you want a friend to read it too. π
What do you need to give your friend so that he can read it tooβ
To give your friend a copy, youβd need to photocopy all the pages and then give it to him, At that point, he has his own complete copy of the document. π
In this situation, youβre dealing with value type behaviorβοΈ
All the information is directly in your hands, you donβt need to go anywhere else to get it.
Your copy of the information is also independent of your friendβs after youβve made the copy. π₯
You could add some notes to your pages, and his pages wouldnβt be changed at all.π π»ββοΈ
γ°γ°γ°γ°γ°γ°
#Types #ValueTypes
@ProgrammingTip
Suppose youβre reading something fantastic, and you want a friend to read it too. π
What do you need to give your friend so that he can read it tooβ
To give your friend a copy, youβd need to photocopy all the pages and then give it to him, At that point, he has his own complete copy of the document. π
In this situation, youβre dealing with value type behaviorβοΈ
All the information is directly in your hands, you donβt need to go anywhere else to get it.
Your copy of the information is also independent of your friendβs after youβve made the copy. π₯
You could add some notes to your pages, and his pages wouldnβt be changed at all.π π»ββοΈ
γ°γ°γ°γ°γ°γ°
#Types #ValueTypes
@ProgrammingTip
Reference Types in the Real World π
Compare that with the situation where youβre reading a web page. π
This time, all you have to give your friend is the URL of the web page. βοΈ
This is reference type behavior, with the URL taking the place of the reference. βοΈ
In order to read the document, you have to navigate the reference by putting the URL in your browser and asking it to load the page. βπ»
If the web page changes for some reason, both you and your friend will see that change the next time each of you loads the page. ππ»
γ°γ°γ°γ°γ°γ°
#Types #ReferenceTypes
@ProgrammingTip
Compare that with the situation where youβre reading a web page. π
This time, all you have to give your friend is the URL of the web page. βοΈ
This is reference type behavior, with the URL taking the place of the reference. βοΈ
In order to read the document, you have to navigate the reference by putting the URL in your browser and asking it to load the page. βπ»
If the web page changes for some reason, both you and your friend will see that change the next time each of you loads the page. ππ»
γ°γ°γ°γ°γ°γ°
#Types #ReferenceTypes
@ProgrammingTip