Skip to content

Instantly share code, notes, and snippets.

@Arkham
Arkham / fun.rb
Last active September 20, 2023 20:40
Fun with Ruby and a Raspberry PI
require 'pi_piper'
require 'ostruct'
laser = PiPiper::Pin.new(pin: 17, direction: :out)
alarm = PiPiper::Pin.new(pin: 18, direction: :out)
vibration = PiPiper::Pin.new(pin: 27, direction: :in)
i2c = PiPiper::I2C.new
def turn_on(pin)
pin.off
@iwan
iwan / devise.it.yml
Last active March 20, 2018 20:30 — forked from epistrephein/devise.it.yml
Italian translation for Devise 3.5
# Italian translation for Devise 4.2
# Date: 2016-08-01
# Author: epistrephein, iwan
# Note: Thanks to xpepper (https://gist.github.com/xpepper/8052632)
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
it:
devise:
confirmations:
confirmed: "Il tuo account è stato correttamente confermato."
@iwan
iwan / devise_invitable.it.yml
Last active March 20, 2018 20:29
Italian translation for for DeviseInvitable
it:
devise:
failure:
invited: "Hai un invito in sospeso, accettalo per completare la creazione del tuo account."
invitations:
send_instructions: "Un'email di invito è stata inoltrata a %{email}."
invitation_token_invalid: "Il token di invito fornito non è valido!"
updated: "La tua password è stata impostata correttamente. Ora sei connesso."
updated_not_active: "La tua password è stata impostata correttamente."
no_invitations_remaining: "Non sono più disponibili inviti."
@ryannealmes
ryannealmes / gist:9c148a6c4b35aefaf505
Last active July 5, 2017 23:08
How to managed services and dependencies ...
# adapted from
# http://adamniedzielski.github.io/blog/2014/11/25/my-take-on-services-in-rails/
class CreateUserAccount
attr_reader :user
def initialize(send_email_service: SendEmail.new, generate_token_service: GenerateToken.new)
@send_email_service = send_email_service
@generate_token_service = generate_token_service
end
@maxim
maxim / rails_load_path_tips.md
Last active April 13, 2023 13:28
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@JoshCheek
JoshCheek / private_attr_writer.rb
Created April 13, 2012 04:50
private attr_writer
class Klass
def initialize(number)
self.number = number
end
attr_reader :number
private
attr_writer :number
@ariera
ariera / README.markdown
Created August 7, 2011 16:23
Nestable, sortable and dragable categories

Nestable, sortable and dragable categories:

In the project I'm working on we wanted to have a Category model which we wanted to be nestable. But we also liked the user to have a draggable interface to manage and rearrange the order of his categories. So we chose awesome_nested_set for the model and jQuery.nestedSortable for the UI.

It took me some time to arrange things to work properly so I wanted to share my work in case it helps anybody.

Before beginning

you might want to take a look at a demo app

  1. go to: http://awesomenestedsortable.heroku.com/groups/
  2. click in show of any group
@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

# LDAP Configuration
development:
host: localhost
port: 636
base: ou=bar,dc=foo,dc=com
admin_user: cn=admin,dc=foo,dc=com
admin_password: password
ssl: false
production: