Skip to content

Instantly share code, notes, and snippets.

View jesuslerma's full-sized avatar

jesuslerma

  • globalgig
  • Monterrey Mexico
View GitHub Profile
@jesuslerma
jesuslerma / docker_ruby.sh
Created July 17, 2020 13:18
Simple notes on how to run ruby in containers
# This is for running an irb
docker run --it --rm ruby:2.5
# This is for running an script
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp ruby:2.5 ruby hello_world.rb
# this is the content we should put in hello_world.rb Make sure to add the first line
# #!/usr/bin/env Ruby
# puts Hello World from Dockerfile
# we also need to make the script executable
chmod u+x hello_world.rb
@jesuslerma
jesuslerma / templateList.html
Last active July 31, 2017 05:22
Sample Vue.s
<template id='productsTemplate'>
<ul>
<li v-for="product in products">
{{product.name}} {{product.color}} cuesta ${{product.price}}
</li>
</ul>
</template>
ropa = Category.create name: 'Ropa'
electro = Category.create name: 'Electronicos'
disco = Category.create name: 'Discos'
Product.create name: 'Playera Locochona', photo: 'https://pbs.twimg.com/profile_images/561116211258220544/FlICmGnj.jpeg', stock: 12, category_id: ropa.id
Product.create name: 'Playera Locochona', photo: 'https://pbs.twimg.com/profile_images/561116211258220544/FlICmGnj.jpeg', stock: 12, category_id: ropa.id
document.getElementById("btnAgrupar").onclick = enviar;
function enviar()
{
var token = '';
var arrayOfIds = [];
var allInputs = document.getElementsByTagName("input");
for (var i = 0, max = allInputs.length; i < max; i++)
// aqui defino las variables que me pasaste
function calcData () {
poblationInit = 122823652 // 122´823, 652
newHabitantMx = 25.6
newBirthMx = 14.5
deathMexican = 44.15
dayInit = '01/01/2017'
today = new Date()
todayMom = moment(today) // aqui uso la variable today para traer la hora/fecha actual
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:
@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
def attr_redeable(attribute)
hash = {
:naturaleza => {
'1' => "Deudora",
'2' => 'Acreedora'
},
:nivel_cuenta => {
'1' => 'Titulo',
'2' => 'Mayor',
'3' => 'Subcuenta',
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);
}
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