Skip to content

Instantly share code, notes, and snippets.

View jest.config.js
/** @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 Jun 8, 2020 — 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
View git-filter-branch-move-files.md
  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
View power
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]
View out
> 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 },
View gulpfile.js
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 Jan 16, 2014
An implementation of reduce modeled after the underscore.js api that does not default to Array.prototype.reduce.
View reduce.js
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;
}
View bind.js
Function.prototype.bind = function(thisObj) {
var that = this;
return function() {
return that.apply(thisObj, arguments);
};
};
function fn() {
return this;
}
@qcom
qcom / db.js
Created Jan 3, 2014
overwrite mongodb document
View db.js
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 Dec 31, 2013
update an object given a slash-delimited path (where each element in path is a property) and a value
View update.js
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 Dec 27, 2015
return the elements of a list with an odd index (1, 3, 5, etc.)
View odds.scm
(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)))
))