Skip to content

Instantly share code, notes, and snippets.

View NahianAhmed's full-sized avatar
:octocat:
❤️ 👨‍💻 ☕

Nahian NahianAhmed

:octocat:
❤️ 👨‍💻 ☕
View GitHub Profile
@NahianAhmed
NahianAhmed / samba setup in linux.md
Created October 17, 2023 15:41
Setup samba in Linux

Step 1: Install Samba sudo apt update sudo apt install samba -y

Step 4: Set Up a User Account To create a user account, set a username and password with: sudo smbpasswd -a username

Ref: https://phoenixnap.com/kb/ubuntu-samba

@NahianAhmed
NahianAhmed / Oh my ZSH with zsh-autosuggestions.md
Created October 17, 2023 15:26
Setup auto suggestions in terminal with oh my zsh

Oh my zsh.

Oh My Zsh

Install CURL.

sudo apt install curl

Install Oh my ZSH.

@NahianAhmed
NahianAhmed / dockerDocx
Last active October 15, 2022 20:31
Some Docker command
// run maria db or mySql image and create a DB
docker run -p 3307:3306 --name container-name -e MARIADB_ROOT_PASSWORD=root -e MARIADB_DATABASE=rookiedev image-name/ID
// Build docker file
docker build -t my-app .
// for docker compose
** docker-compose up -d --build
docker-compose up
// docker network
@NahianAhmed
NahianAhmed / firstDayOfWeek.java
Created August 3, 2022 04:27
1st day of week in java LocalDateTime
DayOfWeek dayOfWeek = WeekFields.of(Locale.getDefault()).getFirstDayOfWeek();
LocalDateTime firstDayOfWeek = LocalDate.now().atTime(0, 0, 0).with(TemporalAdjusters.previousOrSame(dayOfWeek))
.with(LocalTime.MIN);
@NahianAhmed
NahianAhmed / cronJob.java
Last active August 3, 2022 04:21
Cron Job
0 0/5 * * * ? -> 5 min every hour
0 */5 * * * ? ->every 5 min
0 * * * * ? -> every min
0 0 * * * ? - > every hour
@NahianAhmed
NahianAhmed / removeNewLine.java
Created August 3, 2022 03:36
Remove Carriage return, Tab , new line in Java
public static String replaceTabAndNewLine(String text, String replacement) {
return StringUtils.isNotBlank(text) ? text.replaceAll("[\\r\\t\\n]", replacement) : StringUtils.EMPTY;
}
@NahianAhmed
NahianAhmed / Java conventions.md
Created August 2, 2022 06:54 — forked from dferrandizmont/Java conventions.md
[Java conventions] #java

Coding Conventions

This file will cover important coding practices that are important to stress when coding this program. Listed below are some of the more important details that should be stressed. Each programmer has his/her own way to deliver code. The importance of having similar coding conventions throughout this program are listed below.

  • 80% of the time spent on a piece of software goes to maintenance.
  • Hardly any software is maintained for its whole life by the original author.
  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
  • If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create.
@NahianAhmed
NahianAhmed / TSVExporter.java
Last active July 21, 2022 04:23
Export CSV or TSV files as Zip using Java
@Log4j2
@Component
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TagDataExporter {
@Nonnull private final DataExportImportSupport dataExportImportSupport;
@Nonnull private final AccountFileSupport accountFileSupport;
@Nonnull private final IdeaService ideaService;
private static final String TSV_DELIMITER = "\t";
private static final String FILE_NAME_INFIX = "tags";
@NahianAhmed
NahianAhmed / GetData.java
Last active July 21, 2022 04:08
send and get JSON data using Rest Template api call
@PostMapping(value = MY_URL, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponse(code = 200, message = "OK")
public void getData(@RequestBody String data) {
String val = data;
}
@NahianAhmed
NahianAhmed / SendZippedFile.java
Last active July 21, 2022 04:08
Upload/Send File from Microservice one to other Using Rest Template Java
public void sendCommunityData(File zippedFile) {
try {
HttpHeaders headers = New HttpHeaders();
String url = "You url";
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> requestBody = new LinkedMultiValueMap<>();
requestBody.add("file", new FileSystemResource(zippedFile.getAbsolutePath()));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(requestBody, headers);
restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);