This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var max_height = 0; | |
$("div.col").each(function(){ | |
if ($(this).height() > max_height) { max_height = $(this).height(); } | |
}); | |
$("div.col").height(max_height); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="field"> | |
<%= form.label :topmenuitem_id %> | |
<%= form.collection_select(:topmenuitem_id, @menuitems.all, :id, :title) %> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const returnPromiseFromPromise = async (decree) => { | |
return new Promise((resolve, reject) => { | |
getPromise() | |
.then(result => resolve(result)) | |
.catch(Error => reject(Error)) | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const returnPromeseAll = async () => { | |
try{ | |
const a = getPromise1() | |
const b = getPromise2() | |
const concurrentResult = await Promise.all([a, b]) | |
} | |
catch(err) { | |
throw err | |
} | |
return concurrentResult |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
callApi = [url1, url2, url3] | |
const pormiseArr = callApi.map(v => getFromApi(v)) | |
const ConcurrentLoop = async() => { | |
for await (const resolvedPromise in pormiseArr) { | |
console.log(resolvedPromise) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function start() { | |
for await (let asyncFunction of asyncFunctions ) { | |
console.log(await asyncFunction()) | |
} | |
} | |
start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* batchGenerator(array, batchSize) { | |
const arrCopy = [...array]; | |
while(arrCopy.length>0){ | |
yield arrCopy.splice(0, batchSize); | |
} | |
} |
OlderNewer