Following line does't have /products.*
page. This tells Nginx to cache all product pages by default.
Idea is fast loading product pages will improve scalability of a store and also conversion.
Following line does't have /products.*
page. This tells Nginx to cache all product pages by default.
Idea is fast loading product pages will improve scalability of a store and also conversion.
// http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit | |
// form_submit('/contact/', {name: 'Johnny Bravo'}); | |
function form_submit(path, params, method) { | |
method = method || "post"; // Set method to post by default if not specified. | |
// The rest of this code assumes you are not using a library. | |
// It can be made less wordy if you use one. | |
var form = document.createElement("form"); | |
form.setAttribute("method", method); | |
form.setAttribute("action", path); |
// Requires that you set a custom field on the product with logo_src = image url | |
function sv_add_logo_above_wc_shop_image() { | |
global $product; | |
// replace the custom field name logo_src with your own | |
$logo_src = get_post_meta( $product->id, 'logo_src', true ); | |
// Add these fields to the shop loop if set | |
if ( ! empty( $logo_src ) ) { |
require 'rubygems' | |
require 'rspec' | |
require 'webmock' | |
require 'vcr' | |
require 'pry' | |
# in a Rails app, this would be in an initializer | |
WebMock.disable_net_connect!( | |
allow_localhost: true, | |
net_http_connect_on_start: true |
/(#([0-9a-f]{3}){1,2}|(rgba|hsla)\(\d{1,3}%?(,\s?\d{1,3}%?){2},\s?(1|0?\.\d+)\)|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?\)){2})/i |
class String | |
MORSE_CODE = { | |
a: '.-', b: '-...', c: '-.-.', d: '-..', e: '.', f: '..-.', | |
g: '--.', h: '....', i: '..', j: '.---', k: '-.-', l: '.-..', | |
m: '--', n: '-.', o: '---', p: '.--.', q: '--.-', r: '.-.', s: '...', | |
t: '-', u: '..-', v: '...-', w: '.--', x: '-..-', y: '-.--', z: '--..' | |
} | |
def to_morse_code | |
self.downcase.each_char.map { |c| MORSE_CODE[c.to_sym] }.join |
namespace :database do | |
task fat_tables: :environment do | |
c = ActiveRecord::Base.connection | |
max_table_name_width = 0 | |
tables = c.tables.sort_by do |t| | |
max_table_name_width = t.length if t.length > max_table_name_width |
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
I was curious about making retro gaming sounds using Sonic Pi. A couple of months and a lot of Googling later, here's the original Mario Bros theme as it was heard on the NES console.
I'm (just about) old enough to remember rushing home from school to play this game at Philip Boucher's house, sitting cross-legged in front of the TV till my feet got pins and needles. Working out how to recreate it for Sonic Pi was a lot of fun!
This list is based on aliases_spec.rb.
You can see also Module: RSpec::Matchers API.
matcher | aliased to | description |
---|---|---|
a_truthy_value | be_truthy | a truthy value |
a_falsey_value | be_falsey | a falsey value |
be_falsy | be_falsey | be falsy |
a_falsy_value | be_falsey | a falsy value |