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
Better way to hide you **<input type="file" />** is to wrap it into <label> tag. | |
So it will look like so | |
<label class="file-chose"> | |
<input type="file" /> | |
</label> | |
After that you have to make css it styled to set input's display property to "none": |
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
#include <PubSubClient.h> | |
#include <ESP8266WiFi.h> | |
void callback(char* topic, byte* payload, unsigned int length); | |
#define client_name "Switch" | |
#define wifi_ssid "Home" | |
#define wifi_password "secret" | |
#define mqtt_server "176.0.0.2" |
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
/** | |
* Returns an instance of Trie data structure to fill with | |
* strings that can be searched through with high efficiency | |
* Example usage: | |
* ``` | |
* const words = ['cats', 'dogs', 'racoons', 'foxes']; | |
* const t = trie(); | |
* words.forEach(t.insert); | |
* t.search('cat'); // false | |
* t.search('cat', true); // true |
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 radToDeg = (v) => { | |
return (v * 180) / Math.PI; | |
}; | |
const degToRad = (v) => { | |
return (v * Math.PI) / 180; | |
}; | |
export const getBoundBox = (lat, lon, rangeInMeters = 10) => { | |
const latRad = degToRad(lat); |
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
/** | |
* Makes fetch call to API | |
* @param url | |
* @throws {ApiError} | |
*/ | |
export const fetchApi = async (url: string) => { | |
const response = await fetch(url, { | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', |
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 RandomizedSet { | |
constructor() { | |
this.set = new Map(); | |
this.array = []; | |
} | |
insert(val) { | |
if (this.set.has(val)) { | |
return 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
function topKFrequentWords(words, k) { | |
const freq = new Map(); | |
for (const word of words) { | |
if (!freq.has(word)) { | |
freq.set(word, 1); | |
} else { | |
freq.set(word, freq.get(word) + 1); | |
} | |
} |
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
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
function twoSum(nums, target) { | |
let mp = new Map() | |
for (let i = 0; i < nums.length; i++) { | |
let diff = target - nums[i] |
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
/** | |
* @param {string[]} strs | |
* @return {string} | |
*/ | |
function longestCommonPrefix(strs) { | |
if (strs.length === 0) { | |
return ""; | |
} | |
let prefix = strs[0]; |
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 uncommonWords(s1, s2) { | |
const words1 = s1.split(' '); | |
const words2 = s2.split(' '); | |
const freq = new Map(); | |
for (const word of words1) { | |
freq.set(word, (freq.get(word) || 0) + 1); | |
} |
OlderNewer