Skip to content

Instantly share code, notes, and snippets.

View Craga89's full-sized avatar

Craig Michael Thompson Craga89

View GitHub Profile
@Craga89
Craga89 / data.json
Last active August 17, 2018 12:27
Aptitude Test - Address Data
[
{
"owner": "Carlos Vives",
"address": {
"line1": "Flat 5",
"line4": "7 Westbourne Terrace",
"postCode": "W2 3UL",
"city": "London",
"country": "U.K."
},
const get = require('lodash/get');
const isNil = require('lodash/isNil');
const omitBy = require('lodash/omitBy');
const identity = require('lodash/identity');
const { createImport } = require('../urls');
const { listTableColumns } = require('./tableColumn');
const NO_MORE_INFORMATION = 'No more information available.';
const RESULT_TYPE_FAILED_INSERTING = 'FailedInserting';
@Craga89
Craga89 / create-branch-bookmarklet.js
Last active April 20, 2018 09:45
Launches the Bitbucket Server "Create Branch" dialog with correct params based on your selected JIRA issue (or prompts if none selected)
javascript:(async function openDialog() { let issueTypesMap = { 'Sub-bug': 'Bug', 'Sub-task': 'Story', 'Task': 'Story' }; let issueKey; if (/^\/browse\//.test(location.pathname)) { issueKey = (location.pathname.match(/^\/browse\/([^&\/]+)/) || [])[1]; } else { issueKey = (window.location.search.match(/selectedIssue=([^&]+)/) || [])[1]; } if (!issueKey) { issueKey = prompt('No Issue Key detected on the page. Enter the Issue Key here'); } const request = await fetch('https://communicatorcorp.atlassian.net/rest/api/2/issue/' + issueKey, { credentials: 'include' }); const json = await request.json(); const issueTypeName = json.fields.issuetype.name; const issueType = issueTypesMap[issueTypeName] || issueTypeName; const branchNameSlug = json.fields.summary.toString().toLowerCase() .replace(/\s+/g, '-') /* Replace spaces with - */ .replace(/[^\w\-]+/g, '') /* Remove all non-word chars */ .replace(/\-\-+/g, '-') /* Replace multiple - with single - */ .replace(/^-+/, '') /* Trim - from start of text */ .replace(/-+$/
{
"ClientTableId": 0,
"TriggeredDispatches": {
"TriggeredDispatch[]": [
{
"DispatchId": 0,
"TriggeredDispatchMethod": "OnlySendToNewSubscribers"
}
]
},
@Craga89
Craga89 / withGridParts.js
Created February 21, 2018 16:40
Generic withGridFunctionality HOC
import PropTypes from 'prop-types';
/**
* Generates a map of query parameters and their associated values when given
* a `queryProps` map and some `props` values.
*
* @param queryProps {Object} Map of prop names to associated queryProp definitions
* @param props {Object} Current props to generate values from
* @returns {Object} Query parameters map
*/
@Craga89
Craga89 / AppContext.js
Created February 21, 2018 15:55
Add Toasters to AppContext
import { USER } from 'globals';
import PropTypes from 'prop-types';
import uniqueId from 'lodash/uniqueId';
import compose from 'recompact/compose';
import withContext from 'recompact/withContext';
import withReducer from 'recompact/withReducer';
import injectCss from 'react/common/hocs/injectCss';
import componentsCoreCssUrl from '@communicator/components.core/dist/communicator.components.core.css';
@Craga89
Craga89 / cloudSettings
Created November 30, 2016 10:03
Visual Studio Code Sync Settings GIST
{"lastUpload":"2016-11-30T10:03:05.626Z"}
@Craga89
Craga89 / react-select-allowCreate.js
Created February 6, 2016 19:58
A workaround for react-select 1.0.0 to implement allowCreate functionality
let isSelected = (values, selectedValue) => {
if (!values || values.length < 1) {
return false;
}
for (let { value } of values) {
if (selectedValue === value) {
return true;
}
}
@Craga89
Craga89 / romanNumerals-usage.js
Last active December 2, 2015 14:38
Generic method for generating Roman Numerals for numbers 0 - 1M
romanNumeral(5) // "V"
romanNumeral(9) // "IX"
romanNumeral(46) // "XL"
romanNumeral(2015) // "MMXV"
@Craga89
Craga89 / tether.transition.css
Last active September 8, 2015 15:35
Tether.js - Transition small movements
.tether.tether-transition {
transition: -webkit-transform 100ms ease-in-out;
transition: transform 100ms ease-in-out;
}