Posts

Showing posts with the label Code

Get request ip address using express in Nodejs

Image
Get request ip address using express in Nodejs Here’s the way to get the x-forward-for head var ip = req . headers [ 'x-forward-for' ] make sure all the keyword is lower case!! It took me half a day to find this mistake. Result: Reference https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node https://flaviocopes.com/express-headers/

Python Pandas little tips with the Lambda Function

Image
Python Pandas little tips with the Lambda Function Pandas Pandas is a useful tool for data science because we can use this tool to analyze, visualize & manipulate data stored within data sets, or in coding terms, within data frames. Python Lambda A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. Here’s a little tips that we can using lambda to do some easy data process on dataframe: x = [ 176 , 166 , 156 , 186 ] df = pd . DataFrame ( { 'height' : x } ) df [ 'inch' ] = df [ 'height' ] . apply ( lambda x : x / 2.54 ) df Reference https://www.w3schools.com/python/python_lambda.asp

Convert a shell script into an executable binary

Image
Convert a shell script into an executable binary This article will help you to create binary file of your shell script, so no one can see the source code of your script and we can use them as a command. To create binary file from a script we use SHC compiler written by Francisco Javier Rosales GarcĂ­a . Shell Script Compiler (SHC) 1. Download shc and install it $ wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz $ tar xvfz shc-3.8.7.tgz $ cd shc-3.8.7 $ make 2. Verify that shc is installed properly. $ ./shc -v shc parse ( -f ) : No source file specified shc Usage: shc [ -e date ] [ -m addr ] [ -i iopt ] [ -x cmnd ] [ -l lopt ] [ -rvDTCAh ] -f script 3. Create a Sample Shell Script $ vi test.sh #!/bin/bash need to put at the beginning of a script file. #!/bin/bash echo -n "Test" 4. Create Binary of Script $ ./shc -T -f test.sh -T : this will allow the created binary files to be traceable using programs like strace...

Add Code Syntax Highlight on Blogger

Image
Add Code Syntax Highlight on Blogger Add addition code at header Add these code to the end of the theme header <!-- Syntax Highlighter Additions START --> < link href = " https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCore.min.css " rel = " stylesheet " type = " text/css " /> < link href = " https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shThemeEmacs.min.css " rel = " stylesheet " type = " text/css " /> < script src = " https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.min.js " type = " text/javascript " /> < script src = "https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shAutoloader.min.js" type = "text/javascript" / > < script src = "https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/sh...