Skip to content

Instantly share code, notes, and snippets.

View joelibaceta's full-sized avatar
🏠
Working from home

Joel Ibaceta joelibaceta

🏠
Working from home
View GitHub Profile
function ajax_delete_url(url, params, callback){
$.ajax({ url: url, type: 'DELETE', data: params, success: callback });
}
function ajax_get_url(url, params, callback){
$.ajax({ url: url, type: 'GET', data: params, success: callback });
}
function ajax_post_url(url, params, callback){
$.ajax({ url: url, type: 'POST', data: params, success: callback });
@joelibaceta
joelibaceta / get_triple.rb
Last active August 29, 2015 14:03
Escribir un método que al pasarle 2 números devuelva un array con el triple de cada numero
def get_triple(*args)
args.map{|i| i*3}
end
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
@joelibaceta
joelibaceta / designer.html
Last active August 29, 2015 14:26
designer
<link rel="import" href="../topeka-elements/theme.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-categories.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@joelibaceta
joelibaceta / active_admin.coffe
Last active August 29, 2015 14:27 — forked from EtienneDepaulis/active_admin.css.scss
jQuery Datatables + Active Admin
#= require active_admin/base
#= require chosen-jquery
#= require dataTables/jquery.dataTables
$.fn.dataTableExt.oApi.fnPagingInfo = (oSettings) ->
{
'iStart': oSettings._iDisplayStart
'iEnd': oSettings.fnDisplayEnd()
'iLength': oSettings._iDisplayLength
'iTotal': oSettings.fnRecordsTotal()
@joelibaceta
joelibaceta / paperclip.rb
Last active September 7, 2015 19:11
PaperClip + S3 with a custom path
#config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-west-2.amazonaws.com'
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename.#{Time.now.to_i}'
# Implement a Primes class with a class method first(n)
# that returns an array of the first n prime numbers.
class Primes
def self.first(total, primes=[2], n=2)
primes.count >= total ? primes : (eval ((2..n-1).map{|j| (n % j == 0) ? false : true}).join(" && ")) ? first(total, primes.push(n), n+1) : first(total, primes, n+1)
end
end
def list(names)
names.map{|i| i[:name]}.join(" ").gsub(/[ ]/, ', ').gsub(/(.*), /, '\1 & ')
end
def get_sum(n)
odd, even = 0, 0
(1..n).map{|i| i % 2 == 0 ? even += i : odd += i }
puts "Suma de Pares : #{even} \nSuma de Impares : #{odd}"
end
def square(n, ext_char, int_char)
(0..n).map{|i| p (0..n).map{|j| ([0, n].to_a & [i, j]).any? ? ext_char : int_char }.join}
end