• Blog

    Dream Conception

    Everything from Entrepreneurship, nerd talk to personal ramblings

Electron: How to build, package and sign 3rd-party binaries with Electron-Builder

Working on Blazing Bookkeeper, an ORC based document scanner, I had to build and package various libraries and binaries through electron-builder. I couldn’t find any guides detailing this, so I’ll outline the process we took to make it work.

Rails 4: Add data-error attribute to form field instead of using wrapper

I wanted to have data-error on the form field instead of the standard rails error wrapper <div class="field_with_errors"></div>. With a data attribute we can do some much nicer handling of the form field.

Non-obtrusive multi-language redirection (with RoR example)

At Spaces we’ve implemented a non-obtrusive redirection for our multi-language, multi-domain websites. Too many websites have the awful habit of forcing content to visitors that the visitor didn’t request in the first place.

How and why we implement Intercom to only load when required (maintaining the privacy of our users)

At Spaces we’ve been looking into various way of offering support. Intercom seemed to be a great solution, but we were surprised to see the lack of privacy, in that they record personal information for anyone who simply sign in by default.

The Intercom rails gem collected user id, email, name, and sign up date by default. We contacted them about how we could increase the privacy, and the response was in short that we had to use their API with a far worse UX, if we even could get that to work in the first place.

How to retry SSH, API, and external connections in Rails 4

This is pretty much a no-brainer, but in case you’re in doubt, this is an easy way to retry external connections. This way you don’t automatically halt the application at the slightest network issues.

I’m using Peakium as an example of API connection, but you can do this with pretty much anything as long as you rescue from the right exception type (should only be in case there is connectivity issue).

# models/concerns/peakium_retry.rb
module PeakiumRetry
  def peakium_retry(&block)
    retries = 1
    begin
      block.call
    rescue Peakium::APIConnectionError => e
      raise e if retries == 0
      retries -= 1
      sleep 0.5
      retry
    end
  end
end

This will retry the connection one time if failing (waiting half a second between tries), and throw the exception if it fails again.

You will just do the call like this:

events = peakium_retry do
  Peakium::Event.all(params, peakium_access_token).data
end

Straight forward, and easy.

Rails: How to fix issue with unique number under scope that doesn’t count correctly with find_or_create_by

The bug fixing was very frustrating. Take a look at the following example:

class Model < ActiveRecord::Base
...
  # Set a unique scoped number
  validate do
    errors.add(:scoped_unique, "is already taken") if parent_parent_model.parent_model.models(true).where(scoped_unique: scoped_unique).where.not(id: id).present?
  end
  before_validation on: :create do
    self.scoped_unique = (parent_parent_model.parent_model.models(true).collect { | model | model.scoped_unique }.max.to_i || 0) + 1 if self.scoped_unique.nil?
  end
...
end

This works just fine when you are creating a new model like this:

parent_model.models.create(...)

However using find_or_create_by it adds unexpectedly additional parameters to the scope the model itself with the parent_model (thus not restricting itself to parent_parent_model only)!

parent_model.models.create_with(...).find_or_create_by(...)

Turns out you have to unscope the whole query:

class Model < ActiveRecord::Base
...
  # Set a unique scoped number
  validate do
    Model.unscoped do
      errors.add(:scoped_unique, "is already taken") if parent_parent_model.parent_model.models(true).where(scoped_unique: scoped_unique).where.not(id: id).present?
    end
  end
  before_validation on: :create do
    Model.unscoped do
      self.scoped_unique = (parent_parent_model.parent_model.models(true).collect { | model | model.scoped_unique }.max.to_i || 0) + 1 if self.scoped_unique.nil?
    end
  end
...
end

Rails: button_to with [data-confirm] tries to confirm tries and nothing happens

If you are using jquery-ujs and happens to get two confirm dialogs when using [data-confirm] with a button, all you have to do is put the data confirm attribute in a form attribute:

Before:

<%= button_to registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete do %>
    Cancel my account
<% end %>

After

<%= button_to registration_path(resource_name), form: { data: { confirm: "Are you sure?" } }, method: :delete do %>
    Cancel my account
<% end %>

April fools: Dream Conception becomes interplanetary

In 2010 Dream Conception were in negotiations with a group of entrepreneurs who wants to do a reality show of the first colony on Mars. Dan Schultzer from Dream Conception actually got the offer to go as one of the “pilgrims”. This decision would disrupt the team of Dream Conception so they found a synergy with their current goals.

