About phptuts

Author Archive | phptuts

Install node-gyp on Windows

How to Install node-gyp on Windows Step 1: Step 2: Step 3: Microsoft .NET Framework 4.5.1 Step 4: Visual C++ 2015 Build Tools Choose Custom Install, and select Windows 8.1 or Windows 10 SDKs.(depends on your windows) Optionnal: If you have many python version you can use this command to specific version of python to […]

Read full story Comments { 0 }

PHP function ord of unicode character

Read more: PHP function chr of unicode character We have 6 methods: Example: echo uniord(“♥”); //9829 echo “”; echo uniord2(“❤”); //10084 echo “”; echo uniord3(“❥”); //10085 echo “”; echo uniord4(“❦”); //10086 echo “”; echo uniord5(“❧”); //10087 echo “”; echo uniord6(“❧”); //10087

Read full story Comments { 0 }

simplest Hash algorithm Javascript

Requirements: PHP function pack in Javascript PHP function str_split in Javascript PHP unpack function in Javascript Example: Result: Try it yourself update new version: https://jsfiddle.net/sans_amour/ng74y9re/1/ Read more: this method in PHP language: simplest Hash algorithm PHP

Read full story Comments { 0 }

simplest Hash algorithm PHP

Example: Result:

Read full story Comments { 0 }

PHP function pack in Javascript

Example: Result: Try it yourself

Read full story Comments { 0 }

PHP function str_split in Javascript

PHP function str_split in Javascript (method of locutus.io) Method of locutus.io can work with ASCII string, but with non-ASCII string (like UTF8 string), this doesn’t work successfully! Example: Result: But result in PHP: We can use the method in this artice: Javascript: read ASCII characters from Unicode string, now we write own method: Try it […]

Read full story Comments { 0 }

PHP unpack function in Javascript

The method based on locutus.io: Example: Result: Try it yourself

Read full story Comments { 0 }

Javascript: read ASCII characters from Unicode string

Quick ASCII characters reference: JavaScript stores strings as UTF-16 (double byte) > “\u{2122}” “™” > “\u2122” “™” > “\u{1f4ab}” “💫” > “\uD83D\uDCAB” “💫” If you use method String.charCodeAt, you will get UTF-16 code, not ASCII code: > “™”.charCodeAt(0) 8482 > “💫”.charCodeAt(0) 55357 > “💫”.charCodeAt(1) 56491 > “💫”.codePointAt(0) 128171 So if you want to read ASCII […]

Read full story Comments { 0 }

Node.js: how to fix error server error at Socket.onPacket

How to fix Node.js client connect_error: Main raison is mismatched versions of socket.io in client and server. You can choose the match JS client library at: https://cdnjs.com/libraries/socket.io or use /socket.io/socket.io.js on your server eg: https://ws.tutorialspots.com:31111/socket.io/socket.io.js

Read full story Comments { 0 }

Node.js: how to stream a mp4 file

How to stream a mp4 file with Node.js Run test Note: fs.statSync will throw an error if file not exists: So, you should use try catch clause to catch this error:

Read full story Comments { 0 }