Skip to content

Instantly share code, notes, and snippets.

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

Mauro Locatelli crivotz

🏠
Working from home
View GitHub Profile
@tabishiqbal
tabishiqbal / _form.html.erb
Last active March 1, 2024 02:33
Ruby on Rails Tom-Select Example with Stimulus controller
<%= form_with(model: team) do |form| %>
<div>
<%= form.label :name %>
<%= form.text_field :name, class: "input" %>
</div>
<div>
<%= f.select :user_id, {}, {placeholder: "Select user"}, {class: "w-full", data: { controller: "select", select_url_value: users_path }} %>
</div>
require 'googleauth'
require 'google/apis'
require 'google/apis/calendar_v3'
module GoogleMeetService
def self.create_google_event(event)
authorize_client
google_event = create_calendar_event(event)
updated_google_event = update_calendar_event(event,google_event)
event.update_attribute(:conference_link,updated_google_event.hangout_link)
@x1wins
x1wins / application_controller.rb
Last active December 12, 2019 14:53
model user_id onwer check
class ApplicationController < ActionController::Base
def is_owner user_id
unless user_id == current_user.id
render json: nil, status: :forbidden
return
end
end
def is_owner_object data
if data.nil? or data.user_id.nil?
return render status: :not_found
@yalab
yalab / bootstrap-memo.md
Last active July 20, 2022 20:29
rails5 + webpacker + bootstrap
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add bootstrap@4.0.0-beta jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@tony-gutierrez
tony-gutierrez / AWS_Single_LetsEncrypt.yaml
Last active March 7, 2024 11:29
AWS Elastic Beanstalk .ebextensions config for single instance free SSL using letsencrypt certbot and nginx. http://bluefletch.com/blog/domain-agnostic-letsencrypt-ssl-config-for-elastic-beanstalk-single-instances/
# Dont forget to set the env variable "certdomain", and either fill in your email below or use an env variable for that too.
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
@VimleshS
VimleshS / jenkins-rails-ec2
Created April 11, 2016 07:27
Jenkins setup for Rails on EC2
Based on these:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
http://www.intridea.com/blog/2013/5/21/howto-install-setup-jenkins-ci-for-rails-projects
Setup an EC2 instance with Ubuntu (14.04)
Open port 8080
Install Jenkins
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
@mariozig
mariozig / migrate_repo.sh
Last active December 22, 2022 08:32
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror git@your-gitlab-site.com:mario/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
@jhass
jhass / .rubocop.yml
Last active December 15, 2023 22:23
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
@dideler
dideler / upgrade-postgres-9.3-to-9.4.md
Last active June 8, 2020 03:24
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10

TL;DR

Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop