જરાસંધ

ભગવાન કૃષ્ણે જરાસંધના જન્મની વાત પણ ટૂંકાણમાં કહી સંભળાવી : 'મહાતપસ્વી ચંડકૌશિક નામના ઋષિએ જરાસંધના નિઃસંતાન પિતાને એક આમ્રફળ આપતાં કહ્યું હતું કે આ ફળ તારી રાણીને ખવરાવીશ એટલે એને મહાબળવાન પુત્ર થશે!

‘રાજાને બે રાણીઓ હતી. બેઉ રાણીઓ એકસરખી પ્રિય હતી. કેરી એણે બેઉ રાણીઓને અડધી અડધી ખવરાવી. સમય જતાં બન્ને રાણીઓને પ્રસવ થયો. પણ બન્યું એવું કે બન્ને રાણીએ અડધું અડધું બાળક એટલે કે એક હાથ એક પગ એ રીતે અક્કેકા ફાડિયાને જન્મ આપ્યો.

‘આનું કારણ રાજા તરત જ પામી ગયો ! પણ હવે શું ? પોતાના તકદીર ઉપર વિલાપ કરતાં દાસીઓને કહ્યું: “ફેંકી દો આ બન્ને ફાડિયાં.”

'દાસીઓએ ફાડિયાં મહેલની પાછળ આવેલી બારી વાટે ફેંકી દીધાં. આ સ્થળની નજીકમાં જ એક જરા નામની રાક્ષસી રહેતી હતી. એણે કશુંક મહેલ ઉપરથી પડતું જોયું. ત્યાં જઈને જુએ છે તો બાળકનાં બે ફાડિયાં હતાં ! રાક્ષસી તો નવજાત શિશુનું કૂણું કૂણું માંસ જોઈને રાજી રાજી થઈ ઊઠી. પછી એણે પોતાના નિવાસ પર જઈને ખાવાના ઇરાદા સાથે બેઉ ફાડિયાં ભેગાં કર્યાં. આ સાથે ચમત્કાર થયો. ફાડિયાં સંધાઈ ગયાં ને બાળકના રુદનનો અવાજ ઊઠ્યો. રાક્ષસીને થયું કે આ બાળક રાજાને પાછું આપીશ તો એ મને સદાને માટે માંસનો આહાર બાંધી આપશે.

'રાક્ષસીની ધારણા સાચી પડી. પોતાના જ આ બાળકને જીવતું થયેલું જોઈને રાજારાણીઓના આનંદનો પાર ન રહ્યો. રાજાએ પેલી રાક્ષસીને રોજના ભક્ષ તરીકે દરરોજ એક પશુ આપવાનો અમલદારોને હુકમ કરી જરા રાક્ષસીને ખુશ કરીને વિદાય આપી ને નગરમાં પછી છ દિવસનો મહોત્સવ મંડાયો...." ને પાંડવો તરફ નજર ફેરવી કૃષ્ણે વાત પૂરી કરી : "આ રીતે જરા નામની રાક્ષસીથી સંધાયેલા જરાસંધમાં રાક્ષસી બળ અને ગુણો હોય એ સ્વાભાવિક છે."

~ પાર્થને કહો ચડાવે બાણ - 3 માંથી, પન્નાલાલ પટેલ

Window in X11

In this article, we are going to create a simple X11 program that display a window. This is the first in the series of articles on X11 and GUI in general.

You need X11 development libraries in order to follow these articles. Go ahead and install the lib based on your distro and/or package manager. As we are going to write the code in C, GCC - a C compiler is needed. Install that one as well.

Go ahead and create a file with the name wm.c (wm - window manager) and write the following code.

#include <stdio.h>

int main(void) {
    printf("hello, world\n");

    return 0;
}

Run the following command to compile and execute the program.

gcc wm.c -o wm && ./wm

You should see "hello, world" as the output.

