Skip to content

Instantly share code, notes, and snippets.

@animify
animify / uriToBlob.js
Created November 7, 2018 10:08
Function that retrieves a data string and converts it to a Blob
function uriToBlob(dataURI, type) {
const binary = atob(dataURI.split(',')[1]);
const array = [];
for (let i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
return new Blob([new Uint8Array(array)], { type });
}
@animify
animify / compile.js
Created July 20, 2018 08:06 — forked from manuhabitela/compile.js
Checking environment in (node) Sass
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var sass = require('node-sass');
var ENV = process.env.SASS_ENV || 'development';
var file = 'variables.scss';
//if in dev, directly pass file to sass
if (ENV === "development") {
@animify
animify / cloudSettings
Last active December 2, 2019 13:31
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-12-15T03:33:14.576Z","extensionVersion":"v3.2.4"}
@animify
animify / commit.md
Last active August 13, 2018 13:11 — forked from stephenparish/commit.md
Overflow Git Commit Conventions

Commit Message Conventions

These rules are adopted from the AngularJS commit conventions.

Goals

  • Allow generating CHANGELOG.md by script
  • Provide better information when browsing git history
@animify
animify / Article.md
Created August 29, 2017 12:42 — forked from Warry/Article.md
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

const express = require('express')
const router = express.Router()
const auth = require('../auth')
router.use('/login/callback/github',
auth.authenticate('github', { failureRedirect: '/' }),
function(req, res) {
res.redirect('/')
});
@animify
animify / gist:9079644f78ecc6af41c390172c32b14b
Created July 26, 2016 14:28 — forked from Joncom/gist:e8e8d18ebe7fe55c3894
Check if two line segments intersect
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) {
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x;
s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x;
s2_y = p3_y - p2_y;
var s, t;
@animify
animify / mongooseUniquenessValidation.js
Created May 27, 2016 12:00 — forked from edinella/mongooseUniquenessValidation.js
Mongoose uniqueness validator, case-sensitive or not
// context
var mongoose = require('mongoose');
mongoose.connect('mongodb://...');
/**
* Generates Mongoose uniqueness validator
*
* @param string modelName
* @param string field
* @param boolean caseSensitive