Skip to content

Instantly share code, notes, and snippets.

Avatar

Tommaso Lanza tmslnz

View GitHub Profile
@tmslnz
tmslnz / Tx.js
Last active Mar 2, 2017
Transform stack
View Tx.js
/*
Utility to create and manage a stack of CSS transforms.
Supports namespaced properties.
Example:
var el = document.querySelector('#id');
var tx = new Tx();
Basic usage:
@tmslnz
tmslnz / getTranslate3d.js
Created Feb 25, 2017
Get and array of translate3d values
View getTranslate3d.js
function getTranslate3d (el) {
var values = el.style.transform.split(/\w+\(|\);?/);
if (!values[1] || !values[1].length) {
return [];
}
return values[1].split(/,\s?/g);
}
@tmslnz
tmslnz / getTransforms.js
Created Feb 25, 2017
Get list of transform props
View getTransforms.js
function getTransforms (el) {
var values = [];
var re = /\w+\(.+?\)/gi;
var match = [];
while ((match = re.exec(el.style.transform)) !== null) {
values.push(match[0]);
}
return values;
}
@tmslnz
tmslnz / getOffsetFromParent.js
Created Feb 25, 2017
Get HTMLElement offset relative to offsetParent, minus transforms
View getOffsetFromParent.js
function getOffset (node) {
var doc = node.ownerDocument;
var docElem = doc.documentElement;
var win = doc.defaultView;
var rect;
var result;
try {
rect = node.getBoundingClientRect();
} catch (e) {
return { left: 0, top: 0 };
@tmslnz
tmslnz / getOffset.js
Created Feb 25, 2017
Get the absolute, untransformed offset of HTMLElement
View getOffset.js
function getAbsoluteOffset (el) {
var _x = 0;
var _y = 0;
while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
_x += el.offsetLeft;
_y += el.offsetTop;
el = el.offsetParent;
}
return { top: _y, left: _x };
}
View fix unity
~/Library/Unity/Packages
These are copied in from Unity.app application bundle, at path:
/Applications/Unity/Unity.app/Contents/Resources/Packages
To fix by hand, until finding the source of the problem:
cd /
@tmslnz
tmslnz / project_presets.cfg
Created Feb 22, 2017
Modo Project Preset Template
View project_presets.cfg
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--
This file lives under
~/Library/Application Support/Luxology/Configs/project_presets.cfg
-->
<atom type="ProjectTemplates">
View MACHgettime.c
/*
Fix for missing realtime clock in OS X
======================================
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
@tmslnz
tmslnz / HTTrack.md
Last active Dec 1, 2019
Nice command line for HTTrack
View HTTrack.md

Commands

httrack example.com -O ./example.com -N100 −%i0 -I0 --max-rate 0 --disable-security-limits --near -v
httrack example.com -O ./example.com-3 -N100 -I0 -N "%p/%n%[month].%t" --max-rate 0 --disable-security-limits --near  -v
View gulpfile.js
/*
Streamlined Shopify theme development.
NOTE: depends on module gulp-shopify-theme
npm install --save-dev yargs gulp gulp-sass gulp-changed gulp-sourcemaps gulp-autoprefixer gulp-uglify gulp-concat gulp-replace gulp-plumber gulp-babel browser-sync gulp-if del gulp-add-src gulp-rename gulp-yaml gulp-shopify-theme
Highlights:
- https proxying via BrowserSync