Skip to content

Instantly share code, notes, and snippets.

Kermin Zahirovic kerminz

Block or report user

Report or block kerminz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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;
}());
@kerminz
kerminz / numToCurr.js
Last active Apr 27, 2019
Number To Local Currency Format
View numToCurr.js
// Convert any number to a local currency format with Intl Objects
function numToCurr(number) {
return new Intl.NumberFormat("de-DE", {style: "currency", currency: "EUR"}).format(number)
}
numToCurr(50.00)
// expected output: "50,00 €"
@kerminz
kerminz / single-page-application-flickering-2-yt.js
Last active Apr 27, 2019
Code aus Youtube Video SPA + Flickering
View single-page-application-flickering-2-yt.js
javascript: (function(e, s) {
e.src = s;
e.onload = function() {
jQuery.noConflict();
};
document.head.appendChild(e);
})(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js')
var event = new Event('abtest');
You can’t perform that action at this time.