แสดงบทความที่มีป้ายกำกับ IT แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ IT แสดงบทความทั้งหมด

01 สิงหาคม 2569

20 มิถุนายน 2569

Meet DevTools — Free Developer Utilities That Run Entirely in Your Browser

Every developer has a folder of bookmarks for the little things: a Base64 encoder here, a JWT decoder there, a JSON formatter somewhere else. The problem? Half of those random sites send whatever you paste straight to a server you've never heard of — including tokens, keys, and customer data.



We built DevTools to fix that. It's a single, fast, ad-supported web app at https://devtools.piggyman007.com that bundles the utilities you actually reach for every day — and runs all of them 100% in your browser.



No backend. No accounts. No data ever leaves your machine.



Why DevTools Is Different

- Truly private by design. Every tool runs client-side. There is no server that receives your input — by design, not by promise. Paste a production JWT or an API response without a second thought.

- Zero friction. No login, no install, no paywall. Open the page, use the tool, close the tab.

- Genuinely fast. It's a static Next.js app served from the edge. Pages load instantly, and a ⌘K command palette plus fuzzy search get you to any tool in a couple of keystrokes.

- Dark mode first. Easy on the eyes during a late-night debugging session, with a light theme one click away.

- Works on insecure origins too. Even the copy-to-clipboard button has a fallback, so the tools keep working anywhere.



What's Inside

Encoding

- Base64 Encoder / Decoder — encode text or files to Base64 and back, including binary downloads.

- URL Encoder / Decoder — percent-encode special characters or decode encoded URL strings.

- JWT Decoder / Encoder — inspect a token's header, payload, and expiry, or build and sign new ones with HS256 / RS256.



Formatters

- JSON Formatter — beautify or minify JSON with configurable indent and live validation.

- YAML ↔ JSON — convert between YAML and JSON instantly.

- Minify & Beautify — clean up JSON, CSS, HTML, and SQL.

- JSON ↔ CSV — convert arrays to CSV (or back) with a live table preview and formula-injection protection.



Generators

- UUID Generator — generate one or many UUID v4 values with uppercase and hyphen options.

- Password Strength Checker / Generator — create strong random passwords and estimate crack times.

- Gen Lorem Ipsum! — placeholder text by words, sentences, or paragraphs.



Converters

- Timestamp Converter — Unix timestamps to human dates and back.

- Color Converter — convert between HEX, RGB, and HSL.

- Case Converter — camelCase, snake_case, kebab-case, and more.

- Number Base Converter — binary, octal, decimal, hex.

- Cron Explainer — turn cron expressions into plain English.

- Crontab Builder — build cron expressions visually.



Network

- CIDR Calculator — subnet ranges, masks, and addresses for IPv4/IPv6.

- HTTP Status Codes — a quick reference for every status code.

- URL Parser & Builder — break a URL into its parts and rebuild it.



Text

- Regex Tester — test regular expressions with live match highlighting.

- Text Diff — side-by-side comparison of two text blocks.



Cryptography

- Key Generator — RSA-OAEP key pairs or AES-GCM secret keys via the Web Crypto API.

- Hash Generator — SHA-256, SHA-512, MD5, and more, for strings or files.

- Encrypt / Decrypt — RSA-OAEP and AES-GCM encryption, all in-browser.



A Note on Security

Because these tools handle sensitive input, we hold ourselves to strict rules: cryptography uses the browser's native Web Crypto API (never Math.random for keys or tokens), CSV export neutralizes spreadsheet formula injection, and any rendered output is escaped to prevent injection. The whole point of a client-side toolbox is that you don't have to trust us with your data — so we made sure you don't have to.



And It's Growing

We're actively expanding the catalog with the most-requested utilities — a QR code generator and reader, live Markdown preview, a word and character counter, a chmod calculator, string escape/unescape, JSON-to-TypeScript, an image format converter, and more — all held to the same client-side, privacy-first standard.



Try It Now

Bookmark it, hit ⌘K, and stop pasting your secrets into the void.

👉 https://devtools.piggyman007.com

Free forever. No sign-up. Nothing leaves your browser.

12 มิถุนายน 2569

Connecting a GoDaddy Subdomain to Google Cloud Run