Rails: Unique constraint and acts_as_list

Here’s a quick tip to fix issues with unique constraints and acts_as_list gem. The issue stems from the moving model’s position not being set to NULL during the move.

Rails 4: How to set parent model on both left and right side in a has_many :trough relationship, models being created with nested attributes

Let’s say you have a many-to-many setup, with same parent for both left and right side. You might want to create an account, with a user and a project in one go.

Fix nokogiri install issue on Mac OS X 10.9

When installing nokogiri 1.6.1 on my RubyStack installation with Mac OS X Mavericks I got the following error.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

Running ‘configure’ for libxml2 2.8.0… ERROR, review ‘tmp//ports/libxml2/2.8.0/configure.log’ to see what happened.

The configure.log said that the gcc/make could not be found. While figuring it out I found a lot of issues, and the information for fixing them was all deprecated.

The following steps solved my issues completely:

# sudo xcode-select -switch /Library/Developer/CommandLineTools
# gem uninstall nokogiri libxml-ruby
# gem update --system
# gem install nokogiri

Gem update is unnecessary, but good to have just in case. Hope this helps.

Best refund policy for a SaaS company?

Prompted by a Quora post, let me describe what our experiences is at Dream Conception.

Publicly we tell our customers that we will refund the last 30 days as well. However, with seriously disgruntled customers we just refund the amount they feel they have paid unfairly for. That reputation of fairness and openness is worth much more, than the little money we gain by withholding the money. In our experience, customers rarely ask for more than they feel is fair, and we wish to take the side of the customer.

I don’t believe that a hardline approach such as “never more than 30 days refund” is right for customer support. It needs to be based on each individual case, and the 30 days should only be used as a guideline. Not as a rule.

In a SaaS company, a refund shouldn’t matter to the company. If it does, most likely there is more serious underlying problems.

Display your technical documentation easy and beautifully

A few days ago we open sourced our documentation presenter to allow anybody to easily display their technical documentation online.

The presenter accepts markdown (to some degree github flavored) and HTML, and can be easily extended to other formats. This tool saves you time by allowing you to keep all your documentation in git repositories. It can download both archives and directly from git repository, with automatic version tracking.

The future of documentation is to allow for flexibility in your team, while keeping presentation easy. Everybody in your team, no matter technical experience should be able to edit your documentation. The documentation should be resistant to any changes in presentation (design of website, printed markup, and the list goes on) in the future. By using markdown (or other light-weight markup format), you will achieve this and keep life easy for your team. A step further is to add your documentation online at github. You will allow for your users to help perfecting the information, and keep an open community around you.

Set up your technical documentation in a minute right now. You are more than welcome to fork and improve it.

Git: https://github.com/danschultzer/peakium-documentation-viewer
Demo: http://docs.peakium.com/

Perfect for API and technical documentation, but there is no limits.

Install phalcon with MAMP

This is instructions on how to compile and install the phalcon extension on Mac OS X (Lion), along with command-line tools. Everything will be done through the terminal, except installation of Xcode and the command-line tools.

How to secure your MAMP files with Dropbox

In this post I will describe the setup I use with Dropbox to secure all my important MAMP data.

Background: I like to have my MAMP and development environment backed up in case of getting a new computer, my hard disk crash, or anything happens to the data. I can get right back to where I left. It is not a good idea to just put the whole MAMP directory on Dropbox, because you would not want to back up temporary files. I do want to back up binaries, MAMP itself, and any files I need to actually start MAMP on a different computer.

Peakium is opening up

I’m pleased to announce that we have completed second stage of Peakium, the global flexible recurring payment system.

The second stage means that Peakium is fully ready for heavy duty usage. We are still iterating, and making everything run as smooth as possible with most possible transparency.

We have had three goals in mind with Peakium:

  • No lock-in. It has to be easy switch between payment processors, and if one day your business is specialised enough, it has to be easy to switch from Peakium to your own system as well. Personally I would also like to see that we encourage more flexible payment options, and increase competitions for the best payment gateway rates.
  • Extreme flexible subscription terms. Your app/data setup will decide what setup the subscriptions should be, while Peakium will make all the “behind-the-scenes” works. No limitations at all, and you will keep the setup in just one place, your end.
  • Easy to work with. Have to give up on adding some payment features because it simply takes too much time, or are too complicated? We know the hardships of archaic gateways and building specialised payment subscriptions all too well, and that is one of the reasons Peakium exists today!

