Skip to content

Instantly share code, notes, and snippets.

import { Kind } from 'graphql';
function parseLiteral(value) {
return ast.kind === Kind.BOOLEAN ? ast.value : undefined;
}
function parseValue(value) {
if (typeof value !== 'boolean') {
throw new TypeError(
`Boolean cannot represent a non boolean value: ${inspect(value)}`,
);
}
return value;
}
@alizhdanov
alizhdanov / serialize.js
Created October 24, 2018 16:05
GraphQL Boolean serialization
function serializeBoolean(value) {
if (typeof value === 'boolean') {
return value;
}
if (isFinite(value)) {
return value !== 0;
}
throw new TypeError(
`Boolean cannot represent a non boolean value: ${inspect(value)}`,
);
@alizhdanov
alizhdanov / asci.sh
Created September 26, 2018 15:04
ascidoc to epub
asciidoctor -d book -b docbook5 book.asciidoc -o output.docbook
pandoc -f docbook -t epub out.docbook -o book.epub
@alizhdanov
alizhdanov / simpleGeo.js
Created September 1, 2018 12:49
Simple geolocation API example
const success = position => {
const { latitude, longitude } = position.coords;
console.log(`Your coordinates - ${latitude}lat and ${longitude}lng`);
};
const error = err => {
console.log(err);
};
getCurrentPosition(success, error);
@alizhdanov
alizhdanov / promisedGeo.js
Last active September 1, 2018 12:48
Promisified geolocation
const getLocation = () => new Promise((resolve, reject) => {
const success = position => resolve(position);
const error = error => reject(error);
navigator.geolocation.getCurrentPosition(success, error);
})
try {
const position = await getLocation();
console.log(position);
@alizhdanov
alizhdanov / bash.sh
Last active December 19, 2017 12:18
set/get NODE_ENV
# set NODE_ENV
export NODE_ENV=production
# get NODE_ENV
echo $NODE_ENV
@alizhdanov
alizhdanov / State.md
Created November 16, 2017 15:29
Vuex cheat sheet

STATE

  • Inside store
state: {
  count: 0
}
@alizhdanov
alizhdanov / Events.md
Last active November 14, 2017 11:18
React docs cheat sheat

Handling Events

  • React events are named using camelCase, rather than lowercase.
  • With JSX you pass a function as the event handler, rather than a string.
<button onClick={activateLasers}>
  Activate Lasers
</button>
@alizhdanov
alizhdanov / bash.sh
Created November 9, 2017 14:14
Set environment variables
// to set/create variable use export
export NODE_ENV=development
// to get variable use echo and $ prefix
echo $NODE_ENV
// will return 'development'