Skip to content

Instantly share code, notes, and snippets.

View ardeshireshghi's full-sized avatar

Ardeshir Eshghi ardeshireshghi

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>JPG to PNG</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
height: 100%;
text-align: center;
Function.prototype.bind = Function.prototype.bind || function() {
var args = Array.prototype.slice.call(arguments);
var context = args[0];
var fn = this;
return function() {
var fnArgs = Array.prototype.slice.call(arguments);
fn.apply(context, args.slice(1).concat(fnArgs));
}
}
// GOTO: https://deliveroo.co.uk/restaurants/london/balham?postcode=SW120PJ&day=today&time=ASAP&tags=noodles
(function createCustomScroller() {
var slider = document.querySelector('.contextual-link-bar--group-link-list');
var sliderParent = slider.parentNode;
var sliderWrapper = document.createElement('div');
sliderWrapper.style.background = '#fff';
sliderWrapper.style.border = 'solid 1px rgba(0,0,0,0.2)';
sliderWrapper.style.boxShadow = '0 4px 0 0 rgba(0,0,0,0.04)';
sliderWrapper.style.overflow = 'hidden';
Map.prototype.toObject = Map.prototype.toObject || function() {
const result = new Object();
for (let entry of this.entries()) {
result[entry[0]] = entry[1];
}
return result;
};
Object.prototype.toMap = Object.prototype.toMap || function() {
const result = new Map();
Function.prototype.curry = Function.prototype.curry || function(arity) {
const fn = this;
const fnLength = arity || fn.length;
const curried = (...thisArgs) => {
if (thisArgs.length < fnLength) {
return fn.bind(null, ...thisArgs).curry(fnLength - thisArgs.length);
}
return fn(...thisArgs);
};
import R from 'ramda';
const createOutlierFilter = (minMaxValues) => {
const { min, max } = minMaxValues;
return R.filter(value => value < min || value > max);
};
const calculateQuartiles = (data) => {
const q1Index = Math.floor(data.length / 4);
const q3Index = Math.ceil(data.length * 0.75);
@ardeshireshghi
ardeshireshghi / search.html
Last active July 24, 2017 09:09
Full screen search bar
<!DOCTYPE html>
<html>
<head>
<title>Cool search</title>
<style type="text/css">
@import url('https://fonts.googleapis.com/css?family=Fira+Sans');
body {
margin: 0;
padding: 0;
function downloadVideoScreenshot(videoEl, filename = 'screehshot.png') {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d')
const { width, height } = getComputedStyle(videoEl);
// Canvas attributes
canvas.width = width.replace('px', '');
canvas.height = height.replace('px', '')
canvas.display = 'none';
canvas.style.position = 'relative';
const arrayWithoutFastest = (() => {
const isArray = canBeArray => ('isArray' in Array)
? Array.isArray(canBeArray)
: Object.prototype.toString.call(canBeArray) === '[object Array]';
let mapIncludes = (map, key) => map.has(key);
let objectIncludes = (obj, key) => key in obj;
let includes;
function arrayWithoutFastest(arr, ...thisArgs) {
function arrayWithoutConcatReducer(arr, ...thisArgs) {
const isArray = canBeArray => ('isArray' in Array)
? Array.isArray(canBeArray)
: Object.prototype.toString.call(canBeArray) === '[object Array]';
const withoutValues = isArray(thisArgs[0]) ? thisArgs[0] : thisArgs;
return arr.reduce((acc, value) => (([1].indexOf(value) === -1) ? acc.concat(value) : acc), [])
}
function arrayWithoutPushReducer(arr, ...thisArgs) {