Skip to content

Instantly share code, notes, and snippets.

View lemmon's full-sized avatar

Jakub Pelák lemmon

View GitHub Profile
@lemmon
lemmon / email.js
Last active February 2, 2018 14:30
encode/decode email address in HTML
var elements = document.querySelectorAll('[data-mailto]');
for (var i = elements.length - 1; i >= 0; i--) {
var el = elements[i];
var email = '';
for (var j = el.children.length - 1; j >= 0; j--) {
if (el.children[j].style.display !== 'none') {
email = el.children[j].innerText + email;
}
}
el.innerHTML = email;
@lemmon
lemmon / timemachine.md
Created September 7, 2017 11:53
Time Machine

Exclude Dirs from TimeMachine

find ~/Sites -type d -maxdepth 3 -name 'node_modules' | sudo xargs tmutil addexclusion -p

View Current Settings

defaults read /Library/Preferences/com.apple.TimeMachine.plist

Remove Excluded Dirs

@lemmon
lemmon / datediff.js
Created May 16, 2016 14:27
Calculates difference in years, months, and days between today and a date in past. Takes one string parameter -- date in YYYY-MM-DD format.
function dateDiff(date) {
date = date.split('-');
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
var day = today.getDate();
var yy = parseInt(date[0]);
var mm = parseInt(date[1]);
var dd = parseInt(date[2]);
var years, months, days;
@lemmon
lemmon / loader.less
Created August 11, 2015 10:05
CSS loader
.loader {
@w: 48px;
@m: 16px;
position:fixed;
left:50%;
top:50%;
width:@w + 2 * @m;
height:@w + 2 * @m;
margin-left:-(@w / 2 + @m);
margin-top:-(@w / 2 + @m);
@lemmon
lemmon / download.html
Last active December 8, 2015 16:12
Instagram Photo Downloader Bookmarklet
<a href="javascript:(function()%7B%24('article%5Bclass*%3D%22Post%22%5D%20img%5Bclass*%3D%22Photo%22%5D').each(function()%7Bwindow.open(%24(this).attr('src')%2C'_blank'%2C''%2C'')%3B%7D)%7D)()">instagram image</a>
@lemmon
lemmon / gist:3713945
Created September 13, 2012 12:15
Country Services
// get country code of site visitor
function getByVisitor()
{
if (array_key_exists( '__COUNTRY__', $_SESSION ))
{
return $_SESSION[ '__COUNTRY__' ];
}
elseif ($host=gethostbyaddr(Application::getIP()) and substr($host, -3, 1)=='.' and $country=substr($host, -2) and $country=Countries::make()->findLike('code', $country)->first()->code)
{
return $_SESSION[ '__COUNTRY__' ]=$country;
<?php
class Some_Class_To_Parse_Colors_From_Images
{
function logo()
{
$src = 'public/dummy/logo2.png';
$im = imagecreatefrompng(ROOT . $src);
$w0 = imagesx($im);
$h0 = imagesy($im);