Skip to content

Instantly share code, notes, and snippets.

View qetr1ck-op's full-sized avatar
💫

Orest Prystayko qetr1ck-op

💫
View GitHub Profile
const api = {
get(p) {return p},
post() {},
patch() {},
put() {},
dele() {},
}
class Resource {
constructor(private api: any, private resourceUri: string) {}
@qetr1ck-op
qetr1ck-op / custom-promise.js
Last active July 16, 2018 20:08 — forked from ronkot/rastas-promise.js
Simple Promise implementation
const PENDING = 1;
const RESOLVED = 2;
const REJECTED = 3;
const callLater = fn => setTimeout(fn, 0);
class MyPromise {
constructor(fn) {
this._state = PENDING;
this._value = undefined;
@qetr1ck-op
qetr1ck-op / better-nodejs-require-paths.md
Created May 14, 2017 19:16 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

import eventTermsCtrl from './terms-controller';
describe('vv.manager.manager.event:EventTermsController', () => {
let sut, MimeType, eventService, enumService, FormValidationService, notificationService, eventResolve, isSuccess;
beforeEach(() => {
MimeType = {
pdf: {extensions: []}
};
import PasswordRecoveryService from './rest.service';
describe('vv.account.password-recovery:restService', () => {
let sut, Resource;
beforeEach(() => {
Resource = {
passwordRecovery: jasmine.createSpy('passwordRecovery').and.callFake(() => Resource),
post: jasmine.createSpy('post'),
patch: jasmine.createSpy('patch'),
export default class PromoCodeService {
constructor(Resource) {
this._resource = Resource;
}
create(eventId, promo) {
return this._resource.events(eventId).promoCodes().post(promo);
}
get(eventId, id) {
/* Vendor */
import ngMessages 'angular-messages';
import ngAnimate 'angular-animate';
import uiMessages 'angular-ui-mask/dist/mask';
import ngGA from 'angular-google-analytics';
import uiRoute from 'angular-ui-router';
import 'ui-router-extras/release/modular/ct-ui-router-extras.core.js';
import 'ui-router-extras/release/modular/ct-ui-router-extras.transition.js';
import 'ui-router-extras/release/modular/ct-ui-router-extras.previous.js';
// Karma configuration
// Generated on Wed Nov 02 2016 10:09:14 GMT+0200 (FLE Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
import ContactCtrl from './contact.ctrl';
describe('vv.account.contact:ContactCtrl', () => {
let sut, accountEnumService, analyticsService;
beforeEach(() => {
accountEnumService = {
slides: {
contact: []
},
const fs = require('fs');
const zlib = require('zlib');
const filename = process.argv[2];
fs.readFile(filename, (err, content) => {
zlib.gzip(content, (err, gzipedContent) => {
fs.writeFile(`${filename}.gz`, gzipedContent, err => {
console.log('file compresed');
})