Skip to content

Instantly share code, notes, and snippets.

View koresar's full-sized avatar

Vasyl Boroviak koresar

View GitHub Profile
@koresar
koresar / protector.js
Created July 21, 2021 08:54
Protect JS object properties
const HasProtectedAccessor = stampit({
// stamp configuration
deepConf: {
// collect all the property names to protect
protectedProperties: {}
},
statics: {
// API of the stamp
protectProperty(names) {
// will deep merge the base objects with `names`
@koresar
koresar / getters-setters.js
Created July 21, 2021 05:30
getters-setters test
const test = require("tape");
const stampit = require("../src/stampit");
function hasStringAccessor(name) {
let storedValue;
return stampit({
props: {
get [name]() {
return storedValue;
@koresar
koresar / verify-signature.js
Last active May 26, 2023 20:29
WebAuthn "none" signature verification
// The code below was largely taken from:
// https://github.com/strangerlabs/webauthn/blob/9959cb2b5f87692b8b1fecd799dd4029a3bf61b1/src/Webauthn.js#L501
const crypto = require("crypto");
const base64url = require("base64url");
const cbor = require("cbor");
function parseAttestationObject(attestationObject) {
const attestationObjectBuffer = base64url.toBuffer(attestationObject);
return cbor.decodeAllSync(attestationObjectBuffer)[0];
@koresar
koresar / 1clipboard.js
Created June 17, 2018 04:30 — forked from nika1235/1clipboard.js
1clipboard
module.exports = {
    ra: {
        action: {
            delete: 'Видалити',
            show: 'Перегляд',
            list: 'Список',
            save: 'Зберегти',
            create: 'Список',
            edit: 'Редагувати',
            sort: 'Сортувати',

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@koresar
koresar / 1clipboard.js
Created June 3, 2018 12:44
1clipboard
var ru = {
'WINDOW_MAIN':'1Clipboard',
'WINDOW_PREFERENCES':'Настройки',
'TOPBAR_RECENT':'Последние',
'TOPBAR_STARRED':'Избранные',
'TOPBAR_SEARCH':'Поиск',
'TOPBAR_MORE':'Дополнительно',
'TOPBAR_OFFLINE':'Offline',
'TOPBAR_PAUSED':'Пауза',
@koresar
koresar / ua.js
Last active October 26, 2017 02:36
1Clipboard Ukrainian translation
var ua = {
'WINDOW_MAIN':'1Clipboard',
'WINDOW_PREFERENCES':'Налаштування',
'TOPBAR_RECENT':'Останні',
'TOPBAR_STARRED':'Вибрані',
'TOPBAR_SEARCH':'Пошук',
'TOPBAR_MORE':'Додатково',
'TOPBAR_OFFLINE':'Offline',
'TOPBAR_PAUSED':'Пауза',
@koresar
koresar / app2-test3.js
Last active July 23, 2017 07:26
Fun with Stamps. Episode 17. Easy 100% unit test coverage in JS: - app2-test3.js
describe('server', () => {
const App = require('../app2');
it('should call exit process after setImmediate()', (done) => {
let errorCallback = null;
let setImmediateCalled = false;
const MockedApp = App.props({
http: {
createServer() {
return {
@koresar
koresar / app2-test2.js
Last active July 23, 2017 07:26
Fun with Stamps. Episode 17. Easy 100% unit test coverage in JS: - app2-test2.js
describe('routing', () => {
const App = require('../app2');
const {handleNotFound, handleGenericError} = App.compose.methods;
it('should set status code to 404 when no route found', (done) => {
handleNotFound({}, {}, (error) => {
if (!error || error.status !== 404) {
throw new Error('Error status should be 404');
}
done();
@koresar
koresar / app2-test1.js
Last active July 23, 2017 10:39
Fun with Stamps. Episode 17. Easy 100% unit test coverage in JS: - app2-test1.js
describe('express app setup', () => {
const http = {
createServer() {
return {on() {}, listen() {}};
}
};
const App = require('../app2').props({http});
it('should share ./public', (done) => {
const express = () => ({set() {}, use() {}});