Skip to content

Instantly share code, notes, and snippets.

@frankie-loves-jesus
frankie-loves-jesus / nsd.md
Created August 28, 2013 16:06
SERVFAIL for dig @localhost mydomain3.com. There's nothing in my logs, and mydomain1.com and mydomain2.com work fine.

/etc/nsd.conf

# cd /usr/ports/net/ldns/
# make install clean
#
# cd /etc/nsd/
#
# Generate zone signing key
#
#   ldns-keygen -a RSASHA1_NSEC3 -b 1024 <domain>
rvm install fails with rvm HEAD on OpenBSD 5.4:
```
% rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: openbsd/5.4/i386/ruby-1.9.3-p448.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for openbsd.
Installing requirements for openbsd.
Updating system - please wait
MKTEMP(1) OpenBSD Reference Manual MKTEMP(1)
NAME
mktemp - make temporary filename (unique)
SYNOPSIS
mktemp [-dqtu] [-p directory] [template]
DESCRIPTION
The mktemp utility takes the given filename template and overwrites a

Ubuntu 13.10

% npm install canvas

> canvas@1.1.2 install /home/myapp/my_node_app/node_modules/canvas
> node-gyp rebuild

make: Entering directory `/home/myapp/my_node_app/node_modules/canvas/build'
  CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.cc:19:0:
../src/JPEGStream.h:11:21: fatal error: jpeglib.h: No such file or directory

Images not working in Rails 4 -- Ruby brackets still in #main after bundle exec rake assets:precompile RAILS_ENV=production according to Chrome dev tools.

test.css.erb

#main { background-image: url(<%= asset_path 'main.png' %>); }

application.html.erb

Detecting mobile devices and tablets in 2014

The mobile world changes almost daily. Expanding on http://scottwb.com/blog/2012/02/23/a-better-way-to-add-mobile-pages-to-a-rails-site/ -- which is sorta old -- what do you guys think of this mobile and tablet detection scheme?

Use case: The mobile and desktop versions of my Rails app are very different. Although they share the majority of views, JS and CSS (using media queries where applicable), there are cases where I need mobile-only and desktop-only views, JS and CSS.

Code changes

All tablets should be treated as mobile.

unless user.nil?
forum = Forem::Forum.find_or_create_by_name(:category_id => Forem::Category.first.id, :name => "Default", :description => "Default forem created by install")
#########
topic1 = forum.topics.build({ :subject => "Test", :posts_attributes => [:text => "Hello World"] })
topic1.user = user
topic1.save!
#########

:paragraph not behaving as expected

This user input:

Hello,

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
% rake db:migrate
[...snip...]
% rake db:seed
rake aborted!
undefined method `id' for nil:NilClass
/home/dev/demo-search/db/seeds.rb:16:in `<top (required)>'
/home/dev/.rvm/gems/ruby-1.9.3-p448@brgen/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:223:in `load'
/home/dev/.rvm/gems/ruby-1.9.3-p448@brgen/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:223:in `block in load'
/home/dev/.rvm/gems/ruby-1.9.3-p448@brgen/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'

Rails 3

user.rb

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable