Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
@BobNisco
BobNisco / controller.js
Last active February 27, 2023 15:43
onLongPress AngularJS Directive - Great for mobile!
// Somewhere in your controllers for this given example
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}
$scope.itemOnTouchEnd = function(id) {
console.log('Touch end');
}
@rjz
rjz / nvcexploder-noderoad-pdx.md
Created March 21, 2014 02:48
Notes from Ben Acker's talk at #noderoad PDX

Ben Acker (@nvcexploder / Walmart) - Node in Production

  • Impetus: Walmart wanted a mobile presence. They built an application that looked like it was created by a giant retail operation--SOAP services, etc.
  • Started looking for other options: native apps,
  • Started with services team (worked on original app, spinning out to other mobile apps)--all of a sudden had loads of different clients consuming the services. Converting old soap/XML into something mobile-friendly?
  • High volume days (black Friday) start taking services down, and services team already distracted by mobile projects
  • Time to start building better services
  • Brought Eran Hammer over from Yahoo and gave him the go-ahead to use anything he wanted to improve mobile services. He chose node.
  • Walmart's been open-source from the start
  • But how to maintain legacy services?
@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active December 24, 2023 05:25
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
var attempts = 1;
function createWebSocket () {
var connection = new WebSocket();
connection.onopen = function () {
// reset the tries back to 1 since we have a new connection opened.
attempts = 1;
// ...Your app's logic...
@ardcore
ardcore / atom-events
Last active October 13, 2021 20:35
atom.io events
application:open-your-keymap
application:open-your-stylesheet
autocomplete:attach
autoflow:reflow-paragraph
bookmarks:clear-bookmarks
bookmarks:jump-to-next-bookmark
bookmarks:jump-to-previous-bookmark
bookmarks:toggle-bookmark
bookmarks:view-all
check:correct-misspelling
/* jshint node: true */
/* global open: true */
//NOTE: check out gulp-cache, gulp-modernizr, gulp-jscs
// var path = require('path');
var _ = require('lodash');
var connect = require('connect');
var open = require('open');
var tinylr = require('tiny-lr');
@creationix
creationix / convert.js
Last active March 31, 2020 07:15
Convert a hex string (base-16) to a base-65536 (16-bit) string.
function hexToBase65536(hex) {
var result = "";
for (var i = hex.length ; i > 0; i -= 4) {
result += String.fromCharCode(parseInt(hex.substring(i - 4, i), 16));
}
return result;
}
@matthewmueller
matthewmueller / nw.js
Last active November 27, 2015 20:49
string alignment using the Needleman-Wunsch algorithm
const UP = 1;
const LEFT = 2;
const UL = 4;
function nw(s1, s2, op) {
op = op || {};
const G = op.G || 2;
const P = op.P || 1;
const M = op.M || -1;
var mat = {};
/**
* POST to create a new user.
*/
exports.create = function *(){
var body = yield parse(this);
// password
var pass = body.password;
assert(pass, 400, 'password is required');

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.