In order to create a window in X11, we first need to make a connection to the display. To create a connection, XOpenDisplay() function is used. You can pass the name of the display to this function. But, you don't have to. Just pass the NULL value and rest is taken care by XOpenDisplay() function. When you call XOpenDisplay() two things can happen - On success it'll return a pointer to the display or on failure you won't get anything. If we get the pointer as a connection to display, we should save it into the variable of type Display. But, if it fails, we need to terminate the program as if we don't have a connection to display, how should we render a window and interact with it?!

XOpenDisplay() function is declared in the X11/Xlib.h header file. So, we need to include this header file in order to use the XOpenDisplay() function.

Let's update the wm.c program with what we just discussed.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    return 0;
}

In X11, display doesn't mean a single monitor or the screen. If you have multiple screens attached to a single computer and you can interact with the same keyboard and/or mouse with all the screens, you still have a single display. As official definitions says,

"In X11, display is defined as a workstation consisting of a keyboard, a pointing device such as mouse, and one or more screens. Multiple screens can work together, with mouse movement allowed to cross physical screen boundaries. As long as multiple screens are controlled by single user with single keyboard and pointing device, they comprise only a single display."

As we can have multiple screens, we need to select the screen on which we need to display our window. For that, we need to call the DefaultScreen() function and pass the display connection to this function call. This function returns a screen number (int) on which we can display a window later on.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    return 0;
}

We are now ready to create a window. We need to call the XCreateSimpleWindow() function to create a window. We need to pass NINE arguments to this function call - a display, a root window, x, y (as coordinate), width, height (dimensions), border width, border color, background color (of window). On successful call, this function returns a window of type Window. Let me call this function by passing the values to it and then we can discuss again.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window window = XCreateSimpleWindow(
           display,
           RootWindow(display, screen),
           100, 100,                        // x, y
           400, 200,                        // width, height
           1,                               // border width
           BlackPixel(display, screen),     // border color
           WhitePixel(display, screen)      // background color
    );

    return 0;
}

Every window in X11 always has a parent window (except the root window) as windows in X11 are always in hierarchy form. To make this hierarchy form, we need to add a parent of this window. We can fetch the root or parent window using the RootWindow() function. This function accepts display and screen as the two arguments. x and y are the position of the window. In X11, the (0, 0) starts from the top-left corner. Then we defined the size of the window as width and height in pixels. We also need to tell the border width and color of the window which are 1 and black respectively. Finally, the background of the window is white that you should see when we run the program and render the window on screen. BlackPixel() and WhitePixel() are the macros that return default black and white color on the specified screen (more on this in future articles).

We can simplify this XCreateSimpleWindow() function call by putting these functions outside as follows.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window root = RootWindow(display, screen);

    unsigned long black = BlackPixel(display, screen);
    unsigned long white = WhitePixel(display, screen);

    Window window = XCreateSimpleWindow(
           display, 
           root,
           100, 100,
           400, 200,
           1,
           black,
           white
    );

    return 0;
}

I've also removed the comments as explanation is provided.

XCreateSimpleWindow() creates a window. But, creating a window is not enough. We need to display it or as X11 says, we need to map it. To map it, we need to call the XMapWindow() function. This function accepts the display and a window that we want to map.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window root = RootWindow(display, screen);

    unsigned long black = BlackPixel(display, screen);
    unsigned long white = WhitePixel(display, screen);

    Window window = XCreateSimpleWindow(
           display, 
           root,
           100, 100,
           400, 200,
           1,
           black,
           white
    );

    XMapWindow(display, window);

    return 0;
}

Finally (not actually), we need to close the display connection right before the return statement to free the memory once we are done with the program using the XCloseDisplay() function. This function accepts a display that we are interested in closing.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window root = RootWindow(display, screen);

    unsigned long black = BlackPixel(display, screen);
    unsigned long white = WhitePixel(display, screen);

    Window window = XCreateSimpleWindow(
           display, 
           root,
           100, 100,
           400, 200,
           1,
           black,
           white
    );

    XMapWindow(display, window);

    XCloseDisplay(display);

    return 0;
}

