Skip to content

Instantly share code, notes, and snippets.

View crswll's full-sized avatar
💾

Bill Criswell crswll

💾
  • Philadelphia, PA
  • 18:54 (UTC -04:00)
  • X @crswll
View GitHub Profile
@crswll
crswll / gist:4946635
Last active December 13, 2015 17:19
Just a quick demo for cloning and removing elements and updating their id for someone in IRC.
(function($){
$('.add').on('click', function(){
var $items = $('.items'),
$last = $items.find('.item').last();
$clone = $last.clone();
$clone.attr('id', function(idx, id){
@crswll
crswll / gist:5000214
Last active December 14, 2015 00:39
Quick script for Sean to get those remote images...
<?php
function get_product_images($url, $product_number, $sku)
{
if( empty($product_number) || empty($sku) || empty($url) ) return false;
$return = array(
'MediaItem1' => '',
'MediaItem2' => '',
@crswll
crswll / gist:5000244
Last active December 14, 2015 00:39
SSML for getting ProStores product data into a JS object.
<ss:if test="$request.getParameter('no')">
<ss:set name="product" value="$store.products.getProductWithNumber($request.getParameter('no'))"/>
<ss:if test="$product">
<script>
var product = {
name: "<ss:value source="$product.name" escape="javastring"/>",
price: [
<ss:foreach item="price" within="$product.finalPriceList">
<ss:value source="$price" format="none"/><ss:if test="$counter.isLast() == false">,</ss:if>
</ss:foreach>
@crswll
crswll / hashes
Created May 29, 2013 20:41
A person in IRC wanted some help with getting some #hashtags "highlighted" in a div.
$('.bio').html(function(i,html){
return html.split(' ').map(function(word){
if( word.substr(0,1) === '#' ){
return '<strong>' + word + '</strong>';
} else {
return word;
}
}).join(' ');
})
<div itemscope itemtype="http://schema.org/Product">
<div class="product-header">
<h1><ss:value source="$product.name"/></h1>
</div>
<div class="product-media">
<div class="product-media-main-image">
<ss:image itemprop="image" source="$product.defaultImage.medium" alt="$product.name"/>
@crswll
crswll / gist:7905125
Last active December 31, 2015 00:09
The data parameter needs to be the format of jQuery's .serializeArray(), which makes this really useful for cloning a form and keeping the input values in tact.
var populate = function ($form, data) {
var $inputs = $form.find(':input');
$.each( data, function (idx, field) {
var $ctrl = $inputs.filter(function(){
return this.name === field.name;
});
@crswll
crswll / SassMeister-input.scss
Created February 27, 2014 21:13
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
@mixin columnize ( $width, $end: 4 ) {
@for $i from 2 through $end {
@media ( min-width: $width * $i ) {
width: 100% / $i;
}
@crswll
crswll / SassMeister-input.scss
Created March 4, 2014 15:34
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
$foo: '.foo';
#{$foo} {
color: red;
#{$foo}:not(#{$foo}__b) {
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer');
var paths = {
styles: {
src: ['src/scss/**/*'],
dest: 'build/css'
}
};
@crswll
crswll / SassMeister-input.scss
Created June 5, 2014 15:35
Generated by SassMeister.com.
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.18)
// ----
// Reset 960GS
$reset960: (unquote('body, .alpha, .omega, .container_24'));
@for $i from 1 through 24 {
$reset960: append($reset960, unquote('.container_24 .grid_#{$i}'), comma);