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
// Link to kata: http://www.codewars.com/kata/calculating-with-functions/javascript | |
// How it works: | |
// seven(times(five())); // returns 35 | |
// four(plus(nine())); // returns 13 | |
// eight(minus(three())); // returns 5 | |
// six(dividedBy(two())); // returns 3 | |
function zero() { | |
if (arguments.length == 0) return 0; |
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 id = Date.now() + Math.random().toString(16).substr(2); |
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 randomChoice(arr) { | |
return arr[Math.floor(Math.random() * arr.length)]; | |
} |
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 resize(increase_or_decrease) { | |
const direction = increase_or_decrease; | |
// First arg is the direction, elements to change follow | |
for (let i = 1; i < arguments.length; i++) { | |
let fontsize = parseInt($(arguments[i]).css('font-size')); | |
if (direction === 'increase') { | |
fontsize++; | |
if (fontsize > 20) fontsize = 20; // Prevent text from getting too big | |
} else if (direction === 'decrease') { | |
fontsize--; |
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
# needed packages: beautifulsoup4, lxml | |
import requests as r | |
from bs4 import BeautifulSoup | |
from sys import argv | |
import re | |
# dictionaries for country codes and shortenings e.g. UK and UAE | |
country_dict = {'ch': 'Switzerland', 'gr': 'Greece', 'ee': 'Estonia', 'eg': 'Egypt', | |
'ea': 'United Arab Emirates', 'it': 'Italy', 'cz': 'Czech', 'cy': 'Cyprus', 'at': 'Austria', | |
'cs': 'Serbia', 'et': 'Ethiopia', 'ng': 'Nigeria', 'ie': 'Ireland', 'gh': 'Ghana', |
NewerOlder