Skip to content

Instantly share code, notes, and snippets.

View ckozus's full-sized avatar

Carlos Kozuszko ckozus

  • Insignia
  • Tucumán, Argentina
View GitHub Profile
@ckozus
ckozus / 000-intro.rb
Last active March 25, 2020 22:48
Ejemplos en Ruby.
puts "hola mundo".class
puts "hola mundo".upcase
puts "curso: ruby on rails. nivel básico".size
puts 2 + 3
puts 2.+(3)
def self.get_superiors_of(user)
superiors = Array.new
return superiors if user.departament.nil?
case user.is_chief
when true
unless user.departament.parent.nil?
superiors = user.departament.parent.users.chiefs.to_a
end
when false
if user.departament.users.chiefs.to_a.count > 0
namespace :maintenance do
namespace :questions do
task :clean_up => :environment do
Question.find_each do |question|
if question.authors.size == 0
question.picks.destroy_all
question.destroy
end
end
end
def full_name
if self.first_name.nil? || self.last_name.nil?
self.username
else
self.first_name+" "+self.last_name
end
end
def full_name
if first_name && last_name
x = objeto
metodo_raro(x)
print x.nombre #muestra el nombre del objeto original y no el del nuevo
def metodo_raro(x)
x = nuevo_objeto()
return
end
window.pricingFunction = ->
max = Math.max solo.height(), basic.height(), business.height()
$('.solo, .basic, .business').height(max)
class RequestsController < ApplicationController
def create
if access_allowed?
set_access_control_headers
head :created
else
head :forbidden
end
end
@ckozus
ckozus / migration.rb
Created December 7, 2012 18:32
migracion con modificacion de datos en el medio
add_column :users, :title, :string
User.reset_column_information
User.all.each do |user|
user.title = Title.find_by_id(user.title_id).name
user.save!
end
@ckozus
ckozus / crear.pseudo.js.coffee
Created November 29, 2012 19:12
Creacion de registros recursiva
datos = []
for i = 1 to n
datos << {nombre: objeto.nombre, apellido: objeto.apellido}
crear = (datos) ->
dato = datos.pop
if dato
@ckozus
ckozus / Gemfile
Created November 1, 2012 18:27
heroku middleman buildpack
source "http://rubygems.org"
gem "middleman", "~>3.0.0.beta.2", :github => "middleman/middleman"