Skip to content

Instantly share code, notes, and snippets.

View CristianRP's full-sized avatar
🎯
Focusing

Cristian Ramírez CristianRP

🎯
Focusing
  • Guatemala
View GitHub Profile
# frozen_string_literal: true
class Transaction::Create
def self.call(params, transaction)
new(params, transaction).call
end
def call
perform
end
@CristianRP
CristianRP / dml.sql
Last active May 9, 2019 16:05
Script base de datos del segundo parcial, se agregó tabla de Asignaciones
INSERT INTO CURSOS(DESCRIPCION) VALUES('MATEMATICA');
INSERT INTO CURSOS(DESCRIPCION) VALUES('COMPILADORES');
INSERT INTO CURSOS(DESCRIPCION) VALUES('ARQUITECTURA');
INSERT INTO CURSOS(DESCRIPCION) VALUES('ELECTRONICA');
INSERT INTO CURSOS(DESCRIPCION) VALUES('CONTABILIDAD');
INSERT INTO CLIENTES(NOMBRE) VALUES('Cristian');
INSERT INTO CLIENTES(NOMBRE) VALUES('Rodrigo');
INSERT INTO CLIENTES(NOMBRE) VALUES('Saul');
$(function() {
var dataTable = null;
document.addEventListener("turbolinks:before-cache", function() {
if (dataTable !== null) {
dataTable.destroy();
dataTable = null;
}
});
});
You want to use backtick not regular tick:
sudo kill `sudo lsof -t -i:9001`
If that doesn't work you could also use $() for command interpolation:
sudo kill $(sudo lsof -t -i:9001)
@CristianRP
CristianRP / secret_key_base
Created December 19, 2018 17:03 — forked from pablosalgadom/secret_key_base
app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)
So i was using Rails 4.1 with Unicorn v4.8.2 and when i tried to deploy my app it doesn't start properly and into the unicorn.log file i found this error message:
"app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)"
After a little research i found that Rails 4.1 change the way to manage the secret_key, so if we read the secrets.yml file located at exampleRailsProject/config/secrets.yml (you need to replace "exampleRailsProject" for your project name) you will find something like this:
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@CristianRP
CristianRP / BaseDao.kt
Created December 4, 2018 16:04 — forked from florina-muntenescu/BaseDao.kt
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@CristianRP
CristianRP / JBuilderPartials.json.jbuilder
Created May 16, 2018 21:29
How to use JBuilder partials in rails
# app/views/models/_model.json.jbuilder
json.(model, :id, :attr1, :attr2)
# app/views/models/show.json.jbuilder
json.partial! "model/model", model: @model
# app/views/models/index.json.jbuilder
json.array! @models, partial: 'model/model', as: :model
@CristianRP
CristianRP / Ignore.txt
Created April 12, 2018 15:30
Ignore tracked files in git
https://www.git-tower.com/learn/git/faq/ignore-tracked-files-in-git
@CristianRP
CristianRP / ValidateNumberTextBox.js
Created April 6, 2018 17:55
Allow only number in input tag
$(document).ready(function() {
$("#txtboxToFilter").keydown(function (e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl/cmd+A
(e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) ||
// Allow: Ctrl/cmd+C
(e.keyCode == 67 && (e.ctrlKey === true || e.metaKey === true)) ||
// Allow: Ctrl/cmd+X
(e.keyCode == 88 && (e.ctrlKey === true || e.metaKey === true)) ||
@CristianRP
CristianRP / CustomTitleizeRuby.rb
Created February 2, 2018 22:02
Custom titleize case for ruby
class String
def another_titlecase
self.split(" ").collect{|word| word[0] = word[0].upcase; word}.join(" ")
end
end
"john mark McMillan".another_titlecase
=> "John Mark McMillan"