Skip to content

Instantly share code, notes, and snippets.

View junlapong's full-sized avatar
🏚️
Work from home

Junlapong L. junlapong

🏚️
Work from home
  • Ratchaburi, Thailand
View GitHub Profile
@junlapong
junlapong / FileLocking.java
Created October 2, 2022 08:45 — forked from syazawa/FileLocking.java
Example of inter-process and inter-thread file locking in Java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileLock;
// The class demonstrates how to get an exclusive file lock that prevents other threads and processes / JVMs from
// obtaining a lock on the same file. To do this, you need to synchronize a block on a file and acquire FileLock. See
// comments below for more details. Run this class in multiple JVMs and see each thread of each JVM acquires a lock in
// an orderly fasion.
public class FileLocking extends Thread
@junlapong
junlapong / convert.sh
Created September 6, 2022 22:05 — forked from subwiz/convert.sh
Go HTTP client using pkcs12 certificate
#!/bin/sh
## First convert .p12 cert to certificate and key .pem files:
openssl pkcs12 -in cert.p12 \
-clcerts -nokeys -out usercert.pem
openssl pkcs12 -in cert.p12 \
-nocerts -out userkey.pem -nodes
@junlapong
junlapong / srcache.conf
Created May 2, 2022 08:18 — forked from narate/srcache.conf
The srcache-nginx-module example config for WordPress with php-fpm
server {
listen 80;
server_name _;
root /var/www/html;
index index.php;
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
@junlapong
junlapong / gitBash_windows.md
Created April 5, 2022 15:22 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

@junlapong
junlapong / HelloServlet.java
Created January 29, 2022 02:14 — forked from viralpatel/HelloServlet.java
HTML5 Server-Sent Events + Java Servlet example
package net.viralpatel.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@junlapong
junlapong / DefaultListener.java
Created January 28, 2022 10:32 — forked from chRyNaN/DefaultListener.java
Server-Sent Event Java Servlet backend
public interface DefaultListener {
public void onNotification(NotificationEvent event);
}
@junlapong
junlapong / fluent-filebeat-comparison.md
Created December 27, 2021 07:02 — forked from StevenACoffman/fluent-filebeat-comparison.md
Fluentd Fluent-bit FileBeat memory and cpu resources

Fluent-bit rocks

A short survey of log collection options and why you picked the wrong one. 😜

Who am I? Where am I from?

I'm Steve Coffman and I work at Ithaka. We do JStor (academic journals) and other stuff. How big is it?

Number what it means
101,332,633 unique visitors in 2017
@junlapong
junlapong / semantic-commit-messages.md
Created December 12, 2021 22:46 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@junlapong
junlapong / email_test.go
Created October 17, 2021 06:41 — forked from tmichel/email_test.go
Sending and testing email in Go -- appendix
package email
import (
"net/smtp"
"testing"
)
type EmailConfig struct {
Username string
Password string
@junlapong
junlapong / SimpleAppMQAgain.java
Created September 14, 2021 08:53 — forked from berlinbrown/SimpleAppMQAgain.java
Basic IBM MQ with threading
package pipeline.mockdump;
import com.ibm.mq.*;
import com.ibm.mq.constants.CMQC;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;