Skip to content

Instantly share code, notes, and snippets.

View diegodurs's full-sized avatar
💭
Developing the best connected urban e-bike

Diego d'Ursel diegodurs

💭
Developing the best connected urban e-bike
View GitHub Profile
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@diegodurs
diegodurs / console.js
Created November 28, 2013 13:15
Angular
/* get service from the console */
var service = angular.element('[ng-app]').injector().get('MyService');
@diegodurs
diegodurs / exceptions.rb
Created November 22, 2013 10:42
Exceptions
# credits goes to SKORKS
# http://www.skorks.com/2009/09/ruby-exceptions-and-exception-handling/
# raise an exception
raise TypeError, 'You must give me truth' if value == false
# raise RuntimeError
raise "Hello"
# basic block
@diegodurs
diegodurs / strings_sugar.rb
Created November 21, 2013 17:01
Ruby string sugar
%w(1 2 3) => [1,2,3]
%Q{ my super long
string on several lines
}
<<-SQL
/* lets write some SQL */
select users.* from users;
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'dj.log'))
Delayed::Worker.logger.info "Debugging job"
@diegodurs
diegodurs / javascript_resources.md
Created October 31, 2013 13:19 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@diegodurs
diegodurs / rails_resources.md
Created October 31, 2013 13:19 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@diegodurs
diegodurs / array_logger.rb
Last active December 27, 2015 01:59
Easy way to keep your debugging logs in a array + outputing to Rails.logger, useful when executing from the console
module ScriptUtils
class ArrayLogger < Array
def initialize(&blk)
@block = if block_given?
blk
else
->(msg){ Rails.logger.info(msg) }
end
end

Recruiting Web Ninja

require "developer"

People.search_for_role(WebDeveloper).limit(1).who do 
  have(:talent)
  know(:SQL) 
  know(:ruby_on_rails)
 expect { salary }.to be_good
@diegodurs
diegodurs / gist:5425232
Last active December 16, 2015 11:09
Fresh install for new computer
- XCode command line tools
- brew # to install the following tools
- rbenv # for ruby versions
- gem, rails # ruby gem, and install rails gem
- postgress # check Postgress.app
- rails/spring preloader / or zeus # preload Rails env
- Better Errors & RailsPanel
- sublime text + sublime-text-2-ruby-tests
- something to use subdomain for development # .pow or something else
- add git origin