Skip to content

Instantly share code, notes, and snippets.

Avatar

Linus imlinus

  • Sweden
View GitHub Profile
View animated-unsubscribe-page.markdown
View index.html
<script>
Moon.phase('2018', '01', '19'); // returns `quarter-moon`
</script>
View index.html
<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 Jan 19, 2018
jQuery GeoLocation wrapper
View geolocation.js
var GeoLocation = {
cb: '',
lat: '',
lng: '',
getPosition: function() {
var that = this;
if(navigator.geolocation) {
$.when(
@imlinus
imlinus / Modal.js
Last active Jan 8, 2018
Simple as cake modal
View Modal.js
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')
}
}
View gist:eb8b7f34cde25a1f6fe2fe990eea4a2d
<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 Nov 2, 2017
WordPress Custom Post Type with ACF via shortcode
View 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
View async js,css,analytics
<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
View Async JS
<html>
<head>
<script type="text/javascript">
"use strict";
(function() {
class ScriptAsync extends HTMLElement {
View compress_page
<?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();
You can’t perform that action at this time.