Skip to content

Instantly share code, notes, and snippets.

@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 / _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 / 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 / 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 / magnet-links.user.js
Created January 12, 2014 18:52
Displays magnet links and other P2P URLs prominently. Great for sites that hide the real links between obnoxious "download" ad banners or open pop ups when you click on them.
@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;
}
@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;
});
// @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 / 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'])) {
@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>