We are ready to run our program. But, we need to tweak that previous command, in order to include the X11 header in the compilation process.

gcc wm.c -lX11  -o wm && ./wm

The program compiles and executes but nothing happens! I mean we are supposed to see a window with white background. But, we didn't see it. Actually, we need to keep a program or window running in order to see the window and interact with it. How about having an infinite while loop?

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window root = RootWindow(display, screen);

    unsigned long black = BlackPixel(display, screen);
    unsigned long white = WhitePixel(display, screen);

    Window window = XCreateSimpleWindow(
           display, 
           root,
           100, 100,
           400, 200,
           1,
           black,
           white
    );

    XMapWindow(display, window);

    while (1) {

    }

    XCloseDisplay(display);

    return 0;
}

Perfect! Within this while loop, we can write custom code against the interaction. For example, close the window if the user presses any key from the keyboard. In order to do such interaction, we need to listen for input events such as KeyPress event. We need to call the XSelectInput() function to register the type of events we are interested in listening to. This function accepts three arguments - display, a window, and event (e.g. KeyPressMask in our scenario). Let's write this before we map the window as we need to register everything needed for the window before we display it on the screen.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window root = RootWindow(display, screen);

    unsigned long black = BlackPixel(display, screen);
    unsigned long white = WhitePixel(display, screen);

    Window window = XCreateSimpleWindow(
           display, 
           root,
           100, 100,
           400, 200,
           1,
           black,
           white
    );

    XSelectInput(display, window, KeyPressMask);

    XMapWindow(display, window);

    while (1) {

    }

    XCloseDisplay(display);

    return 0;
}

Now, we can check for the event in a loop. XNextEvent() will loop for the event. It accepts two arguments - display and address of the event as a type of XEvent. It can then have a type that we can compare against e.g. KeyPress.

#include <stdio.h>
#include <X11/Xlib.h>

int main(void) {
    Display* display = XOpenDisplay(NULL);

    if (!display) {
       fprintf(stderr, "Unable to open X display\n");
       return 1;
    }

    int screen = XDefaultScreen(display);

    Window root = RootWindow(display, screen);

    unsigned long black = BlackPixel(display, screen);
    unsigned long white = WhitePixel(display, screen);

    Window window = XCreateSimpleWindow(
           display, 
           root,
           100, 100,
           400, 200,
           1,
           black,
           white
    );

    XSelectInput(display, window, KeyPressMask);

    XMapWindow(display, window);

    XEvent event;
    while (1) {
        XNextEvent(display, &event);

        if (event.type == KeyPress) {
            break;
        }
    }

    XCloseDisplay(display);

    return 0;
}

I wrote the XNextEvent() function within a loop as we continuously look for the event or interaction while our program is running. Currently, we are just listening for key presses but in future, we'll listen for many other types of interaction such as, mouse interaction, window map or unmap interaction, etc.

We are now ready to re-run the program again. This time you should see a window and will close on any key-press.

The article is long enough. I want you to take a break before we continue adding more code in this program. See you in the next article!

साधनाक्षेत्र

'तत्त्वालोचना की दृष्टि से मनुष्य शरीर में अलग-अलग तीन खंड हैं। मूलाधार से आज्ञाचक्र पर्यन्त जो षट्चक्र हैं, यहाँ तक कि ऊर्ध्व में सहस्त्रारचक्र तक भी, प्रथम खंड के अंतर्गत है। इसके बाद व्यापक शून्य का अनुभव होता है। इस शून्य को भेद कर सकने पर देह के द्वितीयखंड में प्रवेश हो सकता है। इस द्वितीयखंड के प्रवेश के साथ ही साथ अति विशाल तेजपुंज का साक्षात्कार होता है। यह प्रकाश कोटि-कोटि सूर्य की सम्मिलित प्रभा से भी कहीं अधिक दीप्तिमान है। कोई-कोई साधक सहस्त्रार भेद करके, यहाँ तक कि तदतीत शून्य को भी भेद करके, इस महातेज के भीतर जाकर लीन हो जाते हैं, अर्थात् इसको भेद नहीं कर पाते।
 

