Skip to content

Instantly share code, notes, and snippets.

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest",
testMatch: [
'**/__tests__/**/*.[jt]s?(x)',
'**/?(*.)+(spec|test).[jt]s?(x)',
'**/test/file-i-am-debugging.ts',
],
testPathIgnorePatterns: [
@qcom
qcom / git-filter-branch-move-files.md
Created June 8, 2020 14:37 — forked from fabiomaggio/git-filter-branch-move-files.md
Use git filter-branch to move all projects files to a subdir and rewrite all commits
  1. Clone project

  2. Checkout all branches that contain the files that should be moved

  3. Delete the remote

  4. Run the filter-branch command:

    git filter-branch --tree-filter 'mkdir -p /path/to/tmp; mv * /path/to/tmp; mkdir subdir; mv /path/to/tmp/* subdir/' --tag-name-filter cat --prune-empty -- --all
    • All files are first copied to a temporary dir and move from there to the new destination
  • Existing tags are updated
US wall power outlet <–––> Transformer [hard-wired power cord; male]
Transformer [OUTPUT 220V port; female] <–––> UK power cord [male]
UK power cord [female] <–––> Technics [AC power socket]
@qcom
qcom / out
Created March 22, 2016 21:49
> err
{ handle: 2,
type: 'error',
className: 'Error',
constructorFunction: { ref: 10 },
protoObject: { ref: 11 },
prototypeObject: { ref: 1 },
properties:
[ { name: 'stack', attributes: 2, propertyType: 3, ref: 1 },
{ name: 'message', attributes: 2, propertyType: 0, ref: 12 },
gulp.task('jsx', function() {
return browserify({
entries: paths.reactEntryPoints,
extensions: ['jsx'],
debug: true
}).transform(babelify.configure({
presets: ['es2015', 'stage-1', 'react']
})).bundle()
.on('error', function(err) { console.error(err.message); this.emit('end'); })
.pipe(source('components.js'))
@qcom
qcom / reduce.js
Created January 16, 2014 22:27
An implementation of reduce modeled after the underscore.js api that does not default to Array.prototype.reduce.
function reduce(obj, iterator, memo, ctx) {
var keys = Object.keys(obj),
memo = memo || obj[keys[0]];
ctx = ctx || null;
for (var i = arguments[2] ? 0 : 1; i < keys.length; i++)
memo = iterator.call(ctx, memo, obj[keys[i]], keys[i], obj);
return memo;
}
@qcom
qcom / bind.js
Last active January 2, 2016 08:49
Function.prototype.bind = function(thisObj) {
var that = this;
return function() {
return that.apply(thisObj, arguments);
};
};
function fn() {
return this;
}
@qcom
qcom / db.js
Created January 3, 2014 06:07
overwrite mongodb document
DB.prototype.updateTodo = function(id, val, fn) {
this.db.collection('todo').update({ _id : id }, val, function(err) {
if (err) return fn(err);
console.log(arguments);
fn(null);
});
};
/*
@qcom
qcom / update.js
Created December 31, 2013 09:01
update an object given a slash-delimited path (where each element in path is a property) and a value
function update(path, val, obj) {
(function r(keys, o) {
if (keys.length > 1) {
var current = keys.shift();
if (!o[current])
o[current] = isNaN(parseInt(keys[0])) ? {} : [];
r(keys, o[current]);
} else {
o[keys[0]] = val;
}
@qcom
qcom / odds.scm
Last active December 27, 2015 03:09
return the elements of a list with an odd index (1, 3, 5, etc.)
(define (odds lis)
(reverse (odds-reduce lis '())))
(define (odds-reduce l1 l2)
(cond
((null? l1) l2)
((= (length l1) 1) (cons (car l1) l2))
(else (odds-reduce (cddr l1) (cons (car l1) l2)))
))