Skip to content

Instantly share code, notes, and snippets.

@yoojene
yoojene / index.html
Created February 18, 2016 14:47
Toggle Icon (class) on Item List
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="script.js"></script>
<link href="style.css" type="text/css" rel="stylesheet">
@yoojene
yoojene / mxrnachs.js
Created March 8, 2016 08:26
TRM code for calculating nominal accumulated lost customer hours (Maximo)
/**
* NACHS (LCH) Calculator
*
* @param mbo
* Primary mbo on which to run the NACHS (LCH) Calculator. In essence this is either INCIDENT or WORKORDER.ORIGTICKET[0] depending on if this is called from the button or onSave rule
*
* @return lch
*/

Keybase proof

I hereby claim:

  • I am yoojene on github.
  • I am yoojene (https://keybase.io/yoojene) on keybase.
  • I have a public key ASDYeL5If2N8HygWAROdrgJknlLhVg1oV87NjTDkdmMbHgo

To claim this, I am signing this object:

@yoojene
yoojene / myHealthModalRadio.html
Created March 22, 2017 15:08
Markup for styled radio list item. ng-class is supposed to style each selected item but initialises as all 'selected'
<label class="item item-radio" ng-repeat="nb in data.notebooks">
<input type="radio" ng-model="nb.isSelected" ng-value="$index" ng-click="data.selectNb(nb, $index)" id="dci_Main_InputRadio_Select_{{$index}}">
<div class="item-content" ng-class="{'newton-my-health-mood-modal-radio-selected' : nb.isSelected === data.selected.idx }">
{{nb.attributes.name}}
</div>
</label>
@yoojene
yoojene / filter array of objects
Last active March 31, 2017 16:59
Search array of objects for for items with property 'isActive' = true
var activeEvents = [];
activeEvents = res.filter(function (v) {
return v.isActive = true;
});
@yoojene
yoojene / Array_reduce.js
Last active November 11, 2017 13:48
Flatten array of objects into single object
// items
// [{:url:"www.mysite.com"}, {description: "Here's a link to my site"}]
let flatItems = items.reduce((acc, i) => Object.assign({}, acc, i), {});
// flatItems
// {url:"www.mysite.com", description: "Here's a link to my site"}
@yoojene
yoojene / shorthame_object_create.js
Last active November 15, 2017 19:24
Shorthand initialise object with same property name
onRemove(group, index) {
this.removed.emit( {group, index} )
}
// Creates new object with values and properties same as passed arguments
// { group: group, index: index }
@yoojene
yoojene / Array_Obj_flatten.js
Created February 21, 2018 15:51
Convert Array of Objects to single object mapping key/values
/*
form =
[{"slot":"email","value":"eugene.cross@gmail.com"},{"slot":"password","value":"12345"},{"slot":"repeatPassword","value":"12345"},{"slot":"designationName","value":"Yoojene"},{"slot":"firstName","value":"Eugene"},{"slot":"lastName","value":"Cross"},{"slot":"municipality","value":"London"},{"slot":"workplace","value":"Home Office"}]
*/
let flattened = {};
form.forEach(el => {
flattened[el.slot] = el.value;
});
/*
flattened
@yoojene
yoojene / .gitignore
Created February 22, 2018 15:13
My .gitignore
# Node
node_modules/*
npm-debug.log
# TypeScript
src/*.js
src/*.map
src/*.d.ts
# Python
@yoojene
yoojene / sort_dates.js
Created June 6, 2018 09:25
Simple date sort function native JS date object
const record = [
{id: 1,age:30, name:"Steph Curry",date: "14/03/18 13:07"},
{id: 2,age:28, name:"Klay Thompson",date: "08/02/18 16:30"},
{id: 3,age:29, name:"Kevin Durant",date: "29/09/18 12:34"}
];
// Using native new Date(), convert to miliseconds and subtract from one another.
record.sort((a, b) => {
return new Date(a.date).getTime() - new Date(b.date).getTime()