Skip to content

Instantly share code, notes, and snippets.

View imlinus's full-sized avatar

Linus imlinus

  • Bitwise Media
  • Stockholm
  • 12:50 (UTC +02:00)
View GitHub Profile
@imlinus
imlinus / _alpha.scss
Last active December 29, 2015 10:19
Alpha mixin
@mixin alpha($val: 0) {
$ie-alpha: $val * 100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=#{$ie-alpha})";
filter: alpha(opacity=#{$ie-alpha});
@include prefix(opacity, $val);
}
%alpha-0 { @include alpha(0); }
%alpha-50 { @include alpha(0.5); }
@imlinus
imlinus / _vertical-center.scss
Last active December 29, 2015 13:09
vertical centering mixins
// Mixin for vertical and horizontal centerin
// Requires a declared height + position: relative on parent
// usage:
// .box {
// height: 50%;
// @include vertical-center-1;
// }
@mixin vertical-center-1 {
@include position(absolute, 0, 0, 0, 0);
@imlinus
imlinus / _arrow.scss
Last active December 29, 2015 13:19
arrow mixin
// Mixin for creating arrows, basic usage @include arrow(top-left, #000, 15px);
// available directions: top, right, bottom, left, top-left, top-right, bottom-left, bottom-right
@mixin arrow(
$direction,
$color,
$size
) {
height: 0;
width: 0;
@imlinus
imlinus / _animate.scss
Last active December 29, 2015 13:19
animate/keyframes/transition helper mixins
// Mixin for keyframes
// basic usage:
// @include keyframes(name) {
// 0% { background: yellow; }
// 100% { background: blue; }
// }
@mixin keyframes($name) {
@-webkit-keyframes $name { @content; }
@-moz-keyframes $name { @content; }
@imlinus
imlinus / _all-prefix.scss
Last active December 29, 2015 13:29
prefix mixin
// mixin for prefixin'
// usage: @include prefix(attribute, argument);
@mixin prefix($attribute, $argument) {
-webkit-#{$attribute}: #{$argument};
-moz-#{$attribute}: #{$argument};
-ms-#{$attribute}: #{$argument};
-o-#{$attribute}: #{$argument};
#{$attribute}: #{$argument};
}
@imlinus
imlinus / Router.js
Last active December 12, 2016 08:33
var subPages = {
'index': {
'name': 'Whazzzzup',
'content': 'Welcome to MyTurrn',
},
'about': {
'name': 'Who are we?',
'content': 'We got founded back in 2014',
},
'contact': {
@imlinus
imlinus / compress_page
Last active December 12, 2016 08:45
php
<?php
function compress_page($buffer) {
$search = array("/<!–\{(.*?)\}–>|<!–(.*?)–>|[\t\r\n]|<!–|–>|\/\/ <!–|\/\/ –>|<!\[CDATA\[|\/\/ \]\]>|\]\]>|\/\/\]\]>|\/\/<!\[CDATA\[/" => "");
$buffer = preg_replace(array_keys($search), array_values($search), $buffer);
return $buffer;
}
ob_start('compress_page');
// Page here
ob_end_flush();
<html>
<head>
<script type="text/javascript">
"use strict";
(function() {
class ScriptAsync extends HTMLElement {
<style type="text/css">.body-js { opacity: 0; height: 100%; }</style>
<script type="text/javascript">
!function(a,b){a.async=b}(this,function(){function a(a,b){function c(){g.incr(b)}function d(){"complete"===f.readyState&&c()}function e(){console.warn("[async] occurred an error while fetching",a)}var f=document.createElement("script");f.type="text/javascript",f.onload=c,f.async=!0,f.onreadystatechange=d,f.onerror=e,f.src=a,document.head.appendChild(f)}function b(a){c.apply(this,a)}function c(){var c=Array.prototype.slice.call(arguments),d=c[0];"string"==typeof d&&(d=[d]),"[object Array]"===Object.prototype.toString.call(c[1])&&(c[1]=b.bind(this,c.slice(1,c.length)));for(var f=g.push(d.length,c[1]),h=0;h<d.length;h++){var i=d[h];a(e[i]||i,f)}}var d=Object.prototype.hasOwnProperty,e={},f={"extends":function(a,b,c){for(var e in b)d.call(b,e)&&("constructor"===e&&a===global||(void 0===b[e]?delete a[e]:c&&"undefined"!=typeof a[e]||(a[e]=b[e])));return a},merge:function(a,b){var c={};for(var d in a)c[d]=a
@imlinus
imlinus / WordPress Custom Post Type with ACF via shortcode
Created November 2, 2017 10:48
WordPress Custom Post Type with ACF via shortcode
<?php
function price_shortcode($id) {
if($id != '') {
$post_id = $id[0];
$html = '';
global $wpdb;
$args = array(
'post_type' => 'price_list_init',
'name' => $id