Skip to content

Instantly share code, notes, and snippets.

View FuruholmAnton's full-sized avatar

Anton Furuholm FuruholmAnton

View GitHub Profile
@FuruholmAnton
FuruholmAnton / Gulpfile
Last active June 9, 2016 11:25
SASS Gulp file
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var sassdoc = require('sassdoc');
var input = './assets/scss/**/*.scss';
var output = './assets/css';
var sassOptions = {
<?php
function my_excerpt($excerpt, $maxLength = 200){
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$fullLength = strlen($excerpt);
$excerpt = substr($excerpt, 0, $maxLength);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
function get_current_url($strip = true) {
// filter function
static $filter;
if ($filter == null) {
$filter = function($input) use($strip) {
$input = str_ireplace(array(
"\0", '%00', "\x0a", '%0a', "\x1a", '%1a'), '', urldecode($input));
if ($strip) {
$input = strip_tags($input);
}
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbar = document.querySelector(".site-header");
var navbarHeight = navbar.offsetHeight;
window.addEventListener("scroll", function(){
didScroll = true;
/*---------- VIDEO ----------*/
var video = (function() {
'use strict';
function video(elem) {
// enforces new
if (!(this instanceof video)) {
return new video(elem);
}
this.player = document.querySelector(elem);
<?php
// Check if the flexible content field has rows of data:
if (have_rows('sections')):
// Loop through the rows of data:
while (have_rows('sections')) : the_row();
// Load the corresponding template file:
include(locate_template('templates/'.get_row_layout().'.php'));
endwhile;
endif;
?>
@FuruholmAnton
FuruholmAnton / animate-loading-bar.js
Last active July 5, 2022 16:33
Animates a loading bar with GSAP
'use strict';
import gsap from 'gsap';
let animationDuration = () => { return (Math.sqrt(window.innerWidth) / 9)};
let secoundStartValue;
let secoundStartFn = () => { return animationDuration() * 0.5 }
let colors = ['#daa9ae', '#98b8c1', '#d6deeb', '#acb198'];
/**
@FuruholmAnton
FuruholmAnton / webpack.config.js
Last active February 24, 2017 18:10
Webpack for JS, SCSS with PHP as a backend
"use strict";
var webpack = require('webpack');
const path = require('path');
var loaders = require('./tools/webpack.loaders');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var DashboardPlugin = require('webpack-dashboard/plugin');
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
require("babel-polyfill");
/**
* Serializes the object and arrays and objects of the main object.
*
* @param {Object} data - the object to serialize
* @param {String} prefix - used internally to keep track of the nesting
*/
function deepSerialize(data, prefix = '') {
if (typeof data == 'function') return prefix != '' ? prefix + '=null' : '';
const array = [];
/**
* Bind methods
* ex. bind(this, 'onClick', 'setHeight');
*
* @param {Object} self
* @param {string} functions
*/
function bind(self, ...functions) {
functions.forEach((name) => {
self[name] = self[name].bind(self);