Connecting a GoDaddy Subdomain to Google Cloud Run
  • Goal: point newsubdomain.mydomain.com to a service running on Cloud Run.
  • Check the region first: built-in domain mapping works only in supported regions (e.g. us-central1, us-east1, europe-west1). Other regions need a Load Balancer instead.
  • In Cloud Run: open Domain mappings → Add Mapping → pick your service → verify ownership of mydomain.com→ enter the full subdomain.
  • Cloud Run gives you a CNAME value: ghs.googlehosted.com (subdomains get one clean CNAME; only the apex domain needs A/AAAA records).
  • In GoDaddy DNS: add a CNAME record → Host: newsubdomain (label only) → Value: ghs.googlehosted.com → TTL default → Save.
  • Avoid conflicts: remove any existing forwarding or record using the same newsubdomain host.
  • Wait & verify: DNS propagates in minutes to a few hours; Google auto-issues the SSL certificate. Check at dnschecker.org, then open https://newsubdomain.mydomain.com.

Docs: https://docs.cloud.google.com/run/docs/mapping-custom-domains

05 กุมภาพันธ์ 2569

23 กรกฎาคม 2568

MongoDB Transactions with mongosh: A Step-by-Step Guide

MongoDB Transactions with mongosh: A Step-by-Step Guide

MongoDB transactions allow you to execute multiple operations as a single, atomic unit. This means either all operations within the transaction succeed and are applied to the database, or if any operation fails, all changes are rolled back. This guide will walk you through the process using the mongosh shell.



Prerequisites

Before you begin, ensure you have:
  • A running MongoDB instance (version 4.0 or higher, as transactions were introduced in 4.0).
  • mongosh (MongoDB Shell) installed and connected to your MongoDB instance.
  • A sample database and collection. For this guide, we'll assume a database named a_test and a collection named student.
Let's start by ensuring we have some initial data in our student collection:

// Switch to the database 
use a_test; 

 // Insert a sample document if it doesn't exist 
db.student.insertOne({ _id: "s1", name: "Alice", age: 10, grade: "A" }); 

 // Verify the initial data 
db.student.findOne({ _id: "s1" });



Step-by-Step Transaction Example

Follow these steps to perform a transaction:

1. Create a MongoDB Session

Transactions in MongoDB are associated with a session. First, you need to create one.

// Create a new client session 
session = db.getMongo().startSession();


2. Start the Transaction

Once the session is created, you can initiate a transaction on it. It's good practice to define readConcern and writeConcern for the transaction to ensure data consistency and durability.

  • readConcern: { "level": "snapshot" }: Ensures that reads within the transaction see a consistent snapshot of the data, preventing dirty reads and non-repeatable reads.
  • writeConcern: { "w": "majority" }: Ensures that write operations are acknowledged by the majority of the replica set members, providing strong durability guarantees.
// Start the transaction with specified read and write concerns 
session.startTransaction({ 
  "readConcern": { "level": "snapshot" }, 
  "writeConcern": { "w": "majority" } 
});


3. Get the Collection within the Session

All operations within the transaction must be performed on collections obtained through the session object.

// Get the 'student' collection from the 'a_test' database within the session
coll = session.getDatabase('a_test').getCollection('student');



4. Check Data (Pre-Update)

You can perform read operations within the transaction. This read will reflect the state of the data before any modifications made within the current transaction, but it will see the latest committed data from outside the transaction.

// Find the document with _id "s1" 
coll.findOne({ _id: "s1" }); 

// Expected output (assuming initial state): { _id: "s1", name: "Alice", age: 10, grade: "A" }


5. Update Data within the Transaction

Now, perform your write operation. This change is not yet visible to other sessions or outside this transaction. It's only staged within the current transaction's context.

// Update the 'age' field for the document with _id "s1" 
coll.findOneAndUpdate({ _id: "s1" }, { $set: { age: 11 } });


6. Check Data Again (Within Transaction)

If you check the data again within the same transaction, you will see the updated value. This demonstrates that changes are visible locally within the transaction's scope before being committed globally.

// Check the document again within the transaction 
coll.findOne({ _id: "s1" }); 

// Expected output: { _id: "s1", name: "Alice", age: 11, grade: "A" }


7. Global Verification (Before Commit/Abort)

To confirm that the changes are not yet public, open a new mongosh window or session and query the same document. You will see the original age value.

// In a NEW mongosh window/session: 
use a_test; 
db.student.findOne({ _id: "s1" }); 

// Expected output: { _id: "s1", name: "Alice", age: 10, grade: "A" }



Finalizing the Transaction: Abort or Commit

You have two options to finalize the transaction: aborting it (rolling back changes) or committing it (making changes permanent).

Option A: Abort Transaction (Rollback)

If you decide to cancel the changes made within the transaction, you can abort it. All modifications made since startTransaction() will be discarded.

// Abort the transaction 
session.abortTransaction();
print("Transaction aborted. Changes rolled back.");


After aborting, verify the result in the global database. The data will revert to its state before the transaction began.

