Skip to content

Instantly share code, notes, and snippets.

View nicolasblanco's full-sized avatar
🎯
Focusing

Nicolas Blanco nicolasblanco

🎯
Focusing
View GitHub Profile
"Checkout" challenge (Object Oriented Programming design patterns, Test Driven Development):
https://gist.github.com/aldodelgado/1b3a80de8c34122a3537
https://github.com/nicolasblanco/textmaster_checkout
"Rovers on Mars" challenge (Object Oriented Programming design patterns, Test Driven Development):
https://gist.github.com/nicolasblanco/3e8c181c8b8dbecbfbe51ca976fc18ee
https://bitbucket.org/nicolasblanco/xing-coding-challenge/overview

#Problem Statement (Parking Lot)

I own a multi­storey parking lot that can hold up to 'n' cars at any given point in time. Each slot is given a number starting at 1 increasing with increasing distance from the entry point in steps of one. I want to create an automated ticketing system that allows my customers to use my parking lot without human intervention.

When a car enters my parking lot, I want to have a ticket issued to the driver. The ticket issuing process includes us documenting the registration number (number plate) and the colour of the car and allocating an available parking slot to the car before actually handing over a ticket to the driver (we assume that our customers are nice enough to always park in the slots allocated to them). The customer should be allocated a parking slot which is nearest to the entry. At the exit the customer returns the ticket which then marks the slot they were using as being available.

Due to government regulation, the system should provide me with the ability to f

@nicolasblanco
nicolasblanco / 20160929132327_localize_species.rb
Last active September 29, 2016 13:37
Mongoid : migrate an existing String field to a localized field
# db/migrate/20160929132327_localize_species.rb
class LocalizeSpecies < Mongoid::Migration
def self.up
migrate_field_to_localized(Species, :name)
end
def self.down
end
end
# Rails 5 default app (gem 'mongoid', '~> 6.0.0.rc0', require: false)
irb(main):002:0> Object.methods.count
=> 180
irb(main):003:0> Object.instance_methods.count
=> 92
# Rails 5 default app (gem 'mongoid', '~> 6.0.0.rc0', require: true)
irb(main):003:0> Object.methods.count

Ce que j'appreciais avec AngularJS 1, c'est la possibilite tres simple d'injecter le framework a la volee dans n'importe quelle page.

Genial pour juste injecter des composants de vues dans des parties d'une application existante sans tout remettre en question et continuer d'utiliser l'asset pipeline de Rails.

On a par exemple utilisé AngularJS 1 juste dans des parties d'un back office d'administration.

Aujourd'hui AngularJS 2 est un framework a part entiere qui s'installe avec npm, qui est tres dur a utiliser sans son propre outil de bootstraping, le code TypeScript comprend de la resolution de modules, etc. C'est peut etre plus professionel, mais actuellement impossible de faire autrement qu'avec leur outil de bootstraping.

Pour l'instant j'ai reussi a bootstraper AngularJS 2 dans une appli Rails classique existante mais en mode EcmaScript 5. Le Hello world marche mais la doc en ES5 est totalement inexistante et on sent que la petite communauté existante fait tout pour qu'on utilise le framework avec TS.

class DatePickerInput < SimpleForm::Inputs::Base
def input
res = "<div class='col-sm-6'>"
res << @builder.text_field(attribute_name, input_html_options.merge(name: nil, class: "form-control datepicker"))
res << @builder.hidden_field(attribute_name, id: "#{attribute_name}_hidden")
res << "</div>"
res.html_safe
end
end
#!/bin/sh
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake mongodb-org
➜ reader-on-rails git:(master) heroku run console --remote production
Running `console` attached to terminal... up, run.7547
!
! Timeout awaiting process
➜ projects rm -rf AnotherTest
➜ projects motion create --template=android AnotherTest
Create AnotherTest
Create AnotherTest/.gitignore
Create AnotherTest/app/main_activity.rb
Create AnotherTest/Rakefile
➜ projects cd AnotherTest
➜ AnotherTest vim Rakefile
➜ AnotherTest cat Rakefile
# -*- coding: utf-8 -*-
➜ projects rm -rf Hello
➜ projects motion create --template=android Hello
Create Hello
Create Hello/.gitignore
Create Hello/app/main_activity.rb
Create Hello/Rakefile
➜ projects cd Hello
➜ Hello vim Rakefile
➜ Hello cat Rakefile
# -*- coding: utf-8 -*-