:%!python -m json.tool
:set ft=json
:%s/ / /g
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
#!/bin/sh | |
ls -pla | grep -v / | grep "^." | sort -k 5nr |
Firefox Scratchpad that parse metrics from manning's dashboard:
function getElementsCount(attributeName) {
return document.querySelectorAll(`#productTable > tbody > tr[${attributeName}=true]`).length;
}
var labelsMap = new Map([
['is-book', 'books'],
['is-meap', 'meaps'],
Command to move files to Ubuntu trash for files older than:
find . -type f -name '*.txt' -mtime +7 -exec gio trash {} \;
Where:
find .
: search current folder-type f
: limit search to files-name '*.txt*'
: limit search to files that have.txt
extension-mtime +7
: last modification date is >= 7 days
Simple example that demonstrates how to test environment variables from Jest
describe('models/env unit tests', () => {
function importTestedModule() {
return require('../../../src').models; // eslint-disable-line
}
beforeEach(() => {
jest.resetModules();
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
'use strict'; | |
const neatCsv = require('neat-csv'); | |
async function parseResponseToJson(apiResponse) { | |
try { | |
const result = await neatCsv(apiResponse.body, { | |
separator: ';' | |
}); | |
return result; |
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
'use strict'; | |
let neatCsv = require('neat-csv'); | |
let { parseResponseToJson } = require('./neat-csv.js'); | |
jest.mock('neat-csv', () => | |
jest.fn().mockRejectedValueOnce(new Error('Error while parsing')) | |
); | |
const csv = 'type;part\nunicorn;horn\nrainbow;pink'; |
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
#!/usr/bin/env node | |
'use strict'; | |
const f = new Map(); | |
f.set('availpro:1', {id: 1, provider: 'availpro', name: 'Hotel du sentier', rating: 3}); // delete | |
f.set('synxis:2', {id: 2, provider: 'synxis', name: 'Hotel Opera', rating: 0}); // update | |
f.set('fastbooking:3', {id: 3, provider: 'fastbooking', name: 'Hotel Garnier', rating: 5}); // skip | |
const s = new Map(); |
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
'use strict'; | |
const { SinglyLinkedList, Node } = require('./../interview'); | |
const assert = require('assert'); | |
describe('SingleLinkedList.reverse', function() { | |
let linkedList; | |
beforeEach(() => { |