TGViewer
Channel Public Channel
Programming & AI Tips ๐Ÿ’ก

Programming & AI Tips ๐Ÿ’ก

@programmingtip

Programming & AI:
Tips ๐Ÿ’ก
Articles ๐Ÿ“•
AI & LLMs ๐Ÿ‘พ
Design, Architecture, Principles โœ…

๐Ÿ‡ณ๐Ÿ‡ฑ Contact: @MoienTajik
Subscribers
46.3K
Photos
67
Videos
11
Links
376

Showing posts older than #201 ยท Back to latest

Older Posts 20 shown
Post #198 1.04K
Listing Content Of Directory In Java ๐Ÿ“

In order to list the contents of a directory, below program can be used. ๐Ÿ—„

This program simply receives the names of the all sub-directory and files in a folder in an Array and then that array is sequentially traversed to list all the contents. ๐Ÿ’Ž

import java.io.*;

public class ListContents {

public static void main(String[] args) {

File file =
new File("//home//user//Documents/");

String[] files = file.list();

System.out.println (
"Listing contents of " + file.getPath()
);

for(int i=0 ; i < files.length ; i++) {
System.out.println(files[i]);
}

}

}


โž–โž–โž–โž–โž–โž–โž–โž–โž–โž–โž–โž–
#java #io
@ProgrammingTip
Post #195 1.01K
Let in LINQ ๐Ÿ”ฎ

A let clause introduces a new range variable with a value that can be based on other range variables.

โŒ Sorting by the lengths of usernames without let clause :

var query = 
from user in SampleData.AllUsers
orderby user.Name.Length
select user.Name;

foreach (var name in query)
Console.WriteLine("{0}: {1}", name.Length, name);



โœ… Using a let clause to remove redundant calculations :

var query = 
from user in SampleData.AllUsers
let length = user.Name.Length
order by length
select new
{
Name= user.Name,
Length = length
};

foreach (var entry in query)
Console.WriteLine("{0}:{1}",entry.Length, entry.Name);


ใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐ
#LINQ #Query
@ProgrammingTip
Post #194 931
Try to group extension methods into static classes dealing with the same extended type. ๐Ÿ“ฆ

Sometimes related classes (such as DateTime and TimeSpan) can be sensibly grouped together. โ†”๏ธ

But avoid grouping extension methods targeting disparate types such as Stream and string within the same class. โŒ

ใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐ
#CleanCode #ExtensionMethods
@ProgrammingTip
Post #193 1.05K
Turn Things Off In HTML ๐Ÿ“ด

When making responsive sites, you donโ€™t really want users to be able to double tap and zoom, as all your content should be visible. ๐Ÿ–ฅ

To do this you will need to add some code that disables user zooming and scaling.

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />


This code will also enable iOS device to display sites more elegantly when the iPad or iPhone is rotated. ๐Ÿ“ฑ

โž–โž–โž–โž–โž–โž–โž–โž–โž–โž–

#html #responsive
@ProgrammingTip
Post #191 1.03K
JavaScript Clean Code ๐Ÿ› 

Use consistent capitalization ๐Ÿ’ก

Bad :
const DAYS_IN_WEEK = 7;
const daysInMonth = 30;

const songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
const Artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];

function eraseDatabase() {}
function restore_database() {}

class animal {}
class Alpaca {}


Good :
const DAYS_IN_WEEK = 7;
const DAYS_IN_MONTH = 30;

const SONGS = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
const ARTISTS = ['ACDC', 'Led Zeppelin', 'The Beatles'];

function eraseDatabase() {}
function restoreDatabase() {}

class Animal {}
class Alpaca {}


โž–โž–โž–โž–โž–โž–
#JSTips #CleanCode
@ProgrammingTip
Post #190 1.18K
๐Ÿ’š Retrofit Library ๐Ÿ’š

Retrofit turns your REST API into a Java Interface ๐Ÿ’Ž

Itโ€™s an elegant solution for organizing API Calls in a project. The request method and relative URL are added with an Annotation , which makes code clean and simple.

With annotations, you can easily add a request body, manipulate the URL or headers and add query parameters. ๐Ÿ”ฅ

Adding a return type to a method will make it synchronous, while adding a Callback will allow it to finish asynchronously with success or failure. ๐Ÿ”ฐ

