Skip to content

Instantly share code, notes, and snippets.

@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 = {};
@patik
patik / wysihtml5.multi.example.html
Created September 3, 2012 19:59
wysihtml5 mulitiple editors issue
<div id="alpha-toolbar"><!-- Toolbar commands here --></div>
<textarea id="alpha"></textarea>
<div id="bravo-toolbar"><!-- Toolbar commands here --></div>
<textarea id="bravo"></textarea>
<div id="charlie-toolbar"><!-- Toolbar commands here --></div>
<textarea id="charlie"></textarea>
@patik
patik / adn-auth.php
Created October 11, 2012 17:17
ADN auth issue
<?php
require_once('keys.php'); // Where my constants are defined
require_once('AppDotNet.php');
$clientId = ADN_CLIENT_ID;
$clientSecret = ADN_CLIENT_SECRET;
$redirectUri = ADN_REDIRECT_URI;
# User has authorized:
if (isset($_GET['code']) && !empty($_GET['code'])) {
// @name Redirect from WikiTravel to WikiVoyage
// @description Automatically switch from a WikiTravel.org article to the same article on WikiVoyage.org
// @namespace http://patik.com/code/user-scripts/
// @include http://wikitravel.org/*
// @version v20130218.1
// ==/UserScript==
(function _wikivoyage_redir (win) {
// Example
// Before: http://wikitravel.org/en/Bangkok/Sukhumvit
@patik
patik / insertAfterEveryFromRight.js
Last active December 17, 2015 11:19
A CodePen by Craig Patik (http://cdpn.io/mtHBd)
var insertAfterEveryFromRight = function _insertAfterEveryFromRight(str, insert, every) {
var result = '';
str.split('').reverse().forEach(function(s, idx) {
if (idx !== 0 && idx % every === 0) {
result += insert;
}
result += s;
});
@patik
patik / app.css
Last active December 22, 2015 11:48
Transition height/width to `auto` by defining the transition in CSS
.expandable {
transition-property: none;
transition-duration: .5s;
transition-timing-function: ease-in-out;
}
/* Vary the transition with different classes */
.expandable.molasses {
transition-duration: 3s;
}