Skip to content

Instantly share code, notes, and snippets.

View inneroot's full-sized avatar

Gleb F inneroot

View GitHub Profile
require('dotenv/config')
const mongoose = require('mongoose')
const Mymodel = require('./models/Mymodel')
mongoose.connect(
process.env.MONGOCONNECT,
{useNewUrlParser: true,
useUnifiedTopology: true},
() => console.log('connected to mongo')
)
@inneroot
inneroot / registrations_controller.rb
Created December 4, 2018 13:42
Device gem with one user allowed
# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
before_action :one_user_registered?, only: [:new, :create]
protected
def one_user_registered?
if User.count == 1
if user_signed_in?
@inneroot
inneroot / uploadname.js
Last active November 18, 2018 21:20
changing label on bootstrap custom upload file input field
//bootstrap 4 custom upload
//<input type="file" name="fileToUpload" id="fileToUpload" accept=".pdf" class="custom-file-input" onchange="getname(event)">
//<label class="custom-file-label file-upload-info" for="fileToUpload" id="upload_label">Upload PDF</label>
//uploaded filename > label, default label is back on clear;
let deflabel = "Upload File";
if (document.getElementById("upload_label")) deflabel = document.getElementById("upload_label").innerHTML;
function getname(evt){
//console.log(evt);
@inneroot
inneroot / select_topitem_id.erb
Last active May 19, 2018 15:38
Select form for collection of objects with _form Action View Helper
<div class="field">
<%= form.label :topmenuitem_id %>
<%= form.collection_select(:topmenuitem_id, @menuitems.all, :id, :title) %>
</div>
@inneroot
inneroot / divcolheight.js
Created May 12, 2018 00:03
2 colons same height jQuery
var max_height = 0;
$("div.col").each(function(){
if ($(this).height() > max_height) { max_height = $(this).height(); }
});
$("div.col").height(max_height);