Skip to content

Instantly share code, notes, and snippets.

View arieliten's full-sized avatar

Ariel Diaz Bermejo arieliten

  • Rio Cuarto - Argentina
View GitHub Profile
@arieliten
arieliten / json_parsers_benchmark.rb
Created November 26, 2019 20:25
Ruby (Rails) Json parsers comparisson
require 'bundler'
require 'active_support/core_ext/object/deep_dup'
require 'active_model_serializers'
require 'roar/decorator'
require 'roar/json'
require 'rabl'
require 'jbuilder'
require 'fast_jsonapi'
require 'benchmark'
require 'ffaker'
@arieliten
arieliten / gist:deff2e5bd3f458868cca
Created November 5, 2015 15:55 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@arieliten
arieliten / winning_away_teams.txt
Created May 6, 2015 21:10
¿Qué es mejor en una instancia de eliminación directa local-visitante? ¿Definir de local o definir de visitante? Aquí una breve estadística de las fases finales de las competencias más importantes a nivel de clubes en américa y europa
***************************************************************
****** Equipos que PASAN de fase definiendo de VISITANTE ******
***************************************************************
=== Libertadores 2014 (66%)
(8) Octavos de final => 6
(4) Cuartos de final => 2
(2) Semifinales => 2
(1) Final => 0
@arieliten
arieliten / 1_api_base_controller.rb
Last active August 29, 2015 14:16
Custom authenticate
class Api::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_action :myTS_authenticate!
private
def myTS_authenticate!
if request.env['PATH_INFO'] =~ /api_data_sync/
data_sync_api_authentication
else
@arieliten
arieliten / 1_pd_resource.rb
Created December 19, 2014 20:34
Basic structure to build API endpoint for pd_resources (search)
# app/models/pd_resource.rb
class PdResource < ActiveRecord::Base
# ...
SORT_OPTIONS = [:alpha, :popular]
SORT_CLAUSES = {
alpha: "pd_resources.title ASC",
popular: "pd_resources.views DESC",
}
#...
end
@arieliten
arieliten / api_test.rb
Created April 10, 2013 21:05
Script to test Cutopia's API
require 'rubygems'
gem 'savon', '=1.1.0'
require 'savon'
WSDL_URL = "https://testenv.w-w-i-s.com/hb/51/api.asmx?wsdl"
HMAC = 'string'
CLIENT_ID = 'AHHRV'
MAIN_HEADER = {
'Credentials' => {
'HMac' => HMAC,
@arieliten
arieliten / cart.rb
Created March 19, 2013 14:22
Basic Shopping Cart implementation, using ActiveRecord for persistence of Order/Item and a module to encapsulate the logic of a Cart
module MyApp
class Cart
attr_accessor :order, :items # <== ActiveRecord Instance of Order & Item
def initialize(user, token)
@order ||= user.blank? ? Order.load_for_guest(token) : Order.load_for_customer(user)
@items = @order.items
end
def add(product_id, quantity=1)
@arieliten
arieliten / GetAccounts.request.xml
Last active December 10, 2015 18:59
Detailed list of requests and responses interchanged through the SOAP API of Cutopia.
<soap:Envelope xmlns="http://www.w-w-i-s.com/hb/51" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Header>
<Credentials>
<HMac>string</HMac>
<ClientID>AHHRV</ClientID>
<UserName>ariel1234</UserName>
<Password>worldwide1</Password>
</Credentials>
</soap:Header>
<soap:Body>
@arieliten
arieliten / label_generator.rb
Created May 11, 2012 17:09
Creating LTL labels
s = Store.last
s_name = s.name.upcase
s_address = s.address.address_1 + s.address.address_2
s_city = s.address.city
s_zip = 'Zip: ' + s.address.zipcode
label_path = Rails.root.join('public', 'images', 'ltl_label.png').to_s
barcode_file= "1318364275.png" ### <--- Aca ponete el string de un barcode que tengas en tu disco, en "public/images/barcodes/"
output_path = "#{Rails.root}/tmp/ltl_label_#{barcode_file}"
label = Magick::Image.read(label_path).first
@arieliten
arieliten / person.rb
Created December 19, 2011 19:37
Para Mauricio: como obtener los numeros de telefonos asociados a una persona
class Person
has_many :person_telephones
...
def mobile_numer
phone = self.person_telephones.first(:conditions => ["`person_telephones`.kind = ?", 'KIND_MOBILE'])
phone.number if phone
end