This file contains 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
[ | |
{ | |
"name": "Afghanistan", | |
"dial_code": "+93", | |
"code": "AF" | |
}, | |
{ | |
"name": "Aland Islands", | |
"dial_code": "+358", | |
"code": "AX" |
This file contains 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 removeCharacter(str, charPos) { | |
part1 = str.substring(0, charPos); | |
part2 = str.substring(charPos + 1, str.length); | |
return `${part1}${part2}`; | |
} | |
export default removeCharacter; | |
// console.log(remove_character("Python",3)); |
This file contains 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 getNumFromString(string) { | |
const numbers = string.match(/\d+/g).map(Number); | |
return numbers; | |
} | |
export default getNumFromString; | |
// string = "border-radius:10px 20px 30px 40px" | |
// console.warn(getNumFromString(string)); |
This file contains 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 extractHostname = (url) => { | |
let hostname = ''; | |
// find & remove protocol (http, ftp, etc.) and get hostname | |
if (url.indexOf('//') > -1) hostname = url.split('/')[2]; | |
else hostname = url.split('/')[0]; | |
// find & remove port number | |
hostname = hostname.split(':')[0]; | |
// find & remove "?" |
This file contains 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 urlify(text) { | |
var urlRegex = /(https?:\/\/[^\s]+)/g; | |
return text.replace(urlRegex, function(url) { | |
return '<a href="' + url + '">' + url + '</a>'; | |
}) | |
} | |
var text = "Find me at http://www.example.com and also at http://stackoverflow.com"; | |
var html = urlify(text); |
This file contains 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 Popover extends React.Component { | |
constructor() { | |
super(); | |
this.handleClick = this.handleClick.bind(this); | |
this.handleOutsideClick = this.handleOutsideClick.bind(this); | |
this.state = { | |
popupVisible: false | |
}; |
This file contains 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 urlString = window.location.href; | |
const url = new URL(urlString); | |
const urlParamLang = url.searchParams.get('param'); |
This file contains 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
// Fill array with value, len times | |
// Using concat | |
fillArray = (value, len) => { | |
if (len === 0) return []; | |
let a = [value]; | |
while (a.length * 2 <= len) a = a.concat(a); | |
if (a.length < len) a = a.concat(a.slice(0, len - a.length)); | |
return a; | |
}; |
This file contains 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 toBase64 = file => new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = () => resolve(reader.result); | |
reader.onerror = error => reject(error); | |
}); | |
// toBase64(file).then(file => console.log(file)); |
This file contains 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
/** | |
* We'll load jQuery and the Bootstrap jQuery plugin which provides support | |
* for JavaScript based Bootstrap features such as modals and tabs. This | |
* code may be modified to fit the specific needs of your application. | |
*/ | |
try { | |
window.Popper = require('popper.js').default; | |
window.$ = window.jQuery = require('jquery'); | |
require('bootstrap'); |
OlderNewer