Skip to content

Instantly share code, notes, and snippets.

@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@aheckmann
aheckmann / mongoose-cpu-load-test.js
Created August 28, 2013 03:00
tweak various mongoose settings to observe cpu impact.
/**
* configuration
*/
// connection pool size
var poolSize = 5;
// number of parallel queries
var n = 60;
var LRU = require('lru-cache');
var i = 0;
var sets = 0;
var start = Date.now();
var last = Date.now();
var max = 8193; // 8192 is the magic number upper perf limit of plain objects
var maxAge = 1000 * 60 * 60 * 24;
'use strict';
// run using this fork of NodeJS
// https://github.com/targos/node/commits/v8-5.4 (https://github.com/nodejs/node/pull/8317)
//
// node --harmony_async_await await_thenables.js
function counter(count) {
return {
then: function(res, rej) {
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
mongoose.connect('localhost', 'testing_1088');
mongoose.connection.on('error', function () {
@aheckmann
aheckmann / burn.md
Last active January 5, 2023 22:53
How to get rid of Solana spam NFTs
  1. Open a private tab
  2. Create a completely new wallet by visiting https://www.sollet.io
  3. You will see a screen displaying "Create new wallet" and a list of seed words
  4. Copy the seed words
  5. Check the box next to "I have saved these words in a safe place."
  6. Click "DOWNLOAD BACKUP MNEMONIC FILE (REQUIRED)". This downloads your seed phrase. Delete this file.
  7. Click "continue"
  8. Paste the seed words when it asks you to, then click continue
  9. Click "Main Account" at the top of the screen to copy the new wallet address. This address is where you'll send your spam NFTs.
  10. Open your Phantom wallet (assuming you are using Phantom)
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var dbname = 'testing_geojsonPoint';
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, db = mongoose.connect('localhost', 'testing_streaming').connection
, Stream = require('stream').Stream
, express = require('express')
/**
* Dummy schema.
*/
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var schema = new Schema({
@aheckmann
aheckmann / ignoreEmptyStrings.js
Created May 23, 2013 22:47
ignore empty strings when setting ObjectIds
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var uri = 'mongodb://localhost/testing_optionalObjectid';