Skip to content

Instantly share code, notes, and snippets.

@patik
patik / Duplicate-ID-Finder.markdown
Created February 12, 2014 14:58
A Pen by Craig Patik.

Duplicate ID Finder

Reports IDs that are being used by multiple elements within a page, including the number of occurrences of each one

A Pen by Craig Patik on CodePen.

License.

@patik
patik / sites.md
Last active August 29, 2015 13:57
Why you can't rely on JavaScript

Some of these articles may be old but their arguments hold true. In particular, with more and more people relying on flaky, high-latency cellular networks to deliver sites there is possibly even more concern that JS may not work, even in an otherwise capable browser.

@patik
patik / _breakpoint.scss
Last active August 29, 2015 13:58
Breakpoint without Compass
@mixin breakpoint($size: "", $maxWidth: false) {
@if $size == "" {
$size: 20em; // Put your "main" or most-used breakpoint here to use it as a default
}
// Default, `min-width` media query
@if $maxWidth == false {
@media (min-width: $size) { @content; }
}
// Alternative `max-width` media query
@patik
patik / data.js
Created June 18, 2014 16:01
Simple JSON path parser
// Source data (JSON) from the server
data = {
abc: {
def: {
ghi: 'jkl'
}
}
};
// The path you're looking for (you want the value of `ghi`)
@patik
patik / popover.md
Last active September 14, 2015 17:26
Popover plugin specifications

Popover

Overview

The popover plugin displays HTML in a container that overlays the page. It is triggered by clicking on a button or other UI element and the container is positioned near the element. The popover can be displayed and hidden at will.

Usage

The plugin must be provided with an options object and a jQuery collection of elements.

@patik
patik / jQueryMobile Blackberry 6 collapsible content bug
Created February 10, 2011 21:09
On a Blackberry Bold 9650 running OS 6, collapsible elements do not expand/collapse properly. This workaround adds an event listener with a `setTimeout` of zero milliseconds.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BB6 Collapsible</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css">
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script>
$(document).ready(function() {
if (/blackberry/i.test(navigator.platform)) {
@patik
patik / custom.selector.test.html
Created December 10, 2011 22:16
Customized Zepto for fake selectors
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<style> .hidden { display: none; } </style>
<script src="zepto.custom.js"></script>
<script>
$(document).ready(function(e) {
// This should print 2 results: #div3 and #div4
console.log("visible:", $("div:visible"));
@patik
patik / scrollToHash.user.js
Last active September 28, 2015 21:28
Scroll to the heading that matches the URL hash
// ==UserScript==
// @name Scroll To Heading From Hash
// @author Craig Patik
// @namespace http://github.com/cpatik
// @version 1.0
// @description Enable jumping to any heading without adding IDs to the heading elements
// @include http://*
// ==/UserScript==
// Site owners can drop the code below into their pages,
@patik
patik / twitter-avatar-in-menu.user.js
Last active October 1, 2015 17:18
Twitter Avatar in Menu
// ==UserScript==
// @name Twitter Avatar in Menu
// @namespace http://patik.com/code/user-scripts/
// @include https://twitter.com/*
// @include http://twitter.com/*
// @version 2.1.20131118
// ==/UserScript==
(function _twitter_avatar_in_menu() {
// Find the generic 'person' outline in the nav bar, which will be replaced
@patik
patik / alpha-app-net-enhanced.user.js
Created August 30, 2012 22:20
Alpha.App.Net Enhanced
// @name Enhanced Alpha.App.Net
// @description Image previews, Repost links, and Twitter character count on Alpha.App.Net
// @namespace http://patik.com/code/user-scripts/
// @include https://alpha.app.net/*
// @version v20120903.1
// ==/UserScript==
(function _adnenhance_init(win) {
var adnenh = {};