Skip to content

Instantly share code, notes, and snippets.

View trygve-lie's full-sized avatar

Trygve Lie trygve-lie

View GitHub Profile
@kevincennis
kevincennis / v8.md
Last active May 6, 2024 05:25
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • $ nano ~/.zshrc
    • Add path=('/path/to/depot_tools' $path)
@max-mapper
max-mapper / index.js
Last active May 9, 2021 02:20
fast loading of a large dataset into leveldb
// data comes from here http://stat-computing.org/dataexpo/2009/the-data.html
// download 1994.csv.bz2 and unpack by running: cat 1994.csv.bz2 | bzip2 -d > 1994.csv
// 1994.csv should be ~5.2 million lines and 500MB
// importing all rows into leveldb took ~50 seconds on my machine
// there are two main techniques at work here:
// 1: never create JS objects, leave the data as binary the entire time (binary-split does this)
// 2: group lines into 16 MB batches, to take advantage of leveldbs batch API (byte-stream does this)
var level = require('level')
@jed
jed / level-incremental-id.js
Last active December 17, 2015 04:29
an approach for incremental ids using levelup.
var levelup = require("levelup")
var path = __dirname + "db"
var options = {encoding: "json"}
var db = levelup(path, options)
function id(cb) {
if (typeof cb != "function") throw new TypeError
if (!id.queue) {
id.queue = []
@alexcwatt
alexcwatt / markercluster_multi-layer-markers.html
Last active December 16, 2015 09:19
Example of markers in multiple layers with Leaflet markercluster. Copied from a project using Twitter Bootstrap and jQuery.
<div id="map-buttons" class="btn-group" data-toggle="buttons-checkbox">
<button id="layer1" class="btn active">Layer 1</button>
<button id="layer2" class="btn active">Layer 2</button>
<button id="layer3" class="btn active">Layer 3</button>
</div>
<script type="text/javascript">
// Setup "layer" arrays
layer1Array = new Array();
layer2Array = new Array();
@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active April 2, 2024 20:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version