This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const toFirstUpperRestLowerCase = (str) => { | |
| return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); | |
| }; | |
| const s = 'POINT'; | |
| console.log(toFirstUpperRestLowerCase(str)); //Point |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| const crypto = require('crypto'), | |
| hash = crypto.createHash('md5'); | |
| const uniqid = (prefix = '') => { | |
| return `${prefix}${hash.update(Date.now().toString()).digest('hex')}`; | |
| }; | |
| console.log(uniqid('Example_Prefix-')); //Example_Prefix-d6caf083d4676ec0f2cf2a9a3b2b3020 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const c = "A?A,V V,F2F, MM".replace( /[^A-Z,]/g, ''); | |
| console.log(c); //AA,VV,FF,MM | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let s= "AA,VV,FF,".replace( /,+$/, ''); | |
| console.log(s); //AA,VV,FF | |
| let x = "AA,VV,FF,,".replace( /,+$/, ''); | |
| console.log(x); //AA,VV,FF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //sync | |
| try{ | |
| fs.statSync('../testing'); | |
| }catch(e){ | |
| console.log(e.message);//ENOENT: no such file or directory, stat '../testing' | |
| } | |
| //async | |
| fs.stat('../testing', function(err, res){ | |
| if(err){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function is_json($value = null){ | |
| $ret = true; | |
| if(null === @json_decode($value)){ | |
| $ret = false; | |
| } | |
| return $ret; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $data = preg_replace('/\x0a+/', "\x0a", $data); |