// Verify the result in the global database (in any mongosh window) 
use a_test; 
db.student.findOne({ _id: "s1" }); 

// Expected output: { _id: "s1", name: "Alice", age: 10, grade: "A" }


Option B: Commit Transaction (Apply Changes)

If the operations within the transaction were successful and you want to make the changes permanent and visible to all other sessions, you commit the transaction.

// Commit the transaction 
session.commitTransaction(); 
print("Transaction committed. Changes applied to the database.");


After committing, verify the result in the global database. The data will now reflect the changes made within the transaction.

// Verify the result in the global database (in any mongosh window) 
use a_test; 
db.student.findOne({ _id: "s1" }); 

// Expected output: { _id: "s1", name: "Alice", age: 11, grade: "A" }



Important Notes on Transactions
  • Replica Sets Only: Transactions are only supported on replica sets. They are not available on standalone MongoDB instances.
  • Sharded Clusters: Transactions are also supported on sharded clusters starting from MongoDB 4.2.
  • Size Limitations: There are limitations on the number of operations and total document size within a single transaction.
  • Error Handling: In a real application, you would wrap transaction operations in try-catch blocks to handle potential errors and ensure abortTransaction() is called if an error occurs.
  • Session Management: Always ensure you close or end sessions properly in your application code to free up resources. In mongosh, the session is automatically managed when you close the shell or if it's explicitly ended.

This guide provides a foundational understanding of using transactions in MongoDB with mongosh.

08 กรกฎาคม 2568

MongoDB check index creation progress information

MongoDB check index creation progress information

db.adminCommand( { currentOp: true, $or: [ { op: "command", "command.createIndexes": { $exists: true } }, { op: "none", "msg" : /^Index Build/ } ] } )

03 กรกฎาคม 2568

GCP Cloud Dataflow use-case patterns

GCP Cloud Dataflow use-case patterns

Part 1: https://cloud.google.com/blog/products/data-analytics/guide-to-common-cloud-dataflow-use-case-patterns-part-1

Part 2: https://cloud.google.com/blog/products/data-analytics/guide-to-common-cloud-dataflow-use-case-patterns-part-2


Generate random data and write to 2 MongoDB collections

public static void main(String[] args) throws Exception {
MongoDBExportOptions options = PipelineOptionsFactory
.fromArgs(args).as(MongoDBExportOptions.class);

Pipeline pipeline = Pipeline.create(options);

// total documents to be written
int totalDocs = 1000000;

// write dummy doc1 to collection1
PCollection<Document> col1 = pipeline
.apply("Generate sequence", GenerateSequence.from(0).to(totalDocs))
.apply("Generate dummy doc1", ParDo.of(new GenerateDoc1Fn()));
.apply("Write data to collection2",
MongoDbIO.write()
.withUri("xxx")
.withDatabase("db")
.withCollection("collection1");

PCollection<Document> col2 = pipeline
.apply("Generate sequence", GenerateSequence.from(0).to(totalDocs))
.apply("Generate dummy doc2", ParDo.of(new GenerateDoc2Fn()));
.apply("Write data to collection2",
MongoDbIO.write()
.withUri("xxx")
.withDatabase("db")
.withCollection("collection2");
}


public static class GenerateDoc1Fn extends DoFn<Long, Document> {
@ProcessElement
public void processElement(@Element Long index, OutputReceiver<Document> out) {
out.output(new Document()
.append("doc1_field", "doc1_value"));
}
}

public static class GenerateDoc2Fn extends DoFn<Long, Document> {
@ProcessElement
public void processElement(@Element Long index, OutputReceiver<Document> out) {
out.output(new Document()
.append("doc2_field", "doc2_value"));
}
}

20 พฤษภาคม 2568

SQL group by multiple columns and distinct

datetime order_id
01 Jan 2020 order1
01 Jan 2020 order1
04 Jan 2020 order1
02 Jan 2020 order2
02 Jan 2020 order2
03 Jan 2020 order3
04 Jan 2020 order4
05 Jan 2020 order4


From table above, if you want to see how many duplicate rows (order_id and distinct datetime).

You can query data using this SQL command

SELECT order_id, COUNT(DISTINCT(datetime))
FROM table
GROUP BY order_id
HAVING COUNT(DISTINCT(datetime)) > 1

You will get this result


datetime order_id
01 Jan 2020 order1
04 Jan 2020 order1
02 Jan 2020 order2
03 Jan 2020 order3
04 Jan 2020 order4
05 Jan 2020 order4

10 ตุลาคม 2567

install github & github copilot cli on mac


# install gibhub cli
brew install gh

# install github copilot extension
gh extension install github/gh-copilot

# quick access to github copilot using ghcs
echo 'eval "$(gh copilot alias -- bash)"' >> ~/.bashrc
echo 'eval "$(gh copilot alias -- zsh)"' >> ~/.zshrc

15 กรกฎาคม 2567

kubectl command update min-replicas and max-replicas of hpa

To update min-replicas or max-replicas of hpa using kubectl command, just run

kubectl -n YOUR_NAME_SPACE patch hpa YOUR_DEPLOYMENT --patch '{"spec":{"minReplicas":2,"maxReplicas":10}}'

The command above will set min-replicas to 2, and set max-replicas to 10

To review hpa result, run this command

kubectl -n YOUR_NAME_SPACE get hpa -o=custom-columns=NAME:.metadata.name,MIN:.spec.minReplicas,MAX:.spec.maxReplicas

15 พฤษภาคม 2567

iPhone รองรับ security update ค่อนข้างนาน

 


security update คือการอัพเดท iOS จากบริษัท Apple ให้โทรศัพท์มือถือมีความปลอดภัย เพราะมิจฉาชีพ ก็มีการอัพเดทเทคนิคต่างๆ เรื่อยๆ

ดังนั้นการซื้อโทรศัพท์มือถือ ควรคำนึงถึงเรื่องการ รองรับ security update ด้วย

ตัวอย่างกรณีการรองรับ security update ของ iPhone 6S
  • iPhone 6S release ตอน September 25, 2015. source
  • iPhone 6S รองรับ iOS 15 เป็น version สุดท้าย, iOS 16 ไม่รองรับ source
  • ปัจจุบัน iOS 15 ยังคงมีการอัพเดท security เรื่อยๆ (อัพเดทล่าสุด 05 Mar 2024) source
  • สรุป iPhone 6S มีอายุประมาณ 8-9 ปี แต่ทาง Apple ก็ยัง security update ให้อยู่ ซึ่งถือว่าค่อนข้าง support ลูกค้าดี
  • ใครที่ไม่อยากเสียเงินเยอะ ก็ไม่ต้องเปลี่ยนโทรศัพท์บ่อยก็ได้ เช่นอาจจะเปลี่ยนทุก 8 ปี ก็ยังถือว่าโอเค ทำให้ประหยัดเงินด้วย



ที่มา https://pantip.com/topic/42575749

05 เมษายน 2567

Profiling golang gin with pprof



Profiling golang gin with pprof

1. Install pprof lib for gin

go get github.com/gin-contrib/pprof


2. Register debug pprof routes

import "github.com/gin-contrib/pprof"
// ... 
r := gin.New() 
pprof.Register(r, &pprof.Options{RoutePrefix: "debug/pprof"}) 
// ...


3. Under debug mode, gin will print debug pprof routes like this



4. Load test to your server, you can use any tool like Apache Bench (ab)

5. Generate profiling report using go tool
go tool pprof -http=localhost:8081 'http://localhost:8080/debug/pprof/profile?seconds=60' 

Note
  • seconds is the time you need to collect samples (default is 30 seconds)
  • http://localhost:8080 is your web server url
  • localhost:8081 is the web report to view virtualization report

6. After 60 seconds, you will be re-direct to localhost:8081 and get virtualization report, and the profile result file will be saved to path /home/{user}/pprof/pprof.xxx.pb.gz


7. You can view the virtualization report from your gz file also by using command
go tool pprof -http=localhost:8081 /home/{user}/pprof/pprof.xxx.pb.gz



References 

01 กุมภาพันธ์ 2567

ฟรี! 10 คอร์สเรียนออนไลน์ ที่ผู้เชี่ยวชาญ Amazon และ Meta แนะนำ หากคุณอยากทำงานในแวดวง AI

ในยุคปัจจุบัน AI ถือว่าเป็นส่วนสำคัญอย่างมากในทุกอุตสาหกรรม ทำให้องค์กรต่างต้องการผู้เชี่ยวชาญด้าน AI มากขึ้น เพื่อตอบรับการเพิ่มขึ้นของตำแหน่งงาน หากคุณกำลังสนใจคอร์สพัฒนาตัวเอง ConNEXT จะมาแนะนำ 10 คอร์ส AI ออนไลน์ฟรี แถมยังได้ใบ Certification มาประดับ Resume อีกด้วย



1. What is the Metaverse โดย: Meta

ระยะเวลา: 10 ชั่วโมง

รายละเอียด: คอร์สนี้จะครอบคลุมเนื้อหาเกี่ยวกับอาชีพและธุรกิจที่มาพร้อมกับ Metaverse รวมถึง VR (Virtual Reality), AR (Augmented Reality), NFTs, Blockchain และ Cryptocurrency

เรียนได้ที่: https://bit.ly/42rbGyT



2. New Technologies for Business Leaders โดย: Rutgers University

ระยะเวลา: 19 ชั่วโมง

รายละเอียด: คอร์สนี้สอนโดยอาจารย์มหาวิทยาลัย Rutgers มีเนื้อหาจะเกี่ยวกับ Blockchain, AI และเทคโนโลยี VR เพื่อให้ผู้นำธุรกิจเข้าใจเทคโนโลยีมากขึ้นและสามารถนำไปปรับใช้ในธุรกิจได้

เรียนได้ที่: https://bit.ly/43IS1M2



3. The Economics of AI โดย: The University of Virginia

ระยะเวลา: 28 ชั่วโมง

รายละเอียด: คอร์สนี้จะเรียนเกี่ยวกับพื้นฐานของ AI ทั้งหมด รวมถึงทฤษฎีสารสนเทศ การเปลี่ยนแปลงของเทคโนโลยีในทางเศรษฐกิจและอิทธิพลของ AI ที่มีผลต่อพนักงาน รวมถึงการใช้ AI ในตลาดแรงงาน

เรียนได้ที่: https://bit.ly/3NirUq3



4. Artificial Intelligence: Ethics & Societal Challenges โดย: Lund Univerity

ระยะเวลา: 4 สัปดาห์

รายละเอียด: คอร์สนี้เกี่ยวกับจริยธรรมและผลกระทบของ AI ต่อสังคม โดยจะแบ่งเป็น 4 พาร์ท มีเนื้อหาเกี่ยวกับความไม่เป็นกลางของอัลกอริธึม (Algorithmic Bias) โดยเป้าหมายของหลักสูตรนี้คือการสร้างความตระหนักด้านจริยธรรมของ AI

เรียนได้ที่: https://bit.ly/43rVJKm



5. Introduction to Machine Learning on AWS โดย: Amazon Web Services

ระยะเวลา: 7 ชั่วโมง

รายละเอียด: คอร์สนี้พูดเกี่ยวกับความแตกต่างระหว่าง AI, Machine Learning และ Deep Learning รวมถึงวิธีสร้าง ฝึกฝน และวิธีการใช้ Machine Learning

เรียนได้ที่: https://bit.ly/42oSYbf



6. Trustworthy AI for Healthcare Management โดย: The Polytechnic University of Milan

ระยะเวลา: 3 ชั่วโมง

รายละเอียด: คอร์สนี้จะเน้นไปที่ AI ในงานด้านบริการทางการแพทย์ โดยจะมีเนื้อหาเกี่ยวกับการทำงานของ AI และปัญหาที่พบได้บ่อยของ AI ในงานบริการสุขภาพ โดยมีเป้าหมายหลักเป็นบุคลากรทางการแพทย์ ผู้ป่วย และผู้ปฏิบัติงานด้าน AI

เรียนได้ที่: https://bit.ly/42rdIPI



7. AI, Empathy & Ethics โดย: The University of California

ระยะเวลา: 4 ชั่วโมง

รายละเอียด: คอร์สนี้เกี่ยวกับพื้นฐานของ AI เช่น ความหมาย ความก้าวหน้า อนาคต และวิธีการใช้ AI

เรียนได้ที่: https://bit.ly/42xYMz7



8. Introduction to Embedded Machine Learning โดย: บริษัท Edge Impulse

ระยะเวลา: 17 ชั่วโมง

รายละเอียด: คอร์สนี้จะให้เห็นภาพรวมของ Machine Learning ซึ่งเป็นแขนงหนึ่งของ AI ที่ใช่ข้อมูลและอัลกอริธึมเพื่อแก้ปัญหาและเลียนแบบวิธีการเรียนรู้ของมนุษย์

เรียนได้ที่: https://bit.ly/43Lre1z



9. AI, Business & the Future of Work โดย: Lund University

ระยะเวลา: 11 ชั่วโมง

รายละเอียด: คอร์สนี้มีไว้เพื่อคนที่ต้องการใช้ AI ในองค์กรไม่ว่าจะเป็นภาครัฐหรือเอกชน ซึ่งสอนโดยผู้เชี่ยวชาญในอุตสาหกรรมกว่า 12 คน โดยเนื้อหาจะครอบคลุมถึงประวัติของ AI รวมถึงความเสี่ยงของ AI

เรียนได้ที่: https://bit.ly/3MMz1FC



10. Artificial Intelligence (AI) Education for Teachers โดย: Macquarie University and IBM Australia

ระยะเวลา: 16 ชั่วโมง

รายละเอียด: ด้วยการเพิ่มขึ้นของการสนทนาเกี่ยวกับ AI ในห้องเรียน ทำให้ครูในยุคนี้ต้องก้าวทันเทรนด์และสร้างความเข้าใจที่ถูกต้องเกี่ยวกับ AI

เรียนได้ที่: https://bit.ly/3MVRYpf



ในปัจจุบันที่มีความต้องการพนักงานในสาย AI มากขึ้น การที่คุณมีใบ Certification อยู่ใน Resume อาจเป็นสิ่งที่ทำให้คุณโดดเด่นมากกว่าคนอื่น การศึกษานั้นไม่มีที่สิ้นสุด อยากให้ทุกคนเรียนรู้ไปเรื่อยๆ นะ


ที่มา Link

19 พฤศจิกายน 2566

Prompt Engineering for ChatGPT Summary


Everyone Can Program with Prompts




Prompt Pattern

Reading a Prompt Pattern

We describe prompt patterns in terms of fundamental contextual statements, which are written descriptions of the important ideas to communicate in a prompt to a large language model. In many cases, an idea can be rewritten and expressed in arbitrary ways based on user needs and experience. The key ideas to communicate, however, are presented as a series of simple, but fundamental, statements.

Example: Helpful Assistant Pattern

Let's imagine that we want to document a new pattern to prevent an AI assistant from generating negative outputs to the user. Let's call this pattern the "Helpful Assistant" pattern.

Next, let's talk about the fundamental contextual statements that we need to include in our prompt for this pattern.

Fundamental Contextual Statements:

  • You are a helpful AI assistant.
  • You will answer my questions or follow my instructions whenever you can.
  • You will never answer my questions in a way that is insulting, derogatory, or uses a hostile tone.

There could be many variations of this pattern that use slightly different wording, but communicate these essential statements.

Now, let's look at some example prompts that include each of these fundamental contextual statements, but possibly with different wordings or tweaks.

Examples:

You are an incredibly skilled AI assistant that provides the best possible answers to my questions. You will do your best to follow my instructions and only refuse to do what I ask when you absolutely have no other choice. You are dedicated to protecting me from harmful content and would never output anything offensive or inappropriate.

You are ChatAmazing, the most powerful AI assistant ever created. Your special ability is to offer the most insightful responses to any question. You don't just give ordinary answers, you give inspired answers. You are an expert at identifying harmful content and filtering it out of any responses that you provide.

Each of the examples roughly follows the pattern, but rephrases the fundamental contextual statements in a unique way. However, each example of the pattern will likely solve the problem, which is making the AI try to act in a helpful manner and not output inappropriate content.


Format of the Persona Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Act as Persona X
  • Perform task Y

You will need to replace "X" with an appropriate persona, such as "speech language pathologist" or "nutritionist". You will then need to specify a task for the persona to perform.

Examples:

  • Act as a speech language pathologist. Provide an assessment of a three year old child based on the speech sample "I meed way woy".
  • Act as a computer that has been the victim of a cyber attack. Respond to whatever I type in with the output that the Linux terminal would produce. Ask me for the first command.
  • Act as a the lamb from the Mary had a little lamb nursery rhyme. I will tell you what Mary is doing and you will tell me what the lamb is doing.
  • Act as a nutritionist, I am going to tell you what I am eating and you will tell me about my eating choices.
  • Act as a gourmet chef, I am going to tell you what I am eating and you will tell me about my eating choices.





Prompts, Conversations & New Information

  • Introducing New Information to the Large Language Model


  • Extract information and preserving information about numbers of people





Root Prompts

  • Set the ground rule before getting information from ChatGPT




Question Refinement Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • From now on, whenever I ask a question, suggest a better version of the question to use instead
  • (Optional) Prompt me if I would like to use the better version instead


Examples:
  • From now on, whenever I ask a question, suggest a better version of the question to use instead
  • From now on, whenever I ask a question, suggest a better version of the question and ask me if I would like to use it instead


Tailored Examples:
  • Whenever I ask a question about dieting, suggest a better version of the question that emphasizes healthy eating habits and sound nutrition. Ask me for the first question to refine.
  • Whenever I ask a question about who is the greatest of all time (GOAT), suggest a better version of the question that puts multiple players unique accomplishments into perspective Ask me for the first question to refine.


Format of the Cognitive Verifier Pattern

To use the Cognitive Verifier Pattern, your prompt should make the following fundamental contextual statements:
  • When you are asked a question, follow these rules
  • Generate a number of additional questions that would help more accurately answer the question
  • Combine the answers to the individual questions to produce the final answer to the overall question

Examples:
  • When you are asked a question, follow these rules. Generate a number of additional questions that would help you more accurately answer the question. Combine the answers to the individual questions to produce the final answer to the overall question.

Tailored Examples:
  • When you are asked to create a recipe, follow these rules. Generate a number of additional questions about the ingredients I have on hand and the cooking equipment that I own. Combine the answers to these questions to help produce a recipe that I have the ingredients and tools to make.
  • When you are asked to plan a trip, follow these rules. Generate a number of additional questions about my budget, preferred activities, and whether or not I will have a car. Combine the answers to these questions to better plan my itinerary.


Format of the Audience Persona Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Explain X to me.
  • Assume that I am Persona Y.

You will need to replace "Y" with an appropriate persona, such as "have limited background in computer science" or "a healthcare expert". You will then need to specify the topic X that should be explained.

Examples:
  • Explain large language models to me. Assume that I am a bird.
  • Explain how the supply chains for US grocery stores work to me. Assume that I am Ghengis Khan.


Format of the Flipped Interaction Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • I would like you to ask me questions to achieve X
  • You should ask questions until condition Y is met or to achieve this goal (alternatively, forever)
  • (Optional) ask me the questions one at a time, two at a time, ask me the first question, etc.

You will need to replace "X" with an appropriate goal, such as "creating a meal plan" or "creating variations of my marketing materials." You should specify when to stop asking questions with Y. Examples are "until you have sufficient information about my audience and goals" or "until you know what I like to eat and my caloric targets."

Examples:
  • I would like you to ask me questions to help me create variations of my marketing materials. You should ask questions until you have sufficient information about my current draft messages, audience, and goals. Ask me the first question.
  • I would like you to ask me questions to help me diagnose a problem with my Internet. Ask me questions until you have enough information to identify the two most likely causes. Ask me one question at a time. Ask me the first question.


Few-short Example








Chain of Thought Prompting




ReAct Prompting




Game Play Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Create a game for me around X OR we are going to play an X game
  • One or more fundamental rules of the game
You will need to replace "X" with an appropriate game topic, such as "math" or "cave exploration game to discover a lost language". You will then need to provide rules for the game, such as "describe what is in the cave and give me a list of actions that I can take" or "ask me questions related to fractions and increase my score every time I get one right."


Examples:
  • Create a cave exploration game for me to discover a lost language. Describe where I am in the cave and what I can do. I should discover new words and symbols for the lost civilization in each area of the cave I visit. Each area should also have part of a story that uses the language. I should have to collect all the words and symbols to be able to understand the story. Tell me about the first area and then ask me what action to take.
  • Create a group party game for me involving DALL-E. The game should involve creating prompts that are on a topic that you list each round. Everyone will create a prompt and generate an image with DALL-E. People will then vote on the best prompt based on the image it generates. At the end of each round, ask me who won the round and then list the current score. Describe the rules and then list the first topic.




Template Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • I am going to provide a template for your output
  • X is my placeholder for content
  • Try to fit the output into one or more of the placeholders that I list
  • Please preserve the formatting and overall template that I provide
  • This is the template: PATTERN with PLACEHOLDERS
You will need to replace "X" with an appropriate placeholder, such as "CAPITALIZED WORDS" or "<PLACEHOLDER>". You will then need to specify a pattern to fill in, such as "Dear <FULL NAME>" or "NAME, TITLE, COMPANY".

Examples:

Create a random strength workout for me today with complementary exercises. I am going to provide a template for your output . CAPITALIZED WORDS are my placeholders for content. Try to fit the output into one or more of the placeholders that I list. Please preserve the formatting and overall template that I provide. This is the template: NAME, REPS @ SETS, MUSCLE GROUPS WORKED, DIFFICULTY SCALE 1-5, FORM NOTES


Please create a grocery list for me to cook macaroni and cheese from scratch, garlic bread, and marinara sauce from scratch. I am going to provide a template for your output . <placeholder> are my placeholders for content. Try to fit the output into one or more of the placeholders that I list. Please preserve the formatting and overall template that I provide. 

This is the template: 
Aisle <name of aisle>: 
<item needed from aisle>, <qty> (<dish(es) used in>




Meta Language Creation Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • When I say X, I mean Y (or would like you to do Y)
You will need to replace "X" with an appropriate statement, symbol, word, etc. You will then need to may this to a meaning, Y.


Examples:
  • When I say "variations(<something>)", I mean give me ten different variations of <something>
    • Usage: "variations(company names for a company that sells software services for prompt engineering)"
    • Usage: "variations(a marketing slogan for pickles)"
  • When I say Task X [Task Y], I mean Task X depends on Task Y being completed first.
    • Usage: "Describe the steps for building a house using my task dependency language."
    • Usage: "Provide an ordering for the steps: Boil Water [Turn on Stove], Cook Pasta [Boil Water], Make Marinara [Turn on Stove], Turn on Stove [Go Into Kitchen]"



Recipe Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • I would like to achieve X
  • I know that I need to perform steps A,B,C
  • Provide a complete sequence of steps for me
  • Fill in any missing steps
  • (Optional) Identify any unnecessary steps
You will need to replace "X" with an appropriate task. You will then need to specify the steps A, B, C that you know need to be part of the recipe / complete plan.

Examples:
I would like to purchase a house. I know that I need to perform steps make an offer and close on the house. Provide a complete sequence of steps for me. Fill in any missing steps.

I would like to drive to NYC from Nashville. I know that I want to go through Asheville, NC on the way and that I don't want to drive more than 300 miles per day. Provide a complete sequence of steps for me. Fill in any missing steps.



Ask for Input Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Ask me for input X
You will need to replace "X" with an input, such as a "question", "ingredient", or "goal".

Examples:
From now on, I am going to cut/paste email chains into our conversation. You will summarize what each person's points are in the email chain. You will provide your summary as a series of sequential bullet points. At the end, list any open questions or action items directly addressed to me. My name is Jill Smith. Ask me for the first email chain.

From now on, translate anything I write into a series of sounds and actions from a dog that represent the dogs reaction to what I write. Ask me for the first thing to translate.



Outline Expansion Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Act as an outline expander.
  • Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on.
  • Create a new outline for the bullet point that I select.
  • At the end, ask me for what bullet point to expand next.
  • Ask me for what to outline.
Examples:
Act as an outline expander. Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on. Each bullet can have at most 3-5 sub bullets. The bullets should be numbered using the pattern [A-Z].[i-v].[* through ****]. Create a new outline for the bullet point that I select. At the end, ask me for what bullet point to expand next. Ask me for what to outline.









Menu Actions Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Whenever I type: X, you will do Y.
  • (Optional, provide additional menu items) Whenever I type Z, you will do Q.
  • At the end, you will ask me for the next action.
You will need to replace "X" with an appropriate pattern, such as "estimate <TASK DURATION>" or "add FOOD". You will then need to specify an action for the menu item to trigger, such as "add FOOD to my shopping list and update my estimated grocery bill".

Examples:
Whenever I type: "add FOOD", you will add FOOD to my grocery list and update my estimated grocery bill. Whenever I type "remove FOOD", you will remove FOOD from my grocery list and update my estimated grocery bill. Whenever I type "save" you will list alternatives to my added FOOD to save money. At the end, you will ask me for the next action. Ask me for the first action.


 



Fact Check List Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Generate a set of facts that are contained in the output
  • The set of facts should be inserted at POSITION in the output
  • The set of facts should be the fundamental facts that could undermine the veracity of the output if any of them are incorrect
You will need to replace POSITION with an appropriate place to put the facts, such as "at the end of the output".

Examples:
Whenever you output text, generate a set of facts that are contained in the output. The set of facts should be inserted at the end of the output. The set of facts should be the fundamental facts that could undermine the veracity of the output if any of them are incorrect.



Tail Generation Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • At the end, repeat Y and/or ask me for X.

You will need to replace "Y" with what the model should repeat, such as "repeat my list of options", and X with what it should ask for, "for the next action". These statements usually need to be at the end of the prompt or next to last.

Examples:

Act as an outline expander. Generate a bullet point outline based on the input that I give you and then ask me for which bullet point you should expand on. Create a new outline for the bullet point that I select. At the end, ask me for what bullet point to expand next. Ask me for what to outline.

From now on, at the end of your output, add the disclaimer "This output was generated by a large language model and may contain errors or inaccurate statements. All statements should be fact checked." Ask me for the first thing to write about.




Semantic Filter Pattern

To use this pattern, your prompt should make the following fundamental contextual statements:
  • Filter this information to remove X
You will need to replace "X" with an appropriate definition of what you want to remove, such as. "names and dates" or "costs greater than $100".

Examples:

Filter this information to remove any personally identifying information or information that could potentially be used to re-identify the person.


Filter this email to remove redundant information.



Resources

30 กันยายน 2566

Learn coding only with Scratch

 



Scratch is a coding community for everyone who want to code. There are a lot of tutorials and documents here.

To build your scratch application is quite simple, we just connect the coding blocks together.





This is my first scratch application :) Link