Skip to content

Instantly share code, notes, and snippets.

View jesuslerma's full-sized avatar

jesuslerma

  • globalgig
  • Monterrey Mexico
View GitHub Profile
@jesuslerma
jesuslerma / query.sql
Last active September 23, 2015 15:10
SELECT conciliaciones.id AS id, st.id AS st_id, st.fecha, f.folio,
cuenta.numero_cuenta || '-' || cuenta.nombre AS nombre_cuenta,
(@ conciliaciones.dactual - conciliaciones.danterior) AS monto
FROM conciliaciones
INNER JOIN status_accounts st ON st.id = conciliaciones.status_account_id
LEFT JOIN facturas f ON f.id = conciliaciones.factura_id
LEFT JOIN (
SELECT concepto_contables.* FROM concepto_contables
LEFT JOIN concepto_contable_diots
ON concepto_contable_diots.concepto_contable_id = concepto_contables.id
@jesuslerma
jesuslerma / invoices_controller.rb
Created October 15, 2015 15:16
Como yo veo la solucion
def index
invoices_by_type
end
def sales
invoices_by_type
end
def expenses
invoices_by_type
end
def payroll
alphabet = ("a".."z").to_a << " "
key = 3
word = "hola mundo"
aux_arr = word.split("").map{|w| alphabet[(alphabet.index(w) + key) % alphabet.count] }
puts aux_arr.join("")
decrypt_arr = aux_arr.map{|w|alphabet[(alphabet.index(w) - key) % alphabet.count]}
conn = Faraday.new(:url => 'http://jsonplaceholder.typicode.com') do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
conn.get '/comments'
@jesuslerma
jesuslerma / iva_payment_entry.rb
Created December 30, 2015 23:28
Real testing
require 'rails_helper'
describe Contalink::Entries::IvaPaymentEntry do
@accounting_account = "IVA al Pago"
describe "#account_id" do
it "returns the accounting account id configured for #{@accounting_account}"
end
describe "#is_configured?" do
it "returns true when the accounting account is configured for #{@accounting_account}"
it "returns falsewhen when the accounting account is configured for #{@accounting_account}"
describe "class methods" do
describe ".calc_amount" do
it "returns 0 when the invoice amount is nil"
context "when the invoice status is 'Cancelado'" do
it "returns invoice total when the invoice has polizas for the company"
it "return 0.0 when the invoice doesnt has not polizas for the company"
end
end
end
int array[100];
for(int i = 0; i < array.length(); i ++) {
if (isFizz(array[i]) && isBuzz(array[i])) cout << "FizzBuzz" << endl;
else if ( isFizz(array[i])) cout << "Fizz" << endl;
else if (isBuzz(array[i])) cout << "Buzz" << endl;
}
bool isFizz(int elem) {
return ( elem % 3 == 0);
}
def attr_redeable(attribute)
hash = {
:naturaleza => {
'1' => "Deudora",
'2' => 'Acreedora'
},
:nivel_cuenta => {
'1' => 'Titulo',
'2' => 'Mayor',
'3' => 'Subcuenta',
@jesuslerma
jesuslerma / baby.rb
Created May 13, 2016 16:49
baby.rb
class Baby < RubyProgrammer
attr_accessor :age, :gender, :name
after_create :dad_will_be_happy
def dad_will_be_happy
puts 'Wohoo he\'s a boy'
end
end
import cherrypy
import boto
class Uploader(object):
@cherrypy.expose
@cherrypy.tools.json_out()
def index(self, myFile=None):
try:
FileValidator(myFile)
except ValueError as err: