npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chiwormjava

v2.0.2

Published

A simple CLI tool to **view and copy Java data structure code** (like LinkedList, Stack, etc.) directly in your browser.

Readme

🚀 Java Code Watch

A simple CLI tool to view and copy Java data structure code (like LinkedList, Stack, etc.) directly in your browser.


📦 Installation

Option 1: Use without installing (recommended)

npx javacodewatch

Option 2: Install locally

npm install chiwormjava

Run:

npx javacodewatch

Option 3: Install globally (optional)

npm install -g chiwormjava

Run:

javacodewatch

🧠 What it does

  • Opens a local server
  • Launches your browser
  • Shows Java code snippets
  • Click → View code
  • Click → Copy code

📸 Features

  • 📚 Java DSA snippets (LinkedList, etc.)
  • 🖱️ One-click code view
  • 📋 Copy to clipboard
  • 🌙 Clean dark UI

▶️ Usage

After running the command:

javacodewatch

👉 Your browser will open automatically:

http://localhost:3000

Armstrong



Name: <input type="text" name="name" value="<?php echo $editData['name'] ?? ''; ?>"><br><br>
Email: <input type="text" name="email" value="<?php echo $editData['email'] ?? ''; ?>"><br><br>

<?php if($editData){ ?>
    <input type="submit" name="update" value="Update">
<?php } else { ?>
    <input type="submit" name="add" value="Add">
<?php } ?>

$img = imagecreatetruecolor(500, 350);

$white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $red = imagecolorallocate($img, 255, 0, 0); $blue = imagecolorallocate($img, 0, 0, 255); $green = imagecolorallocate($img, 0, 255, 0); $yellow= imagecolorallocate($img, 255, 255, 0);

imagefill($img, 0, 0, $white);

imagerectangle($img, 20, 20, 120, 100, $black); imagefilledrectangle($img, 140, 20, 240, 100, $green);

imageellipse($img, 350, 70, 80, 80, $red); imagefilledellipse($img, 450, 70, 80, 80, $yellow);

imageline($img, 20, 150, 200, 250, $blue);

$points = [300,150, 350,250, 250,250]; imagepolygon($img, $points, 3, $black);

$points2 = [400,150, 450,250, 350,250]; imagefilledpolygon($img, $points2, 3, $red);

imagearc($img, 100, 300, 100, 50, 0, 180, $blue);

imagestring($img, 5, 180, 300, "Shapes Demo", $black);

header("Content-Type: image/png"); imagepng($img); imagedestroy($img);



1. Right Triangle

Pattern:

*
* *
* * *
* * * *
* * * * *

Code:

<?php
for($i = 1; $i <= 5; $i++){
    for($j = 1; $j <= $i; $j++){
        echo "* ";
    }
    echo "<br>";
}
?>

2. Inverted Triangle

Pattern:

* * * * *
* * * *
* * *
* *
*

Code:

<?php
for($i = 5; $i >= 1; $i--){
    for($j = 1; $j <= $i; $j++){
        echo "* ";
    }
    echo "<br>";
}
?>

3. Full Pyramid

Pattern:

    *
   ***
  *****
 *******
*********

Code:

<?php
for($i = 1; $i <= 5; $i++){
    for($j = 1; $j <= 5 - $i; $j++){
        echo "&nbsp;";
    }
    for($k = 1; $k <= (2*$i - 1); $k++){
        echo "*";
    }
    echo "<br>";
}
?>

⭐ 4. Diamond Pattern

Pattern:

    *
   ***
  *****
   ***
    *

Code:

<?php
// upper
for($i = 1; $i <= 3; $i++){
    for($j = 1; $j <= 3 - $i; $j++){
        echo "&nbsp;";
    }
    for($k = 1; $k <= (2*$i - 1); $k++){
        echo "*";
    }
    echo "<br>";
}

// lower
for($i = 2; $i >= 1; $i--){
    for($j = 1; $j <= 3 - $i; $j++){
        echo "&nbsp;";
    }
    for($k = 1; $k <= (2*$i - 1); $k++){
        echo "*";
    }
    echo "<br>";
}
?>

