Skip to content

Instantly share code, notes, and snippets.

View cfenzo's full-sized avatar

Jens Anders Bakke cfenzo

  • @Inmeta | Bakke Media
  • Hamar, Norway
View GitHub Profile
@cfenzo
cfenzo / ShowMore.jsx
Last active March 16, 2017 12:19
<ShowMore> component
import React from 'react';
class ShowMore extends React.Component {
contentHeight = 0
state = {
contentHeight: 0,
expanded: false
}
componentDidMount() {
this.updateHeight();
@cfenzo
cfenzo / esnextbin.md
Last active October 17, 2016 12:17
esnextbin sketch
@cfenzo
cfenzo / esnextbin.md
Created September 19, 2016 21:47
esnextbin sketch
@cfenzo
cfenzo / detect.js
Created November 26, 2015 09:05
facebook sdk mobile detect
// extracted from all.js on nov 26th 2015
var h = navigator.userAgent,
i = {
iphone: /\b(iPhone|iP[ao]d)/.test(h),
ipad: /\b(iP[ao]d)/.test(h),
android: /Android/i.test(h),
nativeApp: /FBAN\/\w+;/i.test(h),
mobile: /Mobile/i.test(h)
};
isMobile = i.iphone || i.ipad || i.android || i.mobile;
@cfenzo
cfenzo / keypath_resolve.js
Last active August 29, 2015 14:22
Ractive.js: Resolve mapped keypaths from child instances to its correct keypath in the calling instance (if they originate from that instance or one of its parents).
function keypath_resolve(keypath, instance, caller){
return (function _resolve(keypath, instance, caller){
var keypathArray, mapped;
// if instance is the caller, return the current keypath
if(instance === caller) {
return keypath;
}
// split the keypath, look for the first key in viewmodel mappings
@cfenzo
cfenzo / add_sequence.js
Created August 25, 2014 11:21
A utility-function for adding squences in velocity.js, was the base of the sequences-functionality that is now present in velocity.js
/*
animations is declared like this:
- simple (one or more rules, in one duration):
'name':{style:value,style2:value}
- complex (one or more rules, split duration):
'name':[
[{style:value,style2:value},'unitless percentage of duration'||{options}],
[{style:value,style2:value},'unitless percentage of duration'||{options}]
]
*/
@cfenzo
cfenzo / ractive-transitions-animatecss.js
Created August 25, 2014 11:17
A tiny ractive transitions plugin for animate.css-animations.
/*
Requires animate.css, and support for the 'transitionend' event.
(See https://developer.mozilla.org/en-US/docs/Web/Events/transitionend for browser support)
*/
(function ( global, factory ) {
'use strict';
// Common JS (i.e. browserify) environment
if ( typeof module !== 'undefined' && module.exports && typeof require === 'function' ) {
@cfenzo
cfenzo / functions.php
Created April 3, 2013 09:59
How to replace timthumb with wordpress thumbnails for attachment-images in wordpress themes..
// add the thumbnail-sizes you need in functions.php
if ( function_exists( 'add_image_size' ) ) {
// repeat for all the thumbnail-sizes you need
add_image_size( 'thumb790x450', 790, 450, true );
}
// helper-function for getting the attachemnt-ID from source. You need this when you only have an image-src
function get_attachment_id_from_src ($image_src) {
global $wpdb;
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
$id = $wpdb->get_var($query);
@cfenzo
cfenzo / app-tab-to-page-button.userscript.js
Created December 4, 2012 08:08
A small userscript to add a "add tab to page" button to an apps summary-page
// ==UserScript==
// @name Add facebook app to page -button
// @namespace http://webfreak.no/
// @version 0.1
// @description Adds a button to the summary-screen for facebook-apps, and adds a button in the header for adding the tab to a page (if a tab is specified).
// @match https://developers.facebook.com/apps/*/summary/
// @copyright 2012+, enzo @ webfreak.no
// ==/UserScript==
(function(){
var ifstatement = "if(document.getElementById('secure_page_tab_url') && document.querySelectorAll('#developerAppHeader a')){";
@cfenzo
cfenzo / offcanvas.css
Created September 3, 2012 12:30
foundation off-canvas with translate3d
@charset "UTF-8";
/* Foundation 3, artfully masterminded by ZURB Addition offcanvas.css - Specific CSS for off-canvas layouts Off canvas layout CSS/JS provided by or adapted from work by Jason Weaver and Luke Wroblewski
Requires: globals.css grid.css modernizr.js (not the foundation one)
Edit: translate3d fix by Jens Anders Bakke (github.com/cfenzo)
*/
body.off-canvas { padding: 0; margin: 0; }
.container { width: 100%; }
.row { overflow: hidden; }