Skip to content

Instantly share code, notes, and snippets.

davorbadrov / extract_worklog.js
Last active Mar 11, 2019
Extracts working hours for JIRA
View extract_worklog.js
// The worklog has to be open in timesheets and
// Developer Console must be open with Right-click > Inspect so the source maps take effect.
// Paste and run the code inside the Console.
// Note: Tested only on Chrome.
_issueTitles = document.querySelectorAll('.tempo-issue-table-td-issue [title]')
_issueDescriptions = document.querySelectorAll('.tempo-issue-table-td-comment [title]')
_workedHours = document.querySelectorAll('.tempo-issue-table-td-worked [title]')
_log = ''
for (let i = 0; i < _issueTitles.length; i++) {
davorbadrov / .editorconfig
Created May 6, 2018
Editor config for Javascript projects
View .editorconfig
root = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
davorbadrov / getTimezone.js
Last active Oct 5, 2017
Google Timezone API
View getTimezone.js
* Gets timezone info from Google's Timezone API
* based on passed latitude and longitude.
const request = require('request');
const API_KEY = '...';
function getTimezone({latitude, longitude}) {
const timestamp = Math.floor(new Date().getTime() / 1000);
const url = `${latitude},${longitude}&timestamp=${timestamp}&key=${API_KEY}`;
davorbadrov / readJson.js
Created May 9, 2017
Read JSON file in frontend
View readJson.js
// jsonFile can be files[0] from the change event on the input
// it returns a Promise which resolves as JSON content
// or rejects and outputs why it failed
export function readJSON(jsonFile) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = event => {
try {
const jsonContent = JSON.parse(reader.result);
davorbadrov / form_examples.js
Created Dec 6, 2016
React (controlled) form elements
View form_examples.js
<select value={this.state.value} onChange={this.handleChange}>
<option value="grapefruit">Grapefruit</option>
<option value="lime">Lime</option>
<option value="coconut">Coconut</option>
<option value="mango">Mango</option>
<textarea value={this.state.value} onChange={this.handleChange} />
davorbadrov / index.js
Last active Oct 27, 2016
Tag and Autocomplete combined - Using Awesomeplete + Taggle libs together to create an autocompleting tag input
View index.js
// Suppose we have a following HTML element in page:
// <div id="tags" />
const tagsInput = new Taggle(document.querySelector('#tags'), {
allowDuplicates: false,
preserveCase: true,
attachTagId: true,
// tags: preexistingTagsToPrefilTheinput,
// onTagAdd: (e, tag) => {
// console.log('adding tag', tag);
davorbadrov / find_multiple.sql
Last active Aug 6, 2017
SQL - Find multiple entries inside a table for given values.
View find_multiple.sql
# find multiple entries for a certain fields
select count(*), field1, field2 from some_table group by field1, field2 having count(*) > 1;
davorbadrov / index.js
Created Dec 23, 2015
Simple React/Redux example, taken from Dan Abramov's Redux tutorial series on
View index.js
import React from 'react';
import ReactDOM from 'react-dom';
import expect from 'expect';
import { createStore } from 'redux';
* The reducer function which takes a state and action,
* returns the new state
* @param {Number} state old state from the store
View PromisifyAll
var Promise = require('bluebird');
// Transforms node based callbacks into methods that return Promises
Promise.promisifyAll(Awesomify);, function (jsonItem) {
return Awesomify.transformAsync(jsonItem);
.then(function(transformedResults) {
davorbadrov / index.html
Created Nov 4, 2015
Responsive elements with dynamic content using table styling.
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>JS Bin</title>
<link rel="stylesheet" href="main.css">
<div class="bar-container">
<div class="bar"></div>
You can’t perform that action at this time.