5. Number Triangle

Pattern:

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Code:

<?php
for($i = 1; $i <= 5; $i++){
    for($j = 1; $j <= $i; $j++){
        echo $j . " ";
    }
    echo "<br>";
}
?>

6. Floyd’s Triangle

Pattern:

1
2 3
4 5 6
7 8 9 10

Code:

<?php
$num = 1;
for($i = 1; $i <= 4; $i++){
    for($j = 1; $j <= $i; $j++){
        echo $num . " ";
        $num++;
    }
    echo "<br>";
}
?>

7. Alphabet Pattern

Pattern:

A
A B
A B C
A B C D

Code:

<?php
for($i = 65; $i <= 68; $i++){
    for($j = 65; $j <= $i; $j++){
        echo chr($j) . " ";
    }
    echo "<br>";
}
?>

8. Hollow Square

Pattern:

* * * * *
*       *
*       *
*       *
* * * * *

Code:

<?php
$n = 5;
for($i = 1; $i <= $n; $i++){
    for($j = 1; $j <= $n; $j++){
        if($i == 1 || $i == $n || $j == 1 || $j == $n){
            echo "* ";
        } else {
            echo "&nbsp;&nbsp;";
        }
    }
    echo "<br>";
}
?>


9. Left-Aligned Triangle

Pattern:

        *
      * *
    * * *
  * * * *
* * * * *

Code:

<?php
for($i = 1; $i <= 5; $i++){
    for($j = 1; $j <= 5 - $i; $j++){
        echo "&nbsp;&nbsp;";
    }
    for($k = 1; $k <= $i; $k++){
        echo "* ";
    }
    echo "<br>";
}
?>

10. Hollow Pyramid

Pattern:

    *
   * *
  *   *
 *     *
*********

Code:

<?php
$n = 5;
for($i = 1; $i <= $n; $i++){
    for($j = 1; $j <= $n - $i; $j++){
        echo "&nbsp;&nbsp;";
    }
    for($k = 1; $k <= (2*$i - 1); $k++){
        if($k == 1 || $k == (2*$i - 1) || $i == $n){
            echo "*";
        } else {
            echo "&nbsp;";
        }
    }
    echo "<br>";
}
?>

⭐ 11. Hollow Diamond

Pattern:

    *
   * *
  *   *
   * *
    *

Code:

<?php
$n = 3;

// upper
for($i = 1; $i <= $n; $i++){
    for($j = 1; $j <= $n - $i; $j++){
        echo "&nbsp;&nbsp;";
    }
    for($k = 1; $k <= (2*$i - 1); $k++){
        if($k == 1 || $k == (2*$i - 1)){
            echo "*";
        } else {
            echo "&nbsp;";
        }
    }
    echo "<br>";
}

// lower
for($i = $n - 1; $i >= 1; $i--){
    for($j = 1; $j <= $n - $i; $j++){
        echo "&nbsp;&nbsp;";
    }
    for($k = 1; $k <= (2*$i - 1); $k++){
        if($k == 1 || $k == (2*$i - 1)){
            echo "*";
        } else {
            echo "&nbsp;";
        }
    }
    echo "<br>";
}
?>

12. Palindrome Number Pattern

Pattern:

1
121
12321
1234321

Code:

<?php
for($i = 1; $i <= 4; $i++){
    for($j = 1; $j <= $i; $j++){
        echo $j;
    }
    for($j = $i - 1; $j >= 1; $j--){
        echo $j;
    }
    echo "<br>";
}
?>

13. Pascal’s Triangle

Pattern:

1
1 1
1 2 1
1 3 3 1

Code:

<?php
$n = 5;

for($i = 0; $i < $n; $i++){
    $num = 1;
    for($j = 0; $j <= $i; $j++){
        echo $num . " ";
        $num = $num * ($i - $j) / ($j + 1);
    }
    echo "<br>";
}
?>

