Skip to content

Instantly share code, notes, and snippets.

@Bamieh
Bamieh / parse-dotless.scss
Last active December 1, 2016 13:59
Sass parse class without dot (strip dot "." from class name)
@function parse-dotless($class) {
$this: quote($class);
@return if(str-slice($this, 0, 1) == ".", str-slice($this, 2, str-length($this)), $this);
}
/*
example usage:
.14px {
font-size: parse-dotless(#{&}); // will strip the class from .14px to return 14px;
}
@choppingblock
choppingblock / Calculate Angle Along Quadratic Bezier
Created September 14, 2013 02:38
Have a quadratic bezier curve, need to figure out an angle along the way. This should work quite well, easy to convert to JavaScript.
public static function quadraticBezierAngle(value:Number, anchor1:Point, anchor2:Point, control:Point):Number {
var uc:Number = 1 - value;
var dx:Number = (uc * control.x + value * anchor2.x) - (uc * anchor1.x + value * control.x);
var dy:Number = (uc * control.y + value * anchor2.y) - (uc * anchor1.y + value * control.y);
return Math.atan2(dy, dx);
}
@spoike
spoike / reflux.js
Created June 29, 2014 22:23
A simpler implementation of React.JS's Flux
var EventEmitter = require('events').EventEmitter,
_ = require('lodash');
/**
* Creates an action functor object
*/
exports.createAction = function() {
var action = new EventEmitter(),
eventLabel = "action",
@BriSeven
BriSeven / decompose-matrix.js
Last active May 23, 2021 15:21
Decompose a 2D transform matrix into [rotate scale rotate translate]
function decomposeMatrix(m) {
var t,r,s,k,E,F,G,H,Q,R,sx,sy,a1,a2,theta,phi,sqrt=Math.sqrt,atan2=Math.atan2;
// http://math.stackexchange.com/questions/861674/decompose-a-2d-arbitrary-transform-into-only-scaling-and-rotation
//
// It works wonderfully! Thanks.
// The input matrix is transposed though,
// so let me spell the solution out.
E=(m[0]+m[3])/2
var easing = {
linear : function (t){
return t;
},
easeInQuad: function (t) {
return t*t;
},
easeOutQuad: function (t) {
return -1 *t*(t-2);
},
@umaar
umaar / webdriver-hover.js
Created February 17, 2014 14:05
Hover over an element in WebDriverJS
/*
* Hover over an element on the page
*/
(function() {
"use strict";
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'chrome' }).build();
@dsheiko
dsheiko / strtr.js
Last active July 9, 2023 18:18
Java-script strtr — translate characters or replace substrings
/**
* strtr() for JavaScript
* Translate characters or replace substrings
*
* @author Dmitry Sheiko
* @version strtr.js, v 1.0.2
* @license MIT
* @copyright (c) Dmitry Sheiko http://dsheiko.com
**/
@chadrien
chadrien / README.md
Last active September 1, 2023 12:43
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@devver
devver / terms_of_service.markdown
Last active October 22, 2023 03:35
A general Terms of Service under the Creative Commons License

Terms of Service

Last revised on [DATE]

The Gist

[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.

For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.

@timo22345
timo22345 / flatten.js
Last active March 13, 2024 17:06
Flatten.js, general SVG flattener. Flattens transformations of SVG shapes and paths. All shapes and path commands are supported.
<!doctype html>
<html>
<title>Flatten.js, General SVG Flattener</title>
<head>
<script>
/*
Random path and shape generator, flattener test base: https://jsfiddle.net/fjm9423q/embedded/result/
Basic usage example: https://jsfiddle.net/nrjvmqur/embedded/result/