For learn more about Retrofit see :
https://github.com/square/retrofit
http://square.github.io/retrofit/

#java #android #library
@ProgrammingTip
GitHub GitHub - lysine-dev/retrofit: A type-safe HTTP client for Android and the JVM A type-safe HTTP client for Android and the JVM. Contribute to lysine-dev/retrofit development by creating an account on GitHub.
Post #189 1.14K
๐Ÿ‘‰ Pointer Tips In C & C++ ๐Ÿ‘ˆ

๐Ÿ”ธNever ever forget to initialize the pointer. This may be simple and easy known stuff but here I would like to add it as an embedded system developer that this was the main cause of many bugs.

๐Ÿ”นAlso never change the pointer variable itself unless & until you need to change the pointer.

๐Ÿ”ธAlso monitor that the pointers are not overlapping if not pointing to same memory location range.

ใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐใ€ฐ

#c #cpp #pointer
@ProgrammingTip
Post #187 1.07K
Best Websites a Programmer Should Visit ๐Ÿฆ‹

Some useful websites for programmers. โœจ

When learning CS there are some useful sites you must know to get always informed in order to do your technologies eve and learn new things.

Here is a non exhaustive list of some sites you should visit :

[ https://goo.gl/BVQT1v ]

#FreeTime
@ProgrammingTip
GitHub GitHub - sdmg15/Best-websites-a-programmer-should-visit: :link: Some useful websites for programmers. :link: Some useful websites for programmers. Contribute to sdmg15/Best-websites-a-programmer-should-visit development by creating an account on GitHub.
Post #186 1.11K
Stackify Prefix โ˜˜๏ธ

Prefix is a lightweigth developer tool that shows you:

โ€ข Logs
โ€ข Errors
โ€ข Queries
...

in Real-time . ๐Ÿ’Ž

Languages Supported : C#, Java ๐Ÿ•ถ

https://stackify.com/prefix/

src : [ @IranAspMvc ]

#Tracking #Log
@ProgrammingTip
Stackify Prefix: The Developer's Tracing Solution and Code Profiling Tool Our code profiling and tracing solution, Prefix. Streamlines app development, and optimizes app performance. No more nightmare code reviews!
Post #184 1.15K
Refactoring โ€ขGURUโ€ข ๐Ÿฟ

Refactoring.Guru is a shiny website where you can find tons of information on refactoring, design patterns, SOLID principles and other smart programming topics. โœจ

https://refactoring.guru/

#CleanCode #Refactoring
@ProgrammingTip
refactoring.guru Refactoring and Design Patterns Refactoring is a controllable process of improving code without creating new functionality. Design Patterns are typical solutions to the commonly occurring problems in software design.
Post #183 929
Master Your API Workflow with Postman ๐Ÿ”ธ

Theyโ€™re doing a great job by providing an integrated environment for different components of an API, like authorization, testing, documentation, versioning. ๐Ÿ’Ž

https://www.sitepoint.com/master-api-workflow-postman/

#API #Postman
@ProgrammingTip
Sitepoint How to Master Your API Workflow with Postman โ€” SitePoint Younes present Postman - the API development tool of choice - in comprehensive detail. There's never been a better way to improve your API dev workflow!
Post #182 916
GPU.JS ๐Ÿ™

gpu.js will automatically compile specially written JavaScript functions into shader language and run them on the GPU using the WebGL API. โšก๏ธ

In case WebGL is not available, the functions will still run in regular JavaScript.

https://github.com/gpujs/gpu.js

#JavaScript #GPU
@ProgrammingTip
GitHub GitHub - gpujs/gpu.js: GPU Accelerated JavaScript GPU Accelerated JavaScript. Contribute to gpujs/gpu.js development by creating an account on GitHub.
Post #181 898
Material Design The Development Documentation

This site has a single list of available Material Components and samples of their usage for developer. ๐Ÿ’Ž

The v7 appcompat library is used in website - provide support of material design user interface implementations for older Android platforms. ๐Ÿ™†๐Ÿปโ€โ™‚๏ธ

Note: Design Library - provides various material design components which are not part of Android SDK.

http://www.materialdoc.com/

#java #android #material
@ProgrammingTip
Older posts โ†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’