Skip to content

Instantly share code, notes, and snippets.

@Godweed
Godweed / snippets.js
Created January 8, 2022 14:34 — forked from beautyfree/snippets.js
Solana Web3 Snippets
import {
Account,
clusterApiUrl,
Connection,
PublicKey,
sendAndConfirmTransaction,
SystemProgram,
Transaction,
} from '@solana/web3.js';
@Godweed
Godweed / README.md
Created December 7, 2017 09:41 — forked from ifnull/README.md
Using TOR as a proxy for Python on OSX
@Godweed
Godweed / gist:4c6bbf1ed92d628119f11e85f8ec9d8d
Created October 2, 2017 09:04
Add Google Tag Manager to Spree _google_analytics
<script>
dataLayer = [];
</script>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-NF7JL2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);

Add sorting to your product taxon page in Spree

So in following @berkes 'Add sorting to your product page in Spree' guide, I tried to repeat with my taxons controller. However there was no difference in order, despite the scopes being applied.

Another commenter Adam shared my frustration: 'How would I make this work for taxons as well? Everything I try doesn't work'.

After a little bit of research, I figured it out.

TL;DR

@Godweed
Godweed / product_filters.rb
Created August 30, 2017 15:28 — forked from Ranger-X/product_filters.rb
OptionValue filter
def ProductFilters.option_with_values(option_scope, option, values)
# get values IDs for Option with name {@option} and value-names in {@values} for use in SQL below
option_values = Spree::OptionValue.where(:presentation => [values].flatten).joins(:option_type).where(OptionType.table_name => {:name => option}).pluck("#{OptionValue.table_name}.id")
return option_scope if option_values.empty?
option_scope = option_scope.where("#{Product.table_name}.id in (select product_id from #{Variant.table_name} v left join spree_option_values_variants ov on ov.variant_id = v.id where ov.option_value_id in (?))", option_values)
option_scope
end
# option scope
@Godweed
Godweed / index.html
Created April 2, 2017 13:51
Physics of fabric on JS.
<canvas id = "c" > </canvas>
<p>
Tear the cloth with your mouse.<br><br>
Right click and drag to cut the cloth.<br><br>
Reduce physics_accuracy if it's laggy, increase it for a better effect.
</p>
<a target="_blank" href="http://lonely-pixel.com/">my website (in progress, soon to be a javascript experiment showcase)</a>
@Godweed
Godweed / Spree: Filter by brand.md
Created December 17, 2016 07:33 — forked from maxivak/Spree: Filter by brand.md
Spree: Filter Products by properties

Fix 'scoped' error for Rails 4

error: undefined method 'scoped' solution:

# config/initializers/scoped.rb
class ActiveRecord::Base
  # do things the modern way and silence Rails 4 deprecation warnings
 def self.scoped(options=nil)

options ? where(nil).apply_finder_options(options, true) : where(nil)