Skip to content

Instantly share code, notes, and snippets.

View imlinus's full-sized avatar

Linus imlinus

View GitHub Profile
@imlinus
imlinus / animated-unsubscribe-page.markdown
Created October 17, 2018 13:06
Animated Unsubscribe Page
@imlinus
imlinus / index.html
Created January 19, 2018 13:55
Moon Phase
<script>
Moon.phase('2018', '01', '19'); // returns `quarter-moon`
</script>
@imlinus
imlinus / index.html
Created January 19, 2018 13:38
Sun Set Rise
<script>
var ymd = '2018-01-19',
lat = '59.10',
lng = '16.40';
Sun.info(ymd, lat, lng).then(function() {
console.log(Sun.rise);
console.log(Sun.set);
});
@imlinus
imlinus / geolocation.js
Created January 19, 2018 12:59
jQuery GeoLocation wrapper
var GeoLocation = {
cb: '',
lat: '',
lng: '',
getPosition: function() {
var that = this;
if(navigator.geolocation) {
$.when(
@imlinus
imlinus / Modal.js
Last active January 8, 2018 15:19
Simple as cake modal
var Modal = {
open: function(id) {
document.querySelector('.modal[data-modal-id="' + id + '"]').classList.add('active')
},
close: function(id) {
document.querySelector('.modal[data-modal-id="' + id + '"]').classList.remove('active')
}
}
<html>
<head>
<style>
.line-loader {
height: 0.25rem;
background: black;
width: 0;
position: absolute;
top: 0; left: 0;
transition: width 0.25s cubic-bezier(1.000, 0.000, 0.000, 1.000);
@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
<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
<html>
<head>
<script type="text/javascript">
"use strict";
(function() {
class ScriptAsync extends HTMLElement {
@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();