Skip to content

Instantly share code, notes, and snippets.

View chriscoyier's full-sized avatar

Chris Coyier chriscoyier

View GitHub Profile
@mikefowler
mikefowler / mq.scss
Created October 3, 2012 18:40
Retina Media Queries for Sass
// Based on Chris' post here: https://gist.github.com/3828790
@mixin respond-to($size) {
// Small
@if $size == "small" {
@media only screen and (min-width: 320px) {
@content;
}
@include handhelds {
table.responsive {
width: 100%;
thead {
display: none;
}
tr {
display: block;
}
td, th {
@funzeye
funzeye / WordPress Advanced Custom Field - Responsive Image Field
Last active November 26, 2015 21:53
How To Use Responsive Images in WordPress using Advanced Custom Field's image field and the wp-tevko-responsive-images Plugin
<figure>
<?php
$image = get_field('your_image_field_name');
$atts = array(
'imageid' => $image,
'size1' => '0',
'size2' =>'600',
'size3' =>'1000'
);
echo tevkori_responsive_shortcode($atts) ; ?>
@joshefin
joshefin / gist:4506897
Created January 11, 2013 00:11
Multipart cross domain post request with ajax
var data = new FormData();
form.find("input, textarea").each(function() {
var input = $(this);
if (input.attr("type") == "file")
data.append(input.attr("name"), input[0].files[0]);
else
data.append(input.attr("name"), input.val());
});
$.ajax({
<?php
function rkv_url_spamcheck( $approved , $commentdata ) {
$author_url = $commentdata['comment_author_url'];
$author_url_length = strlen($author_url);
if ($author_url_length > 50 )
$approved = 'spam';
// the old way :/
$.ajax({
url: "http://codepen.io/chriscoyier/pen/b2ad8b9a336845dd7b11d4bed34f4256.html",
complete: function(resp) {
// This HTML needs to be there first
$("body").append(resp.responseText);
// Because this script is going to do something with it.
@stryju
stryju / _normalize.scss
Created August 16, 2012 09:57
custom normalize
/*! normalize.css v1.0.0 | MIT License | git.io/normalize */
/*
* usage:
* @import "normalize";
*
* // this will print out ALL selectors
* @include normalize();
*
* // this will print out minimal set (*) -- you can see the list of "excluded" tags below
@norcross
norcross / url-spamcheck.php
Created April 26, 2013 17:41
checks the URL posted by a commenter
<?php
function rkv_url_spamcheck( $approved , $commentdata ) {
$author_url = $commentdata['comment_author_url'];
$author_url_length = strlen($author_url);
if ($author_url_length > 50 )
$approved = 'spam';
@acodesmith
acodesmith / wp-breadcrumb-home-info.php
Last active August 14, 2017 14:11
WordPress Breadcrumbs Data and HTML
<?php
/**
* @return object
*/
function get_breadcrumb_home()
{
return (object) [
'post_title' => __( 'Home', 'uncg-bryan' ),
'permalink' => site_url()
];
@JamieMason
JamieMason / watch.rb
Created September 26, 2012 08:16
Watch a folder for changes to files, then reload Chrome
#!/usr/bin/env ruby
require 'tempfile'
require 'fileutils'
# Signals
trap("SIGINT") { exit }
# Setup
TARGET_FOLDER = ARGV[0]
TARGET_URL = ARGV[1]