Skip to content

Instantly share code, notes, and snippets.

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

William Wong Garay willywg

🏠
Working from home
View GitHub Profile
@willywg
willywg / form.html
Created July 1, 2019 17:33
Prevent multiple submits when clicked a submit button
<form action='/'>
<button class="prevent-multiple-submit" type="submit">Create</button>
</form>
@willywg
willywg / administrate_dashboard_to_moduled_model.md
Last active April 25, 2019 15:08
How create an admistrate dashboard with a moduled model
  1. If our model is Faq::UserType, then we generates the dashboard with:

rails generate administrate:dashboard faq/user_type

This generates:

Running via Spring preloader in process 21074
      create  app/dashboards/user_type_dashboard.rb
      create  app/controllers/admin/user_types_controller.rb
@willywg
willywg / rspec_model_testing_template.rb
Created September 4, 2018 15:53 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
1. Iniciar clover con opcion -s en el booteo (borrar cualquier otra opcion presente). Esto inciiará en Single-User mode
2. En terminal correr mount -uw /
3. Eliminar comprobador de cuenta nueva en Mac: rm /var/db/.AppleSetupDone
4. reboot
5. Crear un usuario nuevo (no usar el nombre del mismo usuario a recuperar)
6. Al inicar la cuenta nueva (nuevo admin) en prefeencias crear un usuario con el mismo nombre, elegir usar la carpeta existente
7. Cambiar a la cuenta del usuario recuperado dos veces. Pedira recuperar algunos accesos.
8. Resolver permisos: sudo chown -R willywg:admin /usr/local/var/
Fuente:
@willywg
willywg / _flash_messages.html.slim
Created May 10, 2018 21:06
Rails flash messages helper for bootstrap 4 with slim
- flash.each do |type, msg|
div class=("alert #{bootstrap_class_for_flash(type)} alert-dismissable fade show")
= msg
button.close data-dismiss="alert" &times;
@willywg
willywg / README.md
Last active July 13, 2017 22:40
Add Bulma Saas to Nuxt via npm

Add sass pre-procesor:

yarn add node-sass sass-loader -D

Add bulma

yarn add bulma
@willywg
willywg / devise_helper.rb
Last active November 5, 2016 15:46 — forked from seyhunak/devise_helper.rb
Devise Error Messages with Bootstrap 3 style
# /app/helpers/devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
@willywg
willywg / gist:31f38a24afed0199eaf6
Created February 5, 2016 14:34 — forked from tamoyal/gist:10441108
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@willywg
willywg / en.js
Created May 17, 2015 02:55
BC Leveling Calculato English Lang
{
'LEVELING_TITLE': 'BC Leveling Calculator',
'MONSTER_FOR_LEVELING': 'Monster for leveling',
'SPECIAL': 'Special',
'CANDY': 'Candy',
'CRYSTAL': 'Crystal',
'RARE': 'Rare',
'SUPER': 'Super',
'ULTRA': 'Ultra',
'EPIC': 'Epic',
@willywg
willywg / ping.rb
Created November 24, 2013 06:00
Ping Web. Connect Ruby with Arduino by Serial Port
require 'serialport'
require 'net/ping'
website = 'http://turismoi.pek'
#this *will* be different for you
#You need to find out what port your arduino is on
#and also what the corresponding file is on /dev
#You can do this by looking at the bottom right of the Arduino
#environment which tells you what the path.