Example with translations:
{
"response": [
{
"type":"text",
"message":{
"translation": {
"en":"do you need and hotel?",| def specific_enqueued_jobs(job) | |
| enqueued_jobs.select{ |j| j if j[:job] == job } | |
| end | |
| require 'active_support/core_ext/class/subclasses' | |
| require 'active_support/core_ext/hash/keys' | |
| module ActiveJob | |
| # Provides helper methods for testing Active Job | |
| module RSpecHelper | |
| extend ActiveSupport::Concern |
| if("hello") "hello"; | |
| "hello" | |
| if(0) "hello"; | |
| undefined | |
| if('') "hello"; | |
| undefined | |
| if(1) "hello"; | |
| "hello" |
Example with translations:
{
"response": [
{
"type":"text",
"message":{
"translation": {
"en":"do you need and hotel?",| class Hash | |
| # merge_present | |
| # examples: | |
| # {hello: ''}.merge_present(hello: 'sd') #=> {hello: 'sd'} | |
| # | |
| # {hello: nil}.merge_present(hello: '') #=> {} | |
| # | |
| def merge_present(other_hash) | |
| mapped = self.map do |k, v| | |
| if v.blank? |
| # && | |
| 'hello' unless true && false | |
| #=> "hello" | |
| 'hello' unless false && true | |
| #=> "hello" | |
| 'hello' unless false && false | |
| #=> "hello" | |
| 'hello' unless true && true | |
| #=> nil |
| class Array | |
| # find_map | |
| # example: | |
| # [nil, 'hello '].find_map |n| | |
| # n.try(:strip) | |
| # end => 'hello' | |
| def find_map(&block) | |
| result = nil | |
| self.each do |q| | |
| result = yield(q) |
| # In not working!! | |
| # Validations are added, but errors are not in the errors list after valid | |
| module AddChildValidations | |
| extend ActiveSupport::Concern | |
| class_methods do | |
| # Example: | |
| # class User < ActiveRecord::Base | |
| # has_one :address | |
| # add_child_validations_for :address do |
| #!/bin/sh | |
| # Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
| # CREATE block and create them in separate commands _after_ all the INSERTs. | |
| # Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
| # The mysqldump file is traversed only once. | |
| # Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
| # Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
| ############################################# | |
| # Push de la rama actual | |
| git push origin $rama_actual | |
| ############################################# | |
| # Volver a un commit anterior, descartando los cambios | |
| git reset --HARD $SHA1 | |
| ############################################# | |
| # Ver y descargar Ramas remotas |
| module SkippableCallbacks | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| def _skippable_callbacks | |
| [ | |
| :after_initialize, | |
| :after_build, | |
| :before_validation, | |
| :after_validation, | |
| :before_create, |