14. Butterfly Pattern

Pattern:

*      *
**    **
***  ***
********
***  ***
**    **
*      *

Code:

<?php
$n = 4;

// upper
for($i = 1; $i <= $n; $i++){
    for($j = 1; $j <= $i; $j++){
        echo "*";
    }
    for($j = 1; $j <= 2*($n-$i); $j++){
        echo "&nbsp;";
    }
    for($j = 1; $j <= $i; $j++){
        echo "*";
    }
    echo "<br>";
}

// lower
for($i = $n; $i >= 1; $i--){
    for($j = 1; $j <= $i; $j++){
        echo "*";
    }
    for($j = 1; $j <= 2*($n-$i); $j++){
        echo "&nbsp;";
    }
    for($j = 1; $j <= $i; $j++){
        echo "*";
    }
    echo "<br>";
}
?>

15. Reverse Alphabet Pattern

Pattern:

E
D E
C D E
B C D E
A B C D E

Code:

<?php
for($i = 69; $i >= 65; $i--){
    for($j = $i; $j <= 69; $j++){
        echo chr($j) . " ";
    }
    echo "<br>";
}
?>


1. Current Date & Time (Using date())

<?php
date_default_timezone_set("Asia/Kolkata");

echo "Current Date: " . date("Y-m-d") . "<br>";
echo "Current Time: " . date("H:i:s") . "<br>";
echo "Full Format: " . date("d-m-Y H:i:s");
?>

Common Formats

  • Y → year (2026)
  • m → month
  • d → day
  • H → hour (24 format)
  • i → minutes
  • s → seconds

2. Using time() (Timestamp)

<?php
date_default_timezone_set("Asia/Kolkata");

$current = time();

echo "Timestamp: " . $current . "<br>";
echo "Readable Date: " . date("d-m-Y H:i:s", $current);
?>

3. Using new DateTime() (IMPORTANT)

This is the modern and most important method.

<?php
date_default_timezone_set("Asia/Kolkata");

$date = new DateTime();

echo $date->format("d-m-Y H:i:s");
?>

4. Custom Date

<?php
$date = new DateTime("2026-04-02");

echo $date->format("d-m-Y");
?>

5. Add / Modify Date

<?php
$date = new DateTime();

$date->modify("+5 days");
echo "After 5 days: " . $date->format("d-m-Y") . "<br>";

$date->modify("+1 month");
echo "After 1 month: " . $date->format("d-m-Y");
?>

6. Date Difference (Age Calculator Logic)

<?php
date_default_timezone_set("Asia/Kolkata");

$birth = new DateTime("2006-01-03");
$current = new DateTime();

$diff = $current->diff($birth);

echo "Age: " . $diff->y . " Years ";
echo $diff->m . " Months ";
echo $diff->d . " Days";
?>

7. Compare Two Dates

<?php
$d1 = new DateTime("2026-04-01");
$d2 = new DateTime("2026-04-10");

if($d1 < $d2){
    echo "d1 is earlier";
} else {
    echo "d2 is earlier";
}
?>

Important Exam Points

  • Always use:
date_default_timezone_set("Asia/Kolkata");

1. HTML Form + Display Name using PHP

<!-- form.php -->
<form method="post">
    Enter Name: <input type="text" name="username">
    <input type="submit" value="Submit">
</form>

<?php
if(isset($_POST['username'])){
    echo "Hello " . $_POST['username'];
}
?>

2. Number Programs

(a) Prime Number

<?php
$num = 7;
$flag = 1;

for($i=2; $i<$num; $i++){
    if($num % $i == 0){
        $flag = 0;
        break;
    }
}

if($flag == 1)
    echo "Prime";
else
    echo "Not Prime";
?>

(b) Odd or Even

<?php
$num = 10;

if($num % 2 == 0)
    echo "Even";
else
    echo "Odd";
?>

(c) Greatest of Three Numbers

<?php
$a = 10; $b = 25; $c = 15;

if($a >= $b && $a >= $c)
    echo "Greatest: $a";
elseif($b >= $a && $b >= $c)
    echo "Greatest: $b";
else
    echo "Greatest: $c";
?>

3. Loop Programs

(a) Reverse 10 to 1

<?php
for($i=10; $i>=1; $i--){
    echo $i . " ";
}
?>

(b) 1-2-3-...-10 (no extra hyphen)

<?php
for($i=1; $i<=10; $i++){
    if($i < 10)
        echo $i . "-";
    else
        echo $i;
}
?>

(c) Floyd Triangle

<?php
$n = 5;
$num = 1;

for($i=1; $i<=$n; $i++){
    for($j=1; $j<=$i; $j++){
        echo $num . " ";
        $num++;
    }
    echo "<br>";
}
?>

4. Continue + Arithmetic Operations

(a) Skip User Number

<?php
$skip = 5;

for($i=1; $i<=10; $i++){
    if($i == $skip)
        continue;
    echo $i . " ";
}
?>

(b) Arithmetic using Select Box

<form method="post">
    Num1: <input type="number" name="a"><br>
    Num2: <input type="number" name="b"><br>
    <select name="op">
        <option value="add">Add</option>
        <option value="sub">Subtract</option>
        <option value="mul">Multiply</option>
        <option value="div">Divide</option>
    </select>
    <input type="submit">
</form>

<?php
if(isset($_POST['op'])){
    $a = $_POST['a'];
    $b = $_POST['b'];

    if($_POST['op']=="add") echo $a+$b;
    elseif($_POST['op']=="sub") echo $a-$b;
    elseif($_POST['op']=="mul") echo $a*$b;
    elseif($_POST['op']=="div") echo $a/$b;
}
?>

5. Table + Armstrong

(a) Multiplication Table

<?php
$num = 5;

for($i=1; $i<=10; $i++){
    echo "$num x $i = " . ($num*$i) . "<br>";
}
?>

(b) Armstrong Number

<?php
$num = 153;
$sum = 0;
$temp = $num;

while($temp > 0){
    $rem = $temp % 10;
    $sum += $rem * $rem * $rem;
    $temp = (int)($temp/10);
}

if($sum == $num)
    echo "Armstrong";
else
    echo "Not Armstrong";
?>

6. Array + Table

(a) Fruit Table

<?php
$fruits = ["Apple", "Banana", "Mango"];

echo "<table border=1>";
foreach($fruits as $f){
    echo "<tr><td>$f</td></tr>";
}
echo "</table>";
?>

(b) Sum of Array

<?php
$arr = [1,2,3,4,5];
$sum = 0;

foreach($arr as $v){
    $sum += $v;
}

echo "Sum = $sum";
?>

7 & 8. Matrix + Palindrome

(a) Multiply Number with Matrix

<?php
$matrix = [
    [1,2],
    [3,4]
];

$num = 2;

for($i=0; $i<2; $i++){
    for($j=0; $j<2; $j++){
        echo $matrix[$i][$j] * $num . " ";
    }
    echo "<br>";
}
?>

(b) Palindrome String

<?php
$str = "malayalam";

if($str == strrev($str))
    echo "Palindrome";
else
    echo "Not Palindrome";
?>

9. Registration Form + Display Data

<form method="post">
    Name: <input type="text" name="name"><br>
    Email: <input type="text" name="email"><br>
    <input type="submit">
</form>

<?php
if(isset($_POST['name'])){
    echo "Name: " . $_POST['name'] . "<br>";
    echo "Email: " . $_POST['email'];
}
?>

10. Login (Username + Password Check)

<form method="post">
    Username: <input type="text" name="user"><br>
    Password: <input type="password" name="pass"><br>
    <input type="submit">
</form>

<?php
if(isset($_POST['user'])){
    if($_POST['user']=="admin" && $_POST['pass']=="godsgift"){
        echo "Welcome Admin";
    } else {
        echo "Invalid Login";
        header("refresh:2; url=");
    }
}
?>