Skip to content

Instantly share code, notes, and snippets.

@ryanriatno
ryanriatno / 0_reuse_code.js
Created October 4, 2016 15:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

tmux/tmuxinator cheatsheet

tmux

As configured in my dotfiles, here and here.

Command line

$ tmux                           -> start new
$ tmux new -s myname             -> start new w/session name
$ tmux a  #  (or at, or attach)  -> attach
$ tmux a -t myname               -> attach to named
@ryanriatno
ryanriatno / gist:a559d4eb8986c126227b
Created December 20, 2014 21:17
Fire $(window).resize() function after the browser window resize is completed
// http://stackoverflow.com/a/4541963
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);

Template Components

Used to provide structural templates.

Pattern

t-template-name
t-template-name--modifier-name
t-template-name__subcomponent-name--subcomponent-modifier-name
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@ryanriatno
ryanriatno / gist:4404803
Created December 29, 2012 05:53
Insert Ads inside Post Content
<?php
add_filter('the_content', 'rr_add_ad_inside_post');
function rr_add_ad_inside_post($content) {
if ( is_single() ) {
$paragraphAfter= 3; //display after the first paragraph
$content = explode("", $content);
for ($i = 0; $i <count ($content); $i++ ) {
if ($i == $paragraphAfter) { ?>
<p class="alignleft">
<script type="text/javascript"><!--
@ryanriatno
ryanriatno / wp-query-ref.php
Created October 6, 2012 21:09 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@ryanriatno
ryanriatno / gist:3846104
Created October 6, 2012 20:59 — forked from padolsey/gist:527683
Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@ryanriatno
ryanriatno / gist:3846045
Created October 6, 2012 20:41
HTML: Starting Template
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</body>
</html>
@ryanriatno
ryanriatno / wp-image-crop-position.php
Created September 8, 2012 09:54 — forked from bradt/wp-image-crop-position.php
WordPress: Set an image's crop position and rotates images based on EXIF information if necessary
<?php
/* Example Usage:
* bt_add_image_size( 'product-screenshot', 300, 300, array( 'left', 'top' ) );
* bt_add_image_size( 'product-feature', 460, 345, array( 'center', 'top' ) );
*/
add_filter( 'intermediate_image_sizes_advanced', 'bt_intermediate_image_sizes_advanced' );
add_filter( 'wp_generate_attachment_metadata', 'bt_generate_attachment_metadata', 10, 2 );
/**