Skip to content

Instantly share code, notes, and snippets.

@NelsonMinar
NelsonMinar / bulkinsert.js
Last active October 1, 2021 02:14
A demonstration of slow sqlite3 bulk inserts in node.js
// Demonstration that bulk insertsin Node.js sqlite3 using prepared statements is very slow.
// Usage: run with one command line argument, one of "db", "reuse", "finalize"
// Details: http://nelsonslog.wordpress.com/2014/11/16/node-js-sqlite3-very-slow-bulk-inserts/
var sqlite3 = require('sqlite3').verbose();
var start = Date.now();
var db = new sqlite3.Database('inserttest.sqlite');
var mode = process.argv[2], runs = "100";
db.serialize(function() {
@kashif
kashif / ubuntu-11.10-gems.erb
Created October 10, 2011 11:58 — forked from bensie/chef_bootstrap_rvm.erb
Chef bootstrap With rvm and ruby 1.9.3 on ubuntu 11.10
bash -c '
<% if knife_config[:bootstrap_proxy] -%>
(
cat <<'EOP'
<%= "proxy = #{knife_config[:bootstrap_proxy]}" %>
EOP
) > ~/.curlrc
<% end -%>
if [ ! -f /usr/bin/chef-client ]; then
@borgar
borgar / Tiny JavaScript tokenizer.js
Created June 24, 2010 12:33
A compact tokenizer written in JavaScript.
/*
* Tiny tokenizer
*
* - Accepts a subject string and an object of regular expressions for parsing
* - Returns an array of token objects
*
* tokenize('this is text.', { word:/\w+/, whitespace:/\s+/, punctuation:/[^\w\s]/ }, 'invalid');
* result => [{ token="this", type="word" },{ token=" ", type="whitespace" }, Object { token="is", type="word" }, ... ]
*
*/