Skip to content

Instantly share code, notes, and snippets.

View sktwentysix's full-sized avatar

Shane Kinsella sktwentysix

  • Software Engineer
  • Bangkok, Thailand
View GitHub Profile
@sktwentysix
sktwentysix / App.js
Last active May 2, 2019 10:06
medium-ocr-react-generate2
<button onClick={this.generateText} className="button">Generate</button>
...
{ /* Results */ }
<section className="results">
{ this.state.documents.map((value, index) => {
return (
<div key={index} className="results__result">
<div className="results__result__image">
@sktwentysix
sktwentysix / dates.js
Last active May 11, 2022 14:48
Javascript DateTime Functions
function getYearMonthDay(isoDateTime) {
const year = date.getFullYear()
const month = (date.getMonth() + 1 < 10 ? '0' : '') + (date.getMonth() + 1)
const day = date.getDate();
return year + '/' + month + '/' + day
}
function getDayMonthYear(isoDateTime) {
const year = date.getFullYear()
const month = (date.getMonth() + 1 < 10 ? '0' : '') + (date.getMonth() + 1)
@sktwentysix
sktwentysix / array_reducer_example_01.js
Created June 9, 2022 12:03
A simple array reducer example using objects
const array = [
{ id: 111, framework: 'react' },
{ id: 222, framework: 'angular' },
{ id: 333, framework: 'vue' }
];
const reducerCallback = (prevItem, currItem) => {
return {
id: prevItem.id + currItem.id,
framework: prevItem.framework + "-" + currItem.framework
const array = [1,5,3,9,6,2,4]
const reducerCallback = (prevItem, currItem) => {
return prevItem + currItem
}
console.log(array.reduce(reducerCallback)) // 30
const survey = [
{ name: "Zuri", votedFramework: 'react' },
{ name: "Sofia", votedFramework: 'angular' },
{ name: "Elon", votedFramework: 'react' },
{ name: "Joe", votedFramework: 'react' },
{ name: "Alex", votedFramework: 'angular' },
{ name: "Josh", votedFramework: 'vue' },
{ name: "Jade", votedFramework: 'react' },
{ name: "Ted", votedFramework: 'angular' },
{ name: "Leo", votedFramework: 'react' },
const survey = [
{ name: "Zuri", votedFramework: 'react' },
{ name: "Sofia", votedFramework: 'angular' },
{ name: "Elon", votedFramework: 'react' },
{ name: "Joe", votedFramework: 'react' },
{ name: "Alex", votedFramework: 'angular' },
{ name: "Josh", votedFramework: 'vue' },
{ name: "Jade", votedFramework: 'react' },
{ name: "Ted", votedFramework: 'angular' },
{ name: "Leo", votedFramework: 'react' },