Skip to content

Instantly share code, notes, and snippets.

View zacwasielewski's full-sized avatar

Zac Wasielewski zacwasielewski

View GitHub Profile
@zacwasielewski
zacwasielewski / product-image-srcset.liquid
Last active September 2, 2021 09:29
Shopify responsive product images with srcset. Picturefill-compatible.
{% comment %}
Shopify responsive product images with srcset.
Example:
Include this snippet on a product page or within a products loop:
{% include 'product-image-srcset',
sizes: '(max-width: 640px) 50vw, (min-width: 641px) and (max-width: 960px) 33vw, 25vw' %}
@zacwasielewski
zacwasielewski / index.html
Created April 10, 2015 15:06 — forked from anonymous/index.html
Copy form data with jQuery
<form id="form1">
<input name="name" value="Zac">
<input name="address" value="407 French Road">
<select name="gender">
<option></option>
<option selected>Male</option>
<option>Female</option>
</select>
</form>
@zacwasielewski
zacwasielewski / edit.php
Last active August 26, 2017 15:02
Lock editing of BuddyPress profile fields. Plugin here: https://github.com/zacwasielewski/buddypress-lock-profile-fields/
<?php
/*
This snippet hides locked fields on the profile edit form.
Add to `wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/profile/edit.php`
immediately after <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> (near line 22):
*/
<?php if ( in_array( bp_get_the_profile_field_name(), bp_get_locked_profile_fields() )) { continue; } ?>
@zacwasielewski
zacwasielewski / persist_initial_options-selectize-plugin.js
Created September 12, 2014 02:21
Selectize.js plugin to load static options alongside remote options
Selectize.define('persist_initial_options', function(options) {
var self = this,
initialOptions = [];
this.onInitialize = (function() {
var original = self.onInitialize;
initialOptions = Object.keys(self.options);
})();
@zacwasielewski
zacwasielewski / dayone-launchcenterpro-foodlog
Created June 18, 2014 15:55
Day One + Launch Center Pro Food Log
dayone://post?entry=Food Log
|Food Log||
|:---|:---|
|Meal|[list: Which meal?|Breakfast|Lunch|Dinner|Snack]|
|Foods|[prompt:What did you eat?]|
|Notes|[prompt:Extra thoughts?]|
#food #log
@zacwasielewski
zacwasielewski / process_json_post.php
Created April 30, 2014 16:50
How to process a JSON POST request in PHP
<?php
if ($_SERVER['REQUEST_METHOD']=='POST') {
$json = json_decode(@file_get_contents('php://input'));
print_r($json);
}
@zacwasielewski
zacwasielewski / gist:9253346
Last active August 29, 2015 13:56
RegEx to convert all relative URLs in an HTML block to absolute URLs
<?php
$content = preg_replace('/(href|src)="((?!(.+:\/\/)|(.+:)|\/).*)"/','\1="/\2"',$content);
# Raw regex: (href|src)="(?!(.+://)|(.+:)|/).*"
@zacwasielewski
zacwasielewski / stocks.pl
Created December 5, 2013 17:00
Command-line Perl script for viewing stock portfolio performance
#!/usr/bin/perl
use LWP::Simple;
%stocks = (
'AAPL' => [{'q'=>100,'p'=>75.00 }],
'MXIM' => [{'q'=>100,'p'=>28.82 }],
'LLTC' => [{'q'=>200,'p'=>31.25 }],
'YHOO' => [{'q'=>100,'p'=>23.46 }],
'WU' => [{'q'=>125,'p'=>21.09 },
{'q'=>125,'p'=>21.97 }]
@zacwasielewski
zacwasielewski / gist:2794562
Created May 26, 2012 16:46
Gutter-free columns for Twitter Bootstrap
/*
Occasionally you need to eliminate the gutters from your grid columns. Include
this SCSS in your project and add a class of .row-nogutter to any <div class="row">
to magically remove its gutters. Not incredibly well-tested, but works for me.
This currently only works for standard (non-fluid) grids.
*/