Skip to content

Instantly share code, notes, and snippets.

Avatar

Kermin Zahirovic kerminz

View GitHub Profile
@kerminz
kerminz / abr-modal.css
Last active Feb 3, 2020
AB Rocket Onboarding Modal Style
View abr-modal.css
.banner-bottom {
position: fixed;
left: 0px;
top: 0px;
height: 55px;
width: 100%;
color: #fff;
background: #001429;
z-index: 1333333337!important;
}
@kerminz
kerminz / abr-modal.js
Last active Feb 3, 2020
AB Rocket Onboarding Example Experiment
View abr-modal.js
var banner_bottom = '<div class="banner-bottom">'+
' <div class="banner-bottom-content">'+
' <span>Lorem Ipsum Dolor!</span>'+
' <a class="c-btn" target="_blank" href="https://www.google.com" title="Click me">CLICK ME!</a>'+
' </div>'+
' <div class="banner-close">'+
' x'+
' </div>'+
'</div>';
View urlParameterTrim.js
window.location.href.split(/[?#]/)[0] + '/'
@kerminz
kerminz / crud-mongodb-nodejs.js
Created May 19, 2019
CRUD – MongoDB + NodeJS
View crud-mongodb-nodejs.js
// CRUD create read update delete
const { MongoClient, ObjectID } = require('mongodb')
const connectionURL = 'mongodb://127.0.0.1:27017'
const databaseName = 'databaseName'
MongoClient.connect(connectionURL, { useNewUrlParser: true }, (error, client) => {
if (error) {
@kerminz
kerminz / basic-mongoDB-nodejs-connection.js
Last active May 19, 2019
Basic MongoDB Connection with NodeJS
View basic-mongoDB-nodejs-connection.js
const mongodb = require('mongodb')
const MongoClient = mongodb.MongoClient
const connectionURL = 'mongodb://127.0.0.1:27017'
const databaseName = 'customDatabaseName'
MongoClient.connect(connectionURL, { useNewUrlParser: true }, (error, client) => {
if (error) {
return console.log('Unable to connect to database!')
}
@kerminz
kerminz / fetch-data-clientside-promise.js
Created May 13, 2019
Fetch data clientside with promises
View fetch-data-clientside-promise.js
const url = 'http://api.fetchurl.com'
fetch(url).then((response) => {
response.json().then((data) => {
console.log(data)
})
})
// expected output: JSON Object
@kerminz
kerminz / rest-api-nodejs-express.js
Created May 13, 2019
Basic REST API with NodeJS and Express
View rest-api-nodejs-express.js
const request = require('request')
const express = require('express')
const app = express()
app.get('/', (req, res) => {
if (!req.query.search) {
return res.send('Please provide a search string...')
@kerminz
kerminz / nodejs-helloWorld-webServer.js
Created May 12, 2019
Simple Web-Server with NodeJS & Express
View nodejs-helloWorld-webServer.js
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('Hello World')
})
app.listen(3000, (err) => {
if (err) {
console.log("Error: ", err)
@kerminz
kerminz / swapElements.js
Created Apr 28, 2019
Swaping two elements in plain JS
View swapElements.js
// Swaping two elements in plain JS
function swapElements(obj1, obj2) {
// create marker element and insert it where obj1 is
var temp = document.createElement("div");
obj1.parentNode.insertBefore(temp, obj1);
// move obj1 to right before obj2
obj2.parentNode.insertBefore(obj1, obj2);
@kerminz
kerminz / restoreConsoleLog.js
Created Apr 28, 2019
Restore console.log()
View restoreConsoleLog.js
// Restore console.log()
javascript: (function() {
var i = document.createElement('iframe');
i.style.display='none';
document.body.appendChild(i);
window.console=i.contentWindow.console;
}());
You can’t perform that action at this time.