Posts

Showing posts with the label server side

The Windows equivalents of the most used Linux commands

Whether it is to pipe the Tcpdump output to another machine hosting Wireshark or checking which service is listening on which port, Windows cmd has similar commands that are present in Linux. Here is some of the most command used in Linux that have equivalent purpose on Windows: Filtering the output of a commande: Linux:   lsof -s | grep 'https' Windows:   netstat -n -a | findstr "https"   (//note the double quotes) Piping tcp dump to another machines that hosts Wireshark Author's note:  From here on, the content is AI-generated Linux:   ssh root@remote-linux "tcpdump -s 0 -U -n -w - -i eth0 not port 22" | wireshark -k -i - Windows:   ssh root@remote-linux "tcpdump -s 0 -U -n -w - -i eth0 not port 22" | "C:\Program Files\Wireshark\wireshark.exe" -k -i -   (//note that Windows 10 and 11 come with a native SSH client built into cmd!) Checking which service is listening on which port Linux:   netstat -tulpn Windows:   netstat -ano   (//n...

How to use a Python variable in an external Javascript (Django)

2025 Update: Check a security note below! One way to use a Python variable in an external Javascript is to declare the JS variable in the HTML template through context object, then pass this variable to the external script code : <script type="text/javascript"> js_var_from_dj = "{{ django_var }}" </script> <script src="{% static "js/js_file.js" %}" type="text/javascript"></script>   js_file.js : function functionA(){ // using the variable declared outside this js file inner_js_var = js_var_from_dj ; }   What if  instead of using HTML template to pass the Django context variable, we inject the variable directly into the external Javascript code ?  This is actually possible, the trick here is to to wrap the original JS file in a View, and use that view to render the JS file as a Django template. O ur js_file become : function functionA(){    //using the Django context variable    inner_js_var = {{django_var}} ; ...