Skip to content

Instantly share code, notes, and snippets.

View scott-riley's full-sized avatar
🎯
Focusing

Scott Riley scott-riley

🎯
Focusing
View GitHub Profile
@scott-riley
scott-riley / gist:9599668
Last active August 29, 2015 13:57
Changing placeholder via media query
// Nice way, using matchMedia, no IE9 or below support
var media = "screen and (min-width: 720px)",
placeholderShort = "Short holder",
placeholderLong = "My quite long placeholder";
$(window).resize(function(){
if(window.matchMedia(media).matches) {
$('.element').attr('placeholder', placeholderLong);
}
else {
$('.element').attr('placeholder', placeholderShort);
function clean_custom_footer_menus() {
$menu_name = 'footer-links'; // specify custom menu slug
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '';
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
$list = $('.collections__list');
$item = $list.find('.list__item--is-selected');
$prev = $item.prev();
$prepended = false;
if ($(window).width() < 700 && $item.index() != 0 && !prepended) {
$list.prependTo('.collections__list');
prepended = true;
}
else if ($(window).width() > 700 && prepended) {
var items = "",
data = ["your json data"]
$.each(json, function(i, item){
items += data[i] ; // simplest example
});
// this is fine because a .each is synchronous and doesn't need a callback
$('[data-json-container]').append(items);
import React, { Component, PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './ProgressBar.scss';
class ProgressBar extends Component {
render() {
const {completed} = this.props;
import React, { Component, PropTypes } from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './ProgressContainer.scss';
class ProgressContainer extends Component {
constructor(props) {
super(props);
// actions/index.js
/* Team actions */
export function fetchTeams() {
const request = axios.get(`${ROOT_URL}/teams${ACCESS_TOKEN}`);
return {
type: FETCH_TEAMS,
payload: request
};
}
import babelPolyfill from "babel-polyfill";
import koa from "koa";
import koaProxy from "koa-proxy";
import koaStatic from "koa-static";
import gzip from "koa-gzip";
import React from "react";
import ReactDOM from "react-dom/server";
import * as ReactRouter from "react-router";
import * as history from "history";
import Transmit from "react-transmit";
{
"email": "[email protected]",
"fields": {
"name": "A super dope client",
"website": "clientisgr8.com",
"subject": "Product redesign",
"budget": "$40,000",
}
}
# Put me in ~/.atom/snippets.cson
'.source.js':
'import connect':
'prefix': 'cn'
'body': "import {connect} from 'react-redux';"
'export connect':
'prefix': 'ecn'
'body': "export default connect(mapStateToProps)(${1:MyComponent});"
'import React + Component':