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
@diegodurs
diegodurs / .bash_prompt
Created October 29, 2014 13:13
Bash Prompt
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
@diegodurs
diegodurs / build_new_rails_app.md
Created September 11, 2012 09:24
Build new Rails App

Generate new app

Don't forget -T -d postgresql. One day create a template and builder

  • rails new AppName -T -d postgresql

Use rspec, haml, coffee, scss

  • rails generate rspec:install In application.rb:
@diegodurs
diegodurs / google_key_val.rb
Created January 9, 2018 12:02
KeyVal on Google Datastore
require 'google/cloud/datastore'
module Ruba
# This use the Google Datastore as a key value storage.
# One could argue that Memcache would be more appropriate.
# usage:
#
## class DoSomething
## include GoogleKeyVal
##
@diegodurs
diegodurs / delayed_job_scopes.rb
Created November 27, 2014 10:56
Delayed::Job Scopes
module DelayedJobScopes
extend ActiveSupport::Concern
included do
scope :error, -> (error) { failed.where('last_error ILIKE (?)', "%#{error.strip}%") }
scope :failed, -> { where('last_error IS NOT NULL') }
scope :queues, -> (queues) { where(queue: queues) }
end
def id_in_args
@diegodurs
diegodurs / conventions.md
Last active June 21, 2016 06:25
Rights'Up little guidelines

RightsUp Code Guidelines

Github

use dashes (-) for branches, it's easier to write than underscore (_)

Pull Requests

  • pull latest changes in the master branch git checkout master git pull origin master
  • checkout on-your-feature
@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 / 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