Skip to content

Instantly share code, notes, and snippets.

@nginnever
nginnever / karma.config.js
Created February 10, 2016 18:07
Webpack noParse example for node-forge build
module.exports = function (config) {
var path = require('path')
var node_modules_dir = path.join(__dirname, 'node_modules')
var deps = [
'path-to-your-bundle-file/forge.bundle.js'
]
config.set({
basePath: '',
frameworks: ['mocha'],
@nginnever
nginnever / bufferImporter.js
Created February 18, 2016 21:52
stream buffer piped to fixedSizeChunker then work is done on it
function bufferImporter (buffer, callback) {
if(!Buffer.isBuffer(buffer)) {
callback('buffer importer must take a buffer')
}
const links = [] // { Hash: , Size: , Name: }
var bufferStream = new stream
bufferStream.push(buffer)
bufferStream.push(null)
@nginnever
nginnever / bufferImporter2.js
Last active February 18, 2016 21:58
fixedSizeChunker pushed to and piped out then work is done on it
function bufferImporter (buffer, callback) {
if(!Buffer.isBuffer(buffer)) {
callback('buffer importer must take a buffer')
}
const links = [] // { Hash: , Size: , Name: }
var fsc = new FixedSizeChunker(CHUNK_SIZE)
fsc.write(buffer)
fsc.end()
@nginnever
nginnever / bufferStream.js
Created February 18, 2016 22:29
buffer to stream
const stream = require( "stream" )
const fileSystem = require( "fs" )
const util = require( "util" )
// turn the given source Buffer into a Readable stream.
function BufferStream(source) {
if (!Buffer.isBuffer(source)) {
throw(new Error("Source must be a buffer."))
}
// Super constructor.
@nginnever
nginnever / fixedsizedchunker.js
Created February 19, 2016 01:02
fixedSizedChunker Change
var through2 = require('through2')
exports = module.exports = FixedSizeChunker
// The difference of this chunker compared to other fixed size chunkers
// available, is that it doesn't add padding the last chunk
function FixedSizeChunker (size) {
var stream = through2(transform, flush)
@nginnever
nginnever / CONTRIBUTING.md
Last active March 12, 2016 00:12
first shot

Contributing

Internationalization

IPFS WebUI has internationalization support, strings for translation can be marked by the i18n.t function. Example: <h3>Node Info</h3> becomes <h3>{i18n.t('Node Info')}</h3>. If you add a new string like this, be sure to add it to static/locale/webui-en.json as well, otherwise it would not be displayed in the UI. The same applies if you need to edit an existing string.

Our translation project is here: https://www.transifex.com/ipfs/ipfs/

'use strict'
const defaultRepo = require('./default-repo')
const blocks = require('ipfs-blocks')
const BlockService = blocks.BlockService
const Block = blocks.Block
const mDAG = require('ipfs-merkle-dag')
const DAGNode = mDAG.DAGNode
const DAGService = mDAG.DAGService
const peerId = require('peer-id')
'use strict'
const Command = require('ronin').Command
const IPFS = require('../../../core')
const debug = require('debug')
const log = debug('cli:version')
log.error = debug('cli:version:error')
const bs58 = require('bs58')
module.exports = Command.extend({
function fileExporter (node, name, dir, callback) {
if (typeof dir === 'function') { callback = dir; dir = {} }
var rs = new Readable()
if (node.links.length === 0) {
const unmarshaledData = UnixFS.unmarshal(node.data)
rs.push(unmarshaledData.data)
rs.push(null)
ee.emit('file', { stream: rs, path: name, dir: dir })
callback()
} else {
{
"_args": [
[
"ipfs-unixfs-engine",
"/Users/voxelot/Github/js-ipfs"
]
],
"_from": "ipfs-unixfs-engine@latest",
"_id": "[email protected]",
"_inCache": true,