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
| class CurlHelper | |
| { | |
| static function get($url, $params = [], $timeout = 60) | |
| { | |
| $paramsJoined = array(); | |
| foreach($params as $param => $value) { | |
| $paramsJoined[] = "$param=$value"; | |
| } |
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
| function allUrlParams(url) { | |
| var url = decodeURIComponent(url); | |
| var paramsPart = url.split('?')[1]; | |
| if (!paramsPart) | |
| return {}; | |
| var params = paramsPart.split('&'); | |
| var pairs = {}; | |
| for (var i = 0; i < params.length; i++) { |
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
| A:link { text-decoration: none; } | |
| A:visited { text-decoration: none; } | |
| A:active { text-decoration: none; } | |
| A:hover { text-decoration: none overline; } |
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
| $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); | |
| fwrite($myfile, print_r($data, true)); | |
| fclose($myfile); |
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
| function openInNewTab(url) { | |
| var win = window.open(url, '_blank'); | |
| win.focus(); | |
| } |
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 _data = []; | |
| const UserStore = { | |
| add: item => _data.push(item), | |
| get: id => _data.find(d => d.id === id) | |
| } | |
| Object.freeze(UserStore); | |
| export default UserStore; |
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
| // From StackOverflow: | |
| // https://stackoverflow.com/questions/9461621/how-to-format-a-number-as-2-5k-if-a-thousand-or-more-otherwise-900-in-javascrip | |
| function nFormatter(num, digits) { | |
| var si = [ | |
| { value: 1E18, symbol: "E" }, | |
| { value: 1E15, symbol: "P" }, | |
| { value: 1E12, symbol: "T" }, | |
| { value: 1E9, symbol: "G" }, | |
| { value: 1E6, symbol: "M" }, |
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
| // getUrlParam('http://test.com?a=1', 'a') // return 1 | |
| function getUrlParam(urlString, param) { | |
| const url = new URL(urlString); | |
| return url.searchParams.get(param); | |
| } |
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
| // getLastUrlSegment('https://vk.com/ibizunov') // return 'ibizunov' | |
| function getLastUrlSegment(url) { | |
| const parts = url.split('/'); | |
| return lastSegment = parts.pop() || parts.pop(); | |
| } |
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
| // checkDomain('https://www.instagram.com/bizunow/', 'www.instagram.com') // === true | |
| // checkDomain('https://www.google.ru/', 'www.instagram.com') // === false | |
| // checkDomain('Test test test', 'www.instagram.com') // === false | |
| function checkDomain(url, domain) { | |
| var a = document.createElement('a'); | |
| a.href = url; | |
| return a.hostname == domain; | |
| } |