Skip to content

Instantly share code, notes, and snippets.

🔮
the only way out is through

isaacs isaacs

🔮
the only way out is through
Block or report user

Report or block isaacs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View for-krainbolt.sh
#!/bin/bash
a () {
sleep 1
echo a
}
b () {
sleep 1
echo b
}
View gist:38204dd8862e549d5d5209fa1d21b36a
diff --git a/cache.js b/cache.js
index f842ba1..f00de14 100644
--- a/cache.js
+++ b/cache.js
@@ -169,7 +169,7 @@ module.exports = class Cache {
cacheTargetStream ? cacheTargetStream.end(done) : done()
})
const oldBody = response.body
- const newBody = through({highWaterMark: fitInMemory && MAX_MEM_SIZE})
+ const newBody = through({highWaterMark: MAX_MEM_SIZE})
View gist:f5e33bff9eeab07aad1cc80a9a3c2425
diff --git a/cache.js b/cache.js
index ee2ba68..ff7e1a4 100644
--- a/cache.js
+++ b/cache.js
@@ -65,10 +65,10 @@ module.exports = class Cache {
// avoid opening cache file handles until a user actually tries to
// read from it.
const body = new Minipass()
- const notFitInMemory = false && info.size > MAX_MEM_SIZE
+ const fitInMemory = info.size < MAX_MEM_SIZE
View index.js
const gfs2 = require('gf')
const gfs = require('graceful-fs')
const fs = require('fs')
gfs.gracefulify(fs)
gfs2.gracefulify(fs)
fs.createReadStream(__filename)
View npm package list puzzle.md

Here's a puzzle to noodle on:

Let's say package.json contains this:

{
  "files": [
    "lib",
    "!lib/one",
    "lib/two"
  ]
View read-git-index.js
const fs = require('fs')
const index = fs.readFileSync('.git/index')
const result = {}
let p = 0
result.signature = index.slice(p, p + 4).toString('ascii')
p += 4
if (result.signature !== 'DIRC') {
throw new Error('not a git index file')
}
View .vimrc
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
call plug#end()
set nu
set encoding=utf-8
let mapleader=","
View pool.js
const {executionAsyncId, AsyncResource} = require('async_hooks')
const _handle = Symbol('_handle')
class ConnectionWrap extends AsyncResource {
constructor (connection) {
super('connection.' + connection.id)
this[_handle] = connection
// Polyfill for Node.js 8 and before
/* istanbul ignore next */
View gist:f72518b06d2644b9b86955d63cd10931
diff --git a/bin/run.js b/bin/run.js
index 09056db..ee986d4 100755
--- a/bin/run.js
+++ b/bin/run.js
@@ -251,15 +251,28 @@ const nycReporter = options =>
const runNyc = (cmd, programArgs, options, spawnOpts) => {
const reporter = nycReporter(options)
+ const branches = Math.max(+options.branches || 100, 100)
+ const lines = Math.max(+options.lines || 100, 100)
View ignore-if-badidea.js
const test = n => {
if (n === 1) {
console.log(n)
} else if (n === 2) {
console.log(2)
} /* istanbul ignore next */ else if (1 === 2) {
console.log('math is broken')
} else {
console.log('n is some other thing')
}
You can’t perform that action at this time.