इस तेज में प्रवेश करने पर पता चलता है कि इसमें तीन पृथक् पृथक् विभाग हैं। पहले विभाग का नाम 'अक्षर' है। यह भी एक प्रकार शून्य ही है। द्वितीय विभाग का नाम 'निरक्षर' है-इसका स्वरूप महाशून्य है। इस मार्ग में आगे बढ़ने पर 'सहजपथ' मिलता है, तब 'अचिंत्य-परब्रह्मपद' की प्राप्ति होती है। जो लोग 'अक्षर-भूमि' में रहते हैं, उनकी स्थिति शून्य में ही होती है। परन्तु जो भाग्यवान हैं वे 'निरक्षर-भूमि' में जा सकते हैं और 'अचिन्त्य परब्रह्मपद' तक उठते हैं। इसके बाद और कोई मार्ग नहीं है। परंतु 'निरक्षर' से भी अतीतावस्था है। अगर कोई वहाँ तक जा सके तो उसको पहले 'सत्यलोक' मिलता है, उसके बाद 'कुमार लोक' और अंत में 'उमालोक'। यहीं तक ऊर्ध्वगति हो सकती है। इनके अनंतर और कहीं जाने के मार्ग का पता नहीं चलता।'

(related: કુંડલિની જાગૃત ≠ સમાધિ

~ सीतारामदास बाबा, मनीषी की लोकयात्रा

સંસારી સંન્યાસી

શ્યામાચરણે પૂછયું કે સાંસારિક કાર્યવ્યસ્તતા વચ્ચે કઠોર સાધના કેવી રીતે કરી શકાશે એ વાત તેમને માટે અસંભવ જેવી પ્રતીત થઈ રહી છે. તેને માટે સમય ક્યાં મળશે?

બાબાજીએ કહ્યું : “ના, શ્યામાચરણ તમે ગૃહસ્થીમાં જઈ તો જુઓ. તમને ઘણો સમય મળશે. સમયાનુસાર તમારી બદલી કાશીમાં થઈ જશે અને તમે સુખી રહેશો. તમે સ્વયં ગૃહસ્થ જીવનમાં રહીને જ સાધના દ્વારા સિધ્ધિ પ્રાપ્ત કરશો ત્યારે તમારા આદર્શોનો સંસારીઓ સ્વીકાર કરશે. એ પણ જાણી લો કે કોઇ સંસારને ત્યાગી નથી શકતું. તેનાથી કોઈ કદી અલગ રહી નથી શકતું. મનુષ્ય ચાહે ત્યાં રહે, સંસાર તેની સાથે રહેશે. તે સિવાય સાંસારિક લોકોએ જ આ દુનિયાને આટલી સુંદર બનાવી રાખી છે, આટલો વૈભવવિલાસ આપી રાખ્યો છે. એ ન હોત તો પૃથ્વી આટલી સુંદર ન હોત. સાંસારિક જીવનને અભાવે ઇશ્વરની સૃષ્ટિ નષ્ટ થઈ જાત. બધા આ સંસારમાં જન્મ લે છે. ઈશ્વરની સાધના કેવળ સંસારત્યાગી કે વિરક્ત લોકોને માટે ન હોઇ શકે. જુઓ, હું સંન્યાસી હોવા છતાં જે પાત્રમાં જળ પીઉં છું તે પણ સંસારી વ્યક્તિનું જ બનાવેલું છે.” દયાશીલ બાબાએ વધુમાં કહ્યું: “આજે સંસારી મનુષ્ય ઇશ્વરસાધનાના વિષયમાં સાવ નિરુપાય છે. તમે સ્વયં સંસારમાં રહીને તેમને સાચો રસ્તો દેખાડશો. ભયની કોઈ વાત નથી, તમે ઘેર પાછા જાઓ. યથાસમયે અવારનવાર તમે મને જોઈ શકશો અને જ્યારે પણ તમે મને જોવાની ઇચ્છા કરશો, જોઈ શકશો. સંસારમાં સદ્દગૃહસ્થોની પ્રતિષ્ઠા થાય.” ત્યાર બાદ બાબાજીએ પાસે બેઠેલા થોડા લોકો તરફ સંકેત કરતાં કહ્યું : “તમારે આ લોકોને દીક્ષા આપવી પડશે. તમારે માટે જ આટલા દિવસ સુધી એમને રોકી રાખ્યા છે.”

~ પુરાણ પુરુષ યોગીરાજ શ્રી શ્યામાચરણ લાહિરી 

Button - Elementary - EFL

Description

This is a push-button. Press it and run some function. Button can have text, icon and text, or icon only. This widget inherits from the Layout widget. So that all the functions acting on Layout widget also work for Button widget.

Default content parts of the button widget that you can use for are:

"icon"
An icon of the button

Default text parts of the button widget that you can use for are:

"default"
A label of the button

Screenshots

Examples

#include <Elementary.h>

static void _on_delete_request(void* data, Evas_Object* obj, void* event_info) {
  elm_exit();
}

static void _on_btn_clicked(void* data, Evas_Object* obj, void* event_info) {
  const char* name = data;
  printf("%s clicked\n", name);
}

int main(int argc, char* argv[]) {
  elm_init(argc, argv);

  // Window
  Evas_Object* win = elm_win_util_standard_add("btns", "btns");
  elm_win_autodel_set(win, EINA_TRUE);
  evas_object_smart_callback_add(win, "delete,request", _on_delete_request, NULL);
  evas_object_resize(win, 300, 300);

  // Box
  Evas_Object* box = elm_box_add(win);
  evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
  elm_win_resize_object_add(win, box);
  evas_object_show(box);

  // Button
  Evas_Object* btn1 = elm_button_add(win);
  elm_object_text_set(btn1, "Button");
  evas_object_size_hint_weight_set(btn1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  evas_object_size_hint_align_set(btn1, EVAS_HINT_FILL, EVAS_HINT_FILL);
  evas_object_smart_callback_add(btn1, "clicked", _on_btn_clicked, "Button");
  elm_box_pack_end(box, btn1);
  evas_object_show(btn1);

  // Icon + Button
  Evas_Object* btn2 = elm_button_add(win);
  elm_object_text_set(btn2, "Button");

  Evas_Object* icon1 = elm_icon_add(win);
  elm_icon_standard_set(icon1, "go-home");
  evas_object_show(icon1);

  elm_object_part_content_set(btn2, "icon", icon1);

  evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  evas_object_size_hint_align_set(btn2, EVAS_HINT_FILL, EVAS_HINT_FILL);
  evas_object_smart_callback_add(btn2, "clicked", _on_btn_clicked, "Button 2");
  elm_box_pack_end(box, btn2);
  evas_object_show(btn2);

  // Icon
  Evas_Object* btn3 = elm_button_add(win);

  Evas_Object* icon2 = elm_icon_add(win);
  elm_icon_standard_set(icon2, "go-home");
  evas_object_show(icon2);

  elm_object_part_content_set(btn3, "icon", icon2);

  evas_object_size_hint_weight_set(btn3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  evas_object_size_hint_align_set(btn3, EVAS_HINT_FILL, EVAS_HINT_FILL);
  evas_object_smart_callback_add(btn3, "clicked", _on_btn_clicked, "Icon Button");
  elm_box_pack_end(box, btn3);
  evas_object_show(btn3);

  evas_object_show(win);
  
  elm_run();
  elm_shutdown();

  return 0;
}

Heirarchy

+---------+
| widget  |
+---------+
     |
     v
+-----------+
| container |
+-----------+
     |
     v
+--------+
| layout |
+--------+
     |
     v
+--------+
| button |
+--------+

Signals

clicked
Emitted when button is clicked (pressed and released).

pressed
Emitted when `button` is pressed.

unpressed
Emitted when button is released after being pressed.

focused (since 1.8)
Emitted when button has received focus.

unfocused (since 1.8)
Emitted when button has lost focus.

repeated
Emitted when button is pressed without releasing it.

Following are the signals inherited from Layout widgets.

"theme,changed"
Emitted when theme is changed.

"language,changed"
Emitted when application's language changed.

Styles

Defined in the default theme, the button has the following styles available:

default
A normal button.

anchor
Like default, but the button fades away when the mouse is not over it, leaving only the text or icon.

hoversel_vertical (internal)
Internally used by Hoversel to give a continuous look across its options.

hoversel_vertical_entry (internal)
Another internal for Hoversel.

naviframe (internal)
Internally used by Elm_Naviframe for its back button.

colorselector (internal)
Internally used by Colorselector for its left and right buttons.

Constructors

elm_button_add
Add a new button to the parent's canvas.

Functions

elm_button_autorepeat_initial_timeout_set
Sets the initial timeout before the autorepeat event is generated.

elm_button_autorepeat_initial_timeout_get
Gets the initial timeout before the autorepeat event is generated.

elm_button_autorepeat_gap_timeout_set
Sets the interval between each generated autorepeat event.

elm_button_autorepeat_gap_timeout_get
Gets the interval between each generated autorepeat event.

elm_button_autorepeat_set
Sets the autorepeat event generated when the button is kept pressed.

elm_button_autorepeat_get
Gets the autorepeat event generated when the button is kept pressed.

Following are the functions inherited from the Container class.

elm_object_part_text_set
Sets the text of an object.

elm_object_part_text_get
Gets the text of an object.

elm_object_part_content_set
Set the content on part of a given container widget.

elm_object_part_content_get
Get the content on part of a given container widget.

elm_object_part_content_unset
Unsets the content on a part of a given container widget.

elm_object_signal_emit
Sends the signal to the widget.

elm_object_signal_callback_add
Adds the callback for a signal emitted by widget.

elm_object_signal_callback_del
Removes a signal-triggered callback from a widget.

इच्छा

सृष्टि के मूल में है इच्छा। एक दृष्टांत लो। कुम्हार ने घटादि बनाने के लिए कुलाल चक्र को घुमा दिया। थोड़ी सी मिट्टी का पिड है और उस पर उसने हाथ लगा रखा है। कैसा आश्चर्य है! हाथ हिलता नहीं और कुम्हार की इच्छा के अनुसार कभी घड़ा, कभी सकोरा और कभी हाँड़ी तैयार हो जाती है। इच्छा से ही सब होता है। उपादान तो नित्य ही है सत् अथवा सत्ता, कालचक्र घूम ही रहा है, अब केवल इच्छा ही उत्पत्ति का नियामक है।

यह बात याद रखनी चाहिए कि इच्छा ही बीज है। जो इच्छा करोगे वही होगा, निश्चय ही होगा। आज नहीं तो कल। इच्छा का नाश नहीं होता। एक बार जो इच्छा की गयी, तत्काल वह अनंत में चित्रित हो गयी। समय आने पर फूटकर बाहर निकल आयेगी। मान लो तुम्हें आज घास खाने की इच्छा हुई अतएव तुम्हें एक ऐसा शरीर धारण करना पड़ेगा जिससे घास खाने की इच्छा पूर्ण हो सकती है। ऐसा शरीर धारण किये बिना वह इच्छा अतृप्त रह जायगी। जिस प्रकार की इच्छा होती है शरीर भी उसी प्रकार का धारण करना पड़ता है, चाहे वह देव शरीर हो, मानव शरीर हो या तिर्यक् शरीर। शरीर धारण किये बिना काम नहीं चल सकता। एक कथा है-
 

एक बार बुद्धदेव का एक भक्त अत्यंत भक्तिपूर्वक गुरुदेव के लिए सूअर का मांस तैयार करके उनके आगमन की प्रतीक्षा में बैठा था। सारा दिन बीत गया, संध्या हो गयी परंतु गुरुदेव नहीं आये। संध्या के समय एक कुत्ते ने आकर उस मांस में जो भगवान् के लिए यत्नपूर्वक रखा गया था, मुँह डाल दिया तथा उसमें से कुछ खा भी लिया। भक्त ने देखते ही कुत्ते को भगा दिया। परंतु उस दिन बुद्धदेव नहीं पधारे। दूसरे दिन उसने जाकर बुद्धदेव से सब वृत्तांत कहा और यह भी प्रकट किया कि आपके न पधारने से मेरे हृदय में बड़ा ही दुःख हुआ था। बुद्धदेव ने कहा "मैं तो कल गया था और मैंने तुम्हारे भोग को ग्रहण भी किया था। तुम मुझे पहचान नहीं सके। कल क्या तुमने एक कुत्ता नहीं देखा, मैं ही कुत्ते का शरीर धारण करके गया था। तुमने मेरे लिए जिस प्रकार का भोग रखा था, उसके अनुरूप देह धारण करके ही मैं गया था।" अतएव समझना चाहिए कि सब शरीरों में सब प्रकार के भोग नहीं हो सकते।
 

इच्छा की तृप्ति हुए बिना मुक्ति नहीं होती। जब तक एक भी वासना अतृप्त रहेगी, तब तक मुक्ति असंभव है। 

~ मनीषी की लोकयात्रा 

Let's Build Peter Pt. 4

Since the backend is working, we can now start using the middleware packages we installed earlier.

Let's begin with morgan.

import express from "express";
import morgan from "morgan";

const app = express();

app.use(morgan("tiny"));

app.get("/ping", (req, res) => {
    return res.json({ data: "pong" });
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`http://localhost:${PORT}`);
});

Now that logging is in place, the next middleware we will configure is cors. We will whitelist the React application's URL: http://localhost:5173.

import express from "express";
import morgan from "morgan";
import cors from "cors";

const app = express();

app.use(morgan("tiny"));
app.use(
    cors({
        origin: "http://localhost:5173",
    }),
);

app.get("/ping", (req, res) => {
    return res.json({ data: "pong" });
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`http://localhost:${PORT}`);
});

Finally, let's add helmet and compression.

import express from "express";
import morgan from "morgan";
import cors from "cors";
import helmet from "helmet";
import compression from "compression";

const app = express();

app.use(morgan("tiny"));
app.use(
    cors({
        origin: "http://localhost:5173",
    }),
);
app.use(helmet());
app.use(compression());

app.get("/ping", (req, res) => {
    return res.json({ data: "pong" });
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`http://localhost:${PORT}`);
});

Perfect! Now visit http://localhost:3000/ping. It should return the same output as before. However, this time you will also see the request being logged in the terminal.

Yes — it’s working for me 👍

Now is a good time to open Insomnia (or any other API client). Send a request to the same endpoint and confirm that you receive: { "data": "pong" }

Cleaning Up the Frontend

On the frontend side, let’s clean up the scaffolded application:

  • Remove the public folder
  • Remove the src/assets folder
  • Remove the App.css file

After cleaning up, your folder structure should look minimal and clean.

Now open the App.jsx file and replace its content with the following:

const App = () => {
    return <h1>hello, world</h1>;
};

export default App;

Run the React application using:

npm run dev

Within a few seconds, the application should be available at: http://localhost:5173. Visit the URL and confirm that you see: hello, world.

Both applications are now running — yay! 🎉