Skip to content

Instantly share code, notes, and snippets.

View evenfrost's full-sized avatar

Aliaksei Kislou evenfrost

View GitHub Profile
@evenfrost
evenfrost / discovery-400.js
Created September 28, 2017 14:05
Discovery returning 400 error on long queries
const DiscoveryV1 = require('watson-developer-cloud/discovery/v1');
const discovery = new DiscoveryV1({
username: USERNAME,
password: PASSWORD,
version_date: '2017-09-01',
});
const query = callback => {
discovery.query({
@evenfrost
evenfrost / lodash.js
Created November 9, 2017 18:31
Convert sequelize v4 query response to plain objects preserving all types and associations
const toPlain = response => {
const flattenDataValues = ({ dataValues }) =>
_.mapValues(dataValues, value => (
_.isArray(value) && _.isObject(value[0]) && _.isObject(value[0].dataValues)
? _.map(value, flattenDataValues)
: _.isObject(value) && _.isObject(value.dataValues)
? flattenDataValues(value)
: value
));
@evenfrost
evenfrost / backup_restore.sh
Last active March 5, 2018 16:14
Backup and restore Posgtres from/to Docker container
# backup from Docker container
docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
# restore to Docker container
cat dump.sql | docker exec -i postgres-container-id psql -U postgres
@evenfrost
evenfrost / func.js
Created October 11, 2018 16:26
Just simple JS function
function isGreater(a, b, cb) {
var greater = false;
if (a > b) {
greater = true;
}
cb(greater);
}
@evenfrost
evenfrost / highlight.ts
Last active April 3, 2025 07:52
Fuse.js with highlight
const highlight = (fuseSearchResult: any, highlightClassName: string = 'highlight') => {
const set = (obj: object, path: string, value: any) => {
const pathValue = path.split('.');
let i;
for (i = 0; i < pathValue.length - 1; i++) {
obj = obj[pathValue[i]];
}
obj[pathValue[i]] = value;
@evenfrost
evenfrost / reset-gnome-screensaver.sh
Last active February 12, 2019 10:04
Reset GNOME screensaver
killall gnome-screensaver
@evenfrost
evenfrost / svgo.sh
Last active December 30, 2022 17:38
svgo --pretty --indent=2 --disable=removeViewBox,mergePaths --enable=inlineStyles --config '{ "plugins": [ { "inlineStyles": { "onlyMatchedOnce": false } }] }' icon.svg
@evenfrost
evenfrost / mongo.sh
Created May 4, 2019 09:30
Some MongoDB commands
# dump database from Docker container
docker run --rm --link mongo:mongo -v /var/dumps/mongo:/backup mongo bash -c 'mongodump --gzip --archive=/backup/dump-$(date +%Y%m%d%H%M%S).gz --host=mongo:27017'

Hello Aleksey,

We’d like to provide open source modular theming examples accessible on GitHub sometime in the future, but hopefully this will answer your question in the short term.

1. The Handlebars Partials File

The contents of the community-posts module’s partials.js file are as follows:

const communityPostsListItem = `
@evenfrost
evenfrost / formZendeskInterface.js
Last active September 9, 2021 07:43
Form TS interface from Zendesk API page
function formInterface() {
const categoryName = document.querySelector('[class^="contentHeader__Container"] h1').textContent.slice(0, -1);
const table = document.querySelector('[class^="documentContent__DocumentContent"] [class^="renderToHtmlWithGarden__TableContainer"] table');
const getTsType = zendeskType => {
let tsType = null;
switch (zendeskType) {
case 'integer':
tsType = 'number';