Skip to content

Instantly share code, notes, and snippets.

@justinshreve
justinshreve / wc-refund-item-info.php
Last active February 21, 2017 18:56
WooCommerce: Get item info from refunds
<?php
// Get items from all refunds
$refunds = array();
$refund_items = get_posts( array(
'post_type' => 'shop_order_refund',
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids'
) );
@bentasm1
bentasm1 / functions.php
Created November 12, 2015 17:16
WC Vendors Pro -- Change defaults for Stock Management / Quantity / Sold Individually
/* Credit to @criticalachievement */
// Changes the default value for manage stock checkbox to checked
add_filter( 'wcv_product_manage_stock', 'change_default_manage_stock' );
function change_default_manage_stock() {
$field['post_id'] = $post_id;
$field['id'] = '_manage_stock';
$field['wrapper_class'] = 'show_if_simple show_if_variable';
@digitalchild
digitalchild / product-edit.php
Last active October 26, 2016 05:29
Custom Product Fields - WC Vendors Pro
<?php
// This will be available in the next version of WC Vendors Pro
// Input type of text on the product-edit.php template
WCVendors_Pro_Form_Helper::input( array(
'post_id' => $object_id,
'id' => '_wcv_custom_product_dispatch_days',
'label' => __( 'Dispatch Days', 'wcvendors-pro' ),
'placeholder' => __( '1 day', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'The number of days to dispatch.', 'wcvendors-pro' ),
@mockdeep
mockdeep / bulk_updateable.rb
Created October 29, 2015 17:13
module to add ActiveRecord bulk update functionality for postgres
module BulkUpdatable
def bulk_update(objects, attribute)
return unless objects.any?
query = build_query_for(objects, attribute)
connection.execute(query)
end
private
@ebrelsford
ebrelsford / nycproj2latlon.sql
Last active December 21, 2015 05:39
Convert a table with coordinates in NAD_1983_StatePlane_New_York_Long_Island_FIPS_3104_Feet (common for NYC data) to lat and lon in 4326. We first convert the coordinates from feet to meters.
UPDATE graffiti_locations
SET the_geom = ST_Transform(
ST_SetSRID(
ST_MakePoint(x * 0.3048006096012192, y * 0.3048006096012192),
32118),
4326
)
@sononum
sononum / gist:6183139
Created August 8, 2013 09:26
accelerate Kaminari with Postgres insert into config/initializers/kaminari.rb
module Kaminari
module PageScopeMethods
def total_count
@_hacked_total_count || (@_hacked_total_count = self.connection.execute("SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname ='#{table_name}'").first["reltuples"].to_i)
end
end
end
@claviska
claviska / pretty-buttons.less
Last active October 21, 2022 22:25
A Less mixin' for pretty buttons with Bootstrap 3
.pretty-buttons(@color, @background, @text-shadow: none) {
color: @color;
#gradient > .vertical(lighten(@background, 5%), darken(@background, 5%), 0%, 100%);
border-color: darken(@background, 10%);
border-bottom-color: darken(@background, 20%);
text-shadow: @text-shadow;
.box-shadow(inset 0 1px 0 rgba(255, 255, 255, .1));
&:hover,
@djq
djq / gist:2846196
Last active September 27, 2022 04:12 — forked from rolo/gist:1481128
Install Postgres 9.1, PostGIS 2.0.2 and PG Routing on Ubuntu 12.04 (Precise Pangolin)
#!/bin/bash
#
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit)
# updated to PostGIS 2.0.1
# basics
apt-get install python-software-properties
apt-add-repository ppa:sharpie/for-science # To get GEOS 3.3.3
# install the following pacakages
@cblunt
cblunt / Gemfile
Created October 21, 2011 08:55
Configure Carrierwave for Amazon S3 Storage and Heroku
# ...
gem 'carrierwave'
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL
@isaacbowen
isaacbowen / will_paginate.rb
Created August 30, 2011 21:37
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer