railway.at

Create a directory .ssl in your home directory. Go there and create a self-signed certificate. It is important to enter localhost.ssl as Common Name when asked. This...

...action and :except => :some_unsafe_action as options. Boot thin thin start -p 3001 --ssl --ssl-key-file ~/.ssl/server.key --ssl-cert-file ~/.ssl/server.crt The option -p tells thin to bind...

kernel.org

...merge in the file named with %A by overwriting it, and exit with zero status if it managed to merge them cleanly, or non-zero if there were conflicts...

Usage $ git diff --help Options: -M[ ], --find-renames[= ] Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the...

...file’s size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a % sign...

makandra dev
select2.org

Select2 comes with AJAX support built in, using jQuery's AJAX methods. ... For remote data sources only, Select2 does not create a new element until the item has been selected...

query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax

...pattern below. The module pattern gives you basic class concepts like a constructor, private state, public methods. Since the module pattern only uses basic JavaScript, your code will run in...

...that we want to translate into Javascript using the module pattern. It's a simple class with one private function: # Ruby class Dog def initialize(name) @name = name

Disabling auto-complete in login forms is probably a bad idea, since it encourages weak passwords. If you are still forced to implement this (maybe due to legal or policy...

...requirements), this is how: Prevent browsers from saving the password in the first place. Disabling autocomplete does not improve security. How to prevent password saving: To prevent the browser from...

...Rails and the copied gem. This notes describes what to do. With Bundler This is super-painful. If you just copy the gem to vendor/gems, Rails will complain:

Fun fact: Our install-gems-remotely script is aware of vendored gems and will scp-copy them to the remoty server. Without Bundler Don't use gem unpack since...

end class Invitation < ActiveRecord::Base belongs_to :party belongs_to :user after_create :send_invite def send_invite other_user_names = party.users.collect(&:name) message = "You've been invited. Also...

end end When creating a party and lots of invitations, you want to send an e-mail to each user and tell them who else is coming. Unfortunately, accessing...

...dbi:ODBC:MyLegacyServer', 'my_name', 'my_password') DBI::DatabaseError: INTERN (0) [RubyODBC]Cannot allocate SQLHENV from /usr/lib/ruby/1.8/dbd/odbc/driver.rb:36:in `connect' from /usr/lib/ruby/1.8/dbi/handles/driver.rb:33:in `connect' from /usr/lib/ruby/1.8/dbi.rb:148:in `connect...

...from /usr/local/lib/site_ruby/1.8/rubygems/dependency_list.rb:14 I installed the gem ruby-odbc instead of the guide's sudo aptitude install libdbd-odbc-ruby sudo gem install ruby-odbc #Successfully installed ruby-odbc...

...file, that don't use Ruby's logger utility, it is often useful to sync them. So other process can read the output just in time. Example with enabled sync...

File.read(log_path) #=> "Some log message\nSome other message\n" Example with disabled sync (default) log_path = '/tmp/some_log.log' log_file = File.open(log_path, 'a+') log_file.puts('Some log message')

When you want the table headers to always stay around (e.g. because that table is huuuge), use the code below. Style table.fixed_table_header{ position: fixed; top: 0;

...each(function(index) { $(this).css("min-width",$table.find("th").eq(index).width()+"px"); }); } function scrollFixed() { var offset = $(this).scrollTop(), tableOffsetTop = $table.offset().top, tableOffsetBottom = tableOffsetTop + $table.height() - $table.find("thead").height(); if(offset...

In theory you can take any scope and extend it with additional joins or conditions. We call this chaining scopes. In practice chaining becomes problematic when scope chains grow more...

...complex. In particular having JOINs in your scope will reduce the scope's ability to be chained with additional JOINs without crashes or side effects. This is because ActiveRecord doesn...

...to optimize powers that only check access to a given record. e.g. Power.current.post?(Post.last). See below for details. Powers that only check a given object Sometimes it is not convenient...

...to define powers as a collection. Sometimes you only want to store a method that checks whether a given object is accessible. To do so, simply define a power that...

tl;dr: Always have your attachment path start with :rails_root/storage/#{Rails.env}#{ENV['RAILS_TEST_NUMBER']}/. The directory where you save your Paperclip attachments should not look like this: storage/photos/1...

...storage/photos/2/... storage/photos/3/... storage/attachments/1/... storage/attachments/2/... The problem with this is that multiple environments (at least development and test) will share the same directory structure. This will cause you pain eventually. Files...

...problems installing a gem and get a error collect2: error: ld returned 1 exit status it's due to missing development headers of a library (ld is the linker).

/home/foobar/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20150915-3539-1i9layj.rb extconf.rb creating Makefile make "DESTDIR=" clean make "DESTDIR=" compiling generator.c linking shared-object json/ext/generator.so /usr/bin/ld: cannot find -lgmp collect2: error: ld returned 1 exit status

If you want a widget for awesome that runs a command regularly (every X seconds) and puts the output into your awesome panel, this is for you.

...below into your ~/.config/awesome/rc.lua. It supplies two methods: execute_command will run a command and return its output. Multiple lines will be joined into one line. The code is from...

Sometimes you can make your life easier by not allowing a record attribute to be changed after the record was created. An example for this is when your model represents...

...a child node in a composition and has logic that is hard to support for cases when the container changes. Here is an example for a container Region composed of...

.../.bashrc to have it always available. Adjust to your needs. Usage $> tab_title # title set to the current directory's name $> tab_title new_title # title set to "new_title...

...Auto-setting the title If you want your title to update each time you change the working directory, put this code after the function definition. # auto-title cd() { builtin cd...

...doing a git blame, git will blame the person who added or removed white space in a line (e.g. by indenting), not the person who originally wrote the code.

...git blame -w to ignore such white-space changes. You want this. \ Note that you can also use it when diffing: git diff -w. Example Consider this method, created by...

You want Spring for super-fast binstubs like bin/rails or bin/rspec which avoid Rails boot time. You want parallel_tests to speed up full test runs of large test suites...

...Unfortunately, you do not want parallel_tests to use your Spring binstubs as those parallelized tests will share data and/or loose some information. There are some issues about this on...

...default distribution from Ubuntu 14.04 (trusty) to 16.04 (precise). This might break your test setup for new builds. You can solve this issue by freezing your test distribution in the...

...travis.yml to Ubuntu 14.04 until you have the time to solve all the issues you will have in 16.04: dist: trusty Error details Here are few indicators that you ran...

makandra dev

...click', cssSelector, handler) Comparison Action jQuery DOM API equivalent Find descendant(s) by CSS selector .find(selector) one: .querySelector(selector), many: .querySelectorAll(selector) Test an element (returns boolean)

...matches(selector) Test for class presence (boolean) .hasClass(class) .classList.contains(class) Add class .addClass(class) .classList.add(class) Remove class .removeClass(class) .classList.remove(class) Toggle class .toggleClass(class) .classList.toggle(class)

...you can force absolute URLs throughout a response. Now you want to modify URLs similarly, but only in parts of a view (or controller) logic. Here is how.

...has only been tested on a Rails 2 application. It should work similarly for Rails 3. Put this into your ApplicationController: def rewrite_options(*args) options = super options.merge!(:only_path...

Active Record's select method allows you to make use of the power of MySQL select statements. On the one hand it allows you to select specific fields. Post.select("content...

...results in the following query: "SELECT content FROM `posts`" This means that your models will be initialized with only the content attribute and you will not be able to access...