This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// service file | |
export const createStockLevelChecker = (serviceLocator) => { | |
return async (offerId) => { | |
const offer = await serviceLocator.offerService.read(offerId); | |
if (offer) { | |
return "there is stock"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example allows: | |
// | |
// `age` to be zero as a valid initial value, or any other number. If its undefined the input | |
// will be empty instead of zero. | |
// | |
// `value` to be undefined, leaving please select as selected, or preset to any other number | |
// including zero. | |
// | |
// It also makes use of yup's schema.cast (post submit) to get around select values | |
// coming out as strings. This is better than manually having to catch these cases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { render } from "react-dom"; | |
import { | |
Formik, | |
FieldArray, | |
Field, | |
Form, | |
FormikProps, | |
ArrayHelpers | |
} from "formik"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var moment = require('moment-timezone') | |
, prevAbbr = moment.fn.zoneAbbr | |
, timezoneTranslations = { | |
'Europe/Istanbul': 'TSİ' | |
} | |
moment.fn.zoneAbbr = function () { | |
var customTimezoneTranslation = timezoneTranslations[this._z.name] | |
return customTimezoneTranslation || prevAbbr.call(this) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mlcm = require('mlcm') | |
, frac = require('frac') | |
module.exports = function getMultiplier (prizes) { | |
if (prizes.length === 0) return 0 | |
if (Array.isArray(prizes) === false) throw new Error('getMultiplier requires an array') | |
return mlcm(prizes.map(function (prize) { | |
return frac(prize.chance, Infinity)[2] | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
people.sort(function (a, b) { | |
return a.name > b.name | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function map (arr, fn, ctx = this) { | |
return Promise.all(arr.map((item, index) => { | |
return new Promise((resolve, reject) => { | |
fn.call(ctx, item, index, arr, resolve, reject) | |
}) | |
})) | |
} | |
var arr = [1, 2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global user.name "YOUR REAL NAME ON GITHUB" | |
git config --global user.email youremail@gmail.com | |
git remote remove origin | |
git remote add origin git@github.com:yourusername/yourrepo | |
git push -u origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
class Shape { | |
public: | |
virtual void print() = 0; | |
}; | |
class Square : public Shape { | |
virtual void print() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct NotCopyable { | |
// defaulted and deleted funtions are only available in C++11 | |
NotCopyable(const NotCopyable&) = delete; | |
// Overriding the = operator so you can't copy one NotCopyable to another | |
// one | |
NotCopyable& operator=(const NotCopyable&) = delete; | |
// You would need the following line to be able to construct an instance of this | |
// struct at all |
NewerOlder