Create a sales functionality within Spree 2.3 using Spree fancy
Introduction
I recently started working with Spree and wanted to learn how to implement some basic features. I focused on one of the most common needs of any e-commerce business—adding a sale functionality to products. To get a basic understanding of what was involved, I headed straight to the Spree Developer Guides. As I was going through the directions, I realized it was intended for the older Spree version 2.1. This led to me running into a few issues as I went through it using Spree’s latest version 2.3.4. I wanted to share with you what I learned, and some tips to avoid the same mistakes I made.
Set-up
I’ll assume you have the prerequisites it lists including Rails, Bundler, ImageMagick and the Spree gem. These are the versions I’m running on my Mac OS X:
- Ruby: 2.1.2p95
- Rails: 4.1.4
- Bundler: 1.5.3
- ImageMagick: 6.8.9-1
- Spree: 2.3.4
What is Bundler? Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. You can read more about the benefits of using Bundler on their website. If you’re new to Ruby on Rails and/or Spree, you’ll quickly realize how useful Bundler is when updating your gems.
After …
ecommerce rails spree
Can we Server Name Indicate yet?
The encryption times, they are a-changin’.
Every once in a while I’ll take a look at the state of SNI, in the hopes that we’re finally ready for putting it to wide-scale use.
It started a few years back when IPv6 got a lot of attention, though in reality very few end user ISPs had IPv6 connectivity at that time. (And very few still do! But that’s another angry blog.) So, essentially, IPv4 was still the only option, and thus SNI was still important.
Then earlier this year when Microsoft dropped [public] support for Windows XP. Normally this is one of those things that would be pretty far off my radar, but Internet Explorer on XP is one of the few clients* that doesn’t support SNI. So at that time, with hope in my heart, I ran a search through the logs on a few of our more active servers, only to find that roughly 5% of the hits are MSIE on Windows XP. So much for that.
(* Android < 3.0 has the same problem, incidentally. But it in contrast constituted 0.2% of the hits. So I’m not as worried about the lack of support in that case.)
Now in fairly quick succession a couple other things have happened: SSLv3 is out, and SSL certificates with SHA-1 signatures are out. This has me …
tls sysadmin security
Dear PostgreSQL: Where are my logs?
When debugging a problem, it’s always frustrating to get sidetracked hunting down the relevant logs. PostgreSQL users can select any of several different ways to handle database logs, or even choose a combination. But especially for new users, or those getting used to an unfamiliar system, just finding the logs can be difficult. To ease that pain, here’s a key to help dig up the correct logs.
Where are log entries sent?
First, connect to PostgreSQL with psql, pgadmin, or some other client that lets you run SQL queries, and run this:
foo=# show log_destination ;
log_destination
-----------------
stderr
(1 row)
The log_destination
setting tells PostgreSQL where log entries should go. In most cases it will be one of four values, though it can also be a comma-separated list of any of those four values. We’ll discuss each in turn.
Syslog
Syslog is a complex beast, and if your logs are going here, you’ll want more than this blog post to help you. Different systems have different syslog daemons, those daemons have different capabilities and require different configurations, and we simply can’t cover them all here. Your syslog may be configured to send …
postgres logging
Finding specific Git commit at a point in time
When using Git, being able to track down a particular version of a file is an important debugging skill. The common use case for this is when someone is reporting a bug in your project, but they do not know the exact version they are using. While normal software versioning resolves this, bug reports often come in from people using the HEAD of a project, and thus the software version number does not help. Finding the exact set of files the user has is key to being able to duplicate the bug, understand it, and then fix it.
How you get to the correct set of files (which means finding the proper Git commit) depends on what information you can tease out of the user. There are three classes of clues I have come across, each of which is solved a different way. You may be given clues about:
- Date: The date they downloaded the files (e.g. last time they ran a git pull)
- File: A specific file’s size, checksum, or even contents.
- Error: An error message that helps guide to the right version (especially by giving a line number)
Finding a Git commit by date
This is the easiest one to solve. If all you need is to see how the repository looked around a certain point in …
git
Where is pg_ctl on CentOS 6 for Postgres 9.3?
When installing PostgreSQL 9.3 onto a CentOS 6 system, you may notice that some postgres commands appear to be missing (like pg_ctl, initdb, and pg_config). However, they actually are on your system but just not in your path. You should be able to find them in /usr/pgsql-9.3/bin/. This can be frustrating if you don’t know that they are there.
To solve the problem, you could just use full paths to these commands, like /usr/pgsql-9.3/bin/initdb, but that may get ugly quick depending on how you are calling these commands. Instead, we can add them to the path.
You could just copy them to /usr/bin/ or create symlinks for them, but both of these methods are hack-ish and could have unintended consequences. Another option is to add /usr/pgsql-9.3/bin/ to your path manually, or to the path for all users by adding it to /etc/bashrc. But again, that seems hack-ish and when you upgrade postgres to 9.4 down the road things will break again.
So instead, let’s look at how Postgres’ other commands get installed when you install the rpm. When you run “yum install postgresql93” the rpm contains not only all the files for that package but it also includes some scripts to run (in this case one at …
redhat postgres
Simplifying mobile development with Ionic Framework
My high school math teacher used to say that mathematicians are the laziest people on Earth. Why? Because they always look for clever ways to simplify their work.
If you stop and think about it, all that technology is, is just simplification. It’s taking the infinitely complex world and turning it into something sterile and simple. It’s all about producing simple models with a limited number of elements and processes.
Today I’d like to walk you through creation of a mobile app that could be used on iOS, Android or Windows Phone. We’ll use a very cool set of technologies that allow us to switch from using multiple languages and frameworks (Objective-C for iOS, Java for Android and C# for Windows Phone) to just using HTML, CSS and JavaScript.
Let’s start turning complex into simple!
PhoneGap and Ionic Framework
Creating the project
In order to be able to start playing along, you need to get yourself a set of toys. Assuming that you’ve got NodeJS and Npm installed already, all you have to do is:
$ npm install -g cordova ionic
Now you should be able to create the project’s scaffold. We’ll be creating a simple app that will list all the latest cartoons from the xkcd blog. Let’s call it …
android angular css html ios javascript mobile
CSS table-cells ::before and ::after
When laying out HTML forms, instead of using a table (re: tables-are-only-for-tabular-data et al), I’ve had good results making use of the table family of values for the CSS display property. I find it a reliable way to ensure items line up in a wide range of situations, a change in the size of labels or a resize of the browser’s window for example.
Something simple like the following has worked well for me on several occasions:
.table {
display: table;
}
.table>* {
display: table-row;
}
.table>*>* {
display: table-cell;
}
Occasionally though, I’ve wanted to leave a column empty for one reason or another. To accomplish this I found myself including empty HTML tags like:
<form class="table">
<div>
<div>A Cell</div>
<div>A Cell</div>
</div>
<div>
<div></div>
<div>A Cell</div>
</div>
</form>
The empty elements function well enough but they feel a little out of place. Recently I came up with a solution I like better. By using the CSS ::after and ::before selectors, you can insert an arbitrary element that can take the place of a missing cell. The …
css html
OpenSSL CSR with Alternative Names one-line
2017-02-16—Edit—I changed this post to use a different method than what I used in the original version cause X509v3 extensions were not created or seen correctly by many certificate providers.
I find it hard to remember a period in my whole life in which I issued, reissued, renewed and revoked so many certificates.
And while that’s usually fun and interesting, there’s one thing I often needed and never figured out, till a few days ago, which is how to generate CSRs (Certificate Signing Requests) with AlternativeNames (eg: including www and non-www domain in the same cert) with a one-liner command.
This need is due to the fact that some certificate providers (like GeoTrust) don’t cover the parent domain when requesting a new certificate (eg: CSR for www.endpoint.com won’t cover endpoint.com), unless you specifically request so.
Luckily that’s not the case with other Certificate products (like RapidSSL) which already offer this feature built-in.
This scenario is starting to be problematic more often since we’re seeing a growing number of customers supporting sites with HTTPs connections covering both www and “non-www” subdomains for their site.
Luckily the solution is pretty simple …
security sysadmin tls