Skip to content

Instantly share code, notes, and snippets.

@lyatziv
lyatziv / jQuery.LazyLoad.vimeo
Created July 12, 2013 07:23
A quick way to load a bunch of videos from vimeo.
jQuery(document).ready(function($){
$('iframe[src*="player.vimeo"]').each(function(){
var id = $(this).attr("src").split("/").slice(-1)[0];
$(this).addClass("video_id_"+id);
$(this).parent().addClass("vimeo_id_"+id);
$.ajax({
type:'GET',
url: 'http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/' + id +'.json',
jsonp: 'callback',
dataType: 'jsonp',
@lyatziv
lyatziv / Facial Auto crop
Created December 17, 2013 20:33
Old bit of code that used Face.com API to auto crop images with just php.
<?php
// Face.com api licence
$FaceAPI_Key = '[enter your key]';
$FaceAPI_Secret = '[enter your secret]';
// Get image url
$imgSRC = urlencode($_GET['url']);
// cURL ALT method
@lyatziv
lyatziv / zipToLocalle.js
Last active November 14, 2017 23:19
ziptastic or zippopotam.us alternative
fetch('https://maps.googleapis.com/maps/api/geocode/json?address=10030&region=US', {
method: 'get'
}).then((response) => response.json())
.then((response) => {
let address = response.results[0].address_components.reduce((comps, comp) => {
let attr = comp.types[0];
attr = (attr === 'administrative_area_level_2') ? 'county' : attr;
attr = (attr === 'administrative_area_level_1') ? 'state' : attr;
comps[attr + '_long'] = comp.long_name;
comps[attr + '_short'] = comp.short_name;
// ==UserScript==
// @name Never Mind
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Removes suggested and sponsord posts on scroll!
// @author Ofraggle
// @match https://www.facebook.com/
// @grant none
// ==/UserScript==
@lyatziv
lyatziv / imStillHere.js
Created November 8, 2018 21:29
Let The Music Play Pandora
// ==UserScript==
// @name Play on and on
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prevent nagging
// @author Lavi
// @run-at document-start
// @match https://www.pandora.com/*
// @grant none
// ==/UserScript==
@lyatziv
lyatziv / object2qs.js
Created May 5, 2020 21:13
object2qs.js
/**
* Converts object properties to query string.
* @param {object} props - The object used to construct the query string.
* @return {string} The query string.
*/
export default (props) => {
return typeof props === 'object'
? `?${Object.keys(props).map((prop) => `${prop}=${props[prop]}`).join('&')}`
: ''
}
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Lavi Yatziv",
"label": "Senior Web Developer",
"image": "",
"email": "lavi.yatziv@gmail.com",
"phone": "",
"url": "http://www.fixedspace.com",
"summary": "A graduate of Carleton University's Film program as well as Algonquin College's Radio and TV Broadcasting studies, my work is situated at the juncture between digital and more traditional media. My thorough understanding of both allows me to create beautiful yet functional websites, promotional videos and animation. Troubleshooting and improving functionality for existing websites are among my specialties.",
@lyatziv
lyatziv / isBlank.js
Last active December 18, 2020 16:23
A presumptive function with exhaustive data type tests for empty, null, values.
export default (tr) => {
const hasLength = (val) => val.length
const noTest = () => true
const notZero = (val) => val !== 0
const types = {
'symbol': (val) => val.description === "",
'function': noTest,
'undefined': noTest,
'bigint': notZero,
'object': (val) => Object.is(val, {}),
@lyatziv
lyatziv / makePamphlet.js
Created March 17, 2022 23:00
Get page numbering for booklet printing
const makePamphlet = (suspectInput) => {
const input = Boolean(suspectInput % 2) ? suspectInput + 1 : suspectInput;
const evenPages = [
...Array(input / 2)
.fill(0)
.map((_el, idx) => (idx + 1) * 2),
].reverse();
const oddPages = [
...Array(input)
.fill(0)
@lyatziv
lyatziv / addFixed
Last active April 13, 2022 18:02
javascript math is weird.
export const addFixed = (a: number, b: number, p = 0) => {
const countDecimal = (a: number): number => String(a).split('.')[1].length;
const dec = isNaN(p) ? Math.max(countDecimal(a), countDecimal(b)) : p;
const t = Number(`1${'0'.repeat(dec)}`);
return (a * t + b * t) / t;
};