Skip to content

Instantly share code, notes, and snippets.

View eheiser's full-sized avatar
🏠
Working from home

Erwin Heiser eheiser

🏠
Working from home
View GitHub Profile
@marcedwards
marcedwards / high-dpi-media.css
Last active November 19, 2023 12:56
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@bradfrost
bradfrost / gist:59096a855281c433adc1
Last active September 4, 2023 15:01
Why I'm Not A JavaScript Developer

Answering the Front-end developer JavaScript interview questions to the best of my ability.

  • Explain event delegation

Sometimes you need to delegate events to things.

  • Explain how this works in JavaScript

This references the object or "thing" defined elsewhere. It's like "hey, thing I defined elsewhere, I'm talkin' to you."

  • Explain how prototypal inheritance works.
@kshnurov
kshnurov / jquery.photoswipe.js
Created February 23, 2015 23:37
PhotoSwipe: init from DOM using jQuery
(function( $ ) {
$.fn.photoswipe = function(options){
var galleries = [],
_options = options;
var init = function($this){
galleries = [];
$this.each(function(i, gallery){
galleries.push({
id: i,
@bryandugan
bryandugan / Craft CMS SEO Meta.twig
Last active October 9, 2022 15:21
Craft CMS SEO Meta Tags
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="{{ siteUrl }}favicon.png">
<title>{% if homeTitle is defined %}{{ siteName }} | {{ entry.homeTitle }}{% elseif entry.title is defined %}{{ entry.title }} | {{ siteName }}{% else %}{{ title }} | {{ siteName }}{% endif %}</title>
<link rel="stylesheet" href="{{ siteUrl }}assets/css/app.css" />
<script src="{{ siteUrl }}assets/bower_components/modernizr/modernizr.js"></script>
<!-- General Page Meta -->
{% if entry.seoDescription is defined %}
{% if entry.seoDescription is not empty %}
@mathiasbynens
mathiasbynens / README.md
Created April 22, 2011 08:06
Improved swipe gestures plugin for jQuery

Improved swipe gestures plugin for jQuery

What was changed (compared to the original v0.1.2):

  • Don’t modify the default settings internally.
  • Merge the options recursively (deep copy) so that the custom threshold values actually get used.
  • Allow overriding the options globally through $.fn.swipe.options.
  • Use namespaced jQuery events (using the swipe namespace) instead of DOM2 addEventListener to prevent errors in old IEs.
  • Simplified and optimized code.
  • Changed swipeLeft and swipeRight functions to be called within the context of the bound element. Thanks, @kswedberg!
@croxton
croxton / ee_multilanguage_with_resource_router.md
Last active April 5, 2022 19:11
Using Resource Router for roll-your-own multi-language ExpressionEngine sites

Multi-language routing with Resource Router

The idea is to set up ISO 639-1 language code prefixes for urls (e.g. en/, de/, fr/), and set global variables {global:lang} and {global:lang_dir} for use in your templates.

In the control panel create a category group "languages" and populate it with your languages, setting the category url title to the appropriate 2-letter language code. Assign the category group to the channels you want to translate.

For example:

Category Name Category URL Title
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@nathansmith
nathansmith / bootstrap-grid-3.3.1.css
Last active October 4, 2021 08:43
Bootstrap's grid, in isolation. Normalize.css removed.
/*
Bootstrap v3.3.1 (http://getbootstrap.com)
*/
/*
NOTE:
This file has Normalize.css removed.
It still requires a "reset.css", so we're using this...
@chodorowicz
chodorowicz / main.js
Created July 15, 2015 12:20
photoswipe disable zoom
{
zoomEl: false,
maxSpreadZoom: 1,
getDoubleTapZoom: function(isMouseClick, item) {
return item.initialZoomLevel;
}
pinchToClose: false
}
@low
low / low-search-ajax.js
Last active October 18, 2020 13:21
Using Low Search for ExpressionEngine with Ajax. Change any of the three variables on top to suit your needs. Tested with jQuery 1.9.0.
(function($){
$(function(){
var $form = $('#search'), // Search form
$target = $('#results'), // Results container
rp = 'search/ajax-results'; // Template for results only
// Function to execute on success
var success = function(data, status, xhr) {
$target.html(data);
};