Skip to content

Instantly share code, notes, and snippets.

View davojta's full-sized avatar

Dzianis Sheka davojta

  • mapbox.com
  • Helsinki
View GitHub Profile
@davojta
davojta / shapely-demo.ipynb
Created May 28, 2020 14:15 — forked from sweenzor/shapely-demo.ipynb
Shapely ipython notebook example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davojta
davojta / skype-interview.js
Created November 15, 2018 13:47 — forked from kutyel/skype-interview.js
Skype Technical Interview's Questions about JavaScript
/**
* Write a JavaScript function that takes a number n and returns the sum of the even numbers from 1 to n.
*/
function firstFunc(n) {
let result = 0;
for (let index = 1; index <= n; index++) {
if (index % 2 === 0) {
result += index;
}
}
@davojta
davojta / FAQ.md
Created November 15, 2018 13:47 — forked from kutyel/FAQ.md
JavaScript Star Q/A 🌟

Typical JS Interview Questions

What is a Closure?

Closure is when a function "remembers" its lexical scope even when the function is executed outside that lexical scope. (IMO: just a stupid function returning another partially applied function).

What is Hoisting?

Variable and function declarations are put into memory during the compile phase, but stays exactly where you typed it in your coding. There is no physically lifting to the top of the file at all.

@davojta
davojta / gmail-compose-encoder.js
Created November 13, 2018 10:57 — forked from danrouse/gmail-compose-encoder.js
gmail `compose` query parameter encoder/decoder
const fullAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const restrictedAlphabet = 'BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz';
const threadPrefix = 'thread-';
const messagePrefix = 'msg-';
const isWhitespace = str => /^[\s\xa0]*$/.test(str);
const isInvalidString = str => str ? (str.indexOf(threadPrefix) !== -1 || str.indexOf(messagePrefix) !== -1) : false;
const encode = function(str) {
if (isWhitespace(str)) return str;