Skip to content

Instantly share code, notes, and snippets.

View theendcomplete's full-sized avatar
🎯
Focusing

Nikkie Grom theendcomplete

🎯
Focusing
View GitHub Profile
@crundberg
crundberg / gist:a77b22de856e92a7e14c81f40e7a74bd
Last active April 27, 2024 16:51
Setup deCONZ on unprivileged Proxmox container

Setup deCONZ on unprivileged Proxmox container

Preparation on host

First find your Conbee with lsusb and note the ID. The vendor is 1cf1 and the product is 0030.

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 1cf1:0030 Dresden Elektronik ZigBee gateway [ConBee II]
Bus 001 Device 003: ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
@gryan11
gryan11 / gs65stealth_linux_setup.md
Last active March 1, 2024 18:36
Notes on setting up MSI GS65 Stealth as dual boot Linux Laptop

Linux Setup on MSI GS65 Laptop

Preliminary Setup

Make the following usb sticks and drives on windows:

  1. Ubuntu install usb stick
  2. System recovery usb stick
  3. System backup image on usb hard drive

windows setup

@bazzel
bazzel / README.md
Last active May 26, 2021 04:20
Rails 6 and Bootstrap 4

This blogpost shows how to setup Rails 6 with Bootstrap 4.

This snippet shows a somehow different and less customized approach.

$ rails new rails6-bootstrap4
$ bundle --binstubs
$ yarn add bootstrap jquery popper.js expose-loader
$ sudo apt-get update
$ sudo apt-get install unzip wget
$ wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
$ unzip ngrok-stable-linux-amd64.zip
$ sudo mv ./ngrok /usr/bin/ngrok
$ ngrok

Adding Google Sign In With Rails and React

For this blog post we will be using ruby version 2.4.0 and rails version 5.1.4 as backend and React/Redux as frontend. Adding Google Sign in functionality in your application can be done in two popular ways.

  • Adding google sign in functionality in the frontend with google api client gapi.

  • Adding google sign in functionality logic in the backend server.

If your application has separate backendend with APIs feeding data to the frontend React application, I suggest you to follow the step 2. If you want yo enhance your application security, then you implement both.

@ryanermita
ryanermita / rails_locking.md
Last active February 17, 2024 02:19
Optimistic and Pessimistic Locking in Rails

Optimistic Locking assumes that a database transaction conflict is very rare to happen. It uses a version number of the record to track the changes. It raise an error when other user tries to update the record while it is lock.

usage

Just add a lock_version column to the table you want to place the lock and Rails will automatically check this column before updating the record.

Pessimistic locking assumes that database transaction conflict is very likely to happen. It locks the record until the transaction is done. If the record is currently lock and the other user make a transaction, that second transaction will wait until the lock in first transaction is release.

usage

@MarkMurphy
MarkMurphy / README.md
Last active February 5, 2024 19:59
Cursor based pagination for Rails models.

Example Usage

Users

id name
1 Jane
2 Max
3 John
4 Scott
@zulhfreelancer
zulhfreelancer / heroku_pg_db_reset.md
Last active June 17, 2024 11:44
How to reset PG Database on Heroku (for Rails app)?

It's important to note that running this reset will drop any existing data you have in the application

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

@mozamimy
mozamimy / gist:52c0004c8370f78df2c2
Created May 4, 2015 07:43
Validations for IP address and MAC address on Ruby on Rails
require "resolv"
class Model < ActiveRecord::Base
validates :ip_address, format: { with: Resolv::IPv4::Regex }
validates :mac_address, format: { with: /\A([0-9A-F]{2}[-:]){5}([0-9A-F]{2})\z/ }
end