Skip to content

Instantly share code, notes, and snippets.

View winkerVSbecks's full-sized avatar
🥵

Varun Vachhar winkerVSbecks

🥵
View GitHub Profile
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
title.charAt(index - 1).search(/[^\s-]/) < 0) {
return match.toLowerCase();
}
@winkerVSbecks
winkerVSbecks / sketch.js
Created February 27, 2015 02:33
Paper JS Vector Field
paper.install(window);
var canvas, parent, hero, mousePos;
var locs = [];
var paths = [];
var thetas = [];
var nodes = 0;
window.onload = function() {
paper.setup('js-vector-field');
@winkerVSbecks
winkerVSbecks / git-subtree.md
Last active August 29, 2015 14:14
Git Sub tree workflow

Pull changes:

git subtree pull --prefix packages/onist-data onist-data master --squash

Push to my fork:

git subtree push --prefix packages/onist-data my-onist-data master
@winkerVSbecks
winkerVSbecks / pre-commit
Last active August 29, 2015 14:14
Run JSHint validation before commit
#!/bin/bash
#
# Run JSHint validation before commit.
files=$(git diff --cached --name-only --diff-filter=ACM | grep '.js$')
pass=true
# JSHint
if [ "$files" != "" ]; then
for file in ${files}; do
jshint ${file}
@winkerVSbecks
winkerVSbecks / Gulpfile.js
Last active August 29, 2015 14:13
Jekyll and Gulp
var gulp = require('gulp');
var connect = require('gulp-connect');
var watch = require('gulp-watch');
var exec = require('gulp-exec');
var livereload = require('gulp-livereload');
var sass = require('gulp-ruby-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
gulp.task('sass', function(done) {
@winkerVSbecks
winkerVSbecks / box-shadow-helper.scss
Created November 21, 2014 21:04
Google Material Box Shadow Generator
@mixin box-shadow-helper($level: 1) {
@if $level == 1 {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
} @else if $level == 2 {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
} @else if $level == 3 {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
} @else if $level == 4 {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
} @else if $level == 5 {

SASS Mixin for Generating a Custom Easing Function

From Patakk (http://patakk.tumblr.com/info):

Here’s a simple function you can use for easing motions, just set your “time” variable to go from 0 to 1. The ‘g’ adjusts the amount of easing.

In the animation above I used the function like this:

x = 300 * ease(time, g);

<!-- Photos -->
{{#if showPhotosRow}}
<h5>Photos <small>(click to view)</small></h5>
{{#each photos}}
{{#if isAssembleOrSelected}}
<div class="relative additionalitem-photo">
<img
class="thumbnail {{#if selected}}selected{{/if}}"
src="{{#photoUrl this}}{{/photoUrl}}"
data-name="{{photoName}}" />