Peakium is ready to slay the subscription payment monster! We are supporting gateways that together covers almost all countries in the world!

If Peakium sounds like the answer to your prayers, I would be more than happy to include you in the private beta!

Just hit me with an email or tweet!

Dream big,
Dan Schultzer

How set yourself free

I was around 10 years old, and I was walking with my mom down a street towards our house after doing some shopping. While walking back to our house, I asked my mom if she understood that I would not live in this country when I grow older. My mom, being painfully aware of my passion for living as a world citizen, answered that I should not be saying those things, because “I know too well that it will happen, but right now you are still my little boy, and I do not wish to imagine you not being here”.

The… Read more »

Elegant flexible (automatic) coloring in Javascript

In this piece I will show you how you can calculate esthetic colors using Javascript. In this particular case the result will be a glossy button, but this technique can be used for anything.

Background: At cSupport we have a very different idea of how to work with design. While most of our competitors use fixed templates, or have a huge palette where you need to decide every single color, we believe that it should be much more straight forward, and elegant. Give us one color, and we will calculate everything else needed for delivering a gorgeous layout. We have used this setup for more than 2 years now, and I think it is time for us to reveal how!

Asynchronous (non-blocking) lazy loading of external javascript

Here’s a simple solution to the issue of having external javascript components make your page look like it loads slow. Of course, if you need the javascript “as soon as possible” (meaning that you wish the javascript to run at the same time as your page is rendered), then you should not do this. Instead just go for an asynchronous load.

#twitter7

As you probably have noticed twitter (or twttr) has turned 7, and boy a lot have happened since 2006.

Seven years ago I had just turned 20. Back then I came from a failed online store for Mac games, going through military service, and I was going to start working as a humble mail carrier! I was saving up money to turn my old childhood dream into reality; my dream of living abroad.

Read more »

How to install mysqldb (mysql-python) on MAMP

This is instructions how to setup so you can run mysql enabled python apps using MySQL on your MAMP installation. These instructions are written for installation of CMake, PIP, mysql-python (mysqldb), along with XCode command-line tools. Everything will be done in the terminal, except installation of XCode, the command-line tools, CMake and MAMP Components dmg fie.

This will be a bit long, as there is some issues that needs to be dealt with for it to work. It is straight forward though!

Why programming is essential learning

Programming is an artform. To know how to code is to be able to speak a language, in which you transform your ideas into reality. The joy when building your first application, and see it work, as you specifically told the machine it should, is simply amazing. Just as a kid learning to read stories for the first time.

Now, why should you learn to code? Read more »

Install python support (mod_wsgi) on MAMP

This is instructions how to setup so you can run python applications through Apache 2 on your MAMP installation. This is instructions on how to install the mod_wsgi module on Mac OS X (Lion), along with command-line tools. Everything will be done in the terminal, except installation of XCode and the command-line tools.

Install intl extension with MAMP

This is instructions on how to compile and install the intl extension on Mac OS X (10.7+), along with command-line tools, and ICU. Everything will be done through the terminal, except installation of Xcode and the command-line tools.

The Importance Of Being Consistent

Life can be difficult. Crossing the ocean will bring upset water, the same way journey in life will bring you difficult times. It is a truth that all people have experienced at some points in their life when trying to reach a goal, or level of consistency. That be in startups, exercise, and other dedicated lifestyle choices.

Measure your server performance Monit-Graph

At Dream Conception we are focused in entrepreneurship, and startups. Also we have a high degree of technical experience which we use to make our daily life easier. For most startups open source software is vital. Without open source it would have been impossible to create the technological startups we see today.

“Entrepreneurs can change the world”

We found this great video of what it means to be an entrepreneur, and think it’s excellent to somewhat describe the energy and passion that runs in entrepreneurs veins. Enjoy!

The start-up of an organization

From creating an idea to actually having an up and running project can be a long process. At Dream Conception, we’ve been working extremely hard to get this up and running. From the first meetings of conceiving an idea, to building the concept, and actually having all product information ready, with projects in the pipeline, to a fully functioning running organization.

We are proud to present our work here and offer a glimpse of what we’ve been going through. First off, we have treated building Dream Conception as any other project in this organization. There is no difference at all in creating the contracts, making work plans, keeping deadlines, and holding periodic meetings. This is crucial to our product, since we have hands-on experience with any issues that may exist.