Skip to content

Instantly share code, notes, and snippets.

View coderaiser's full-sized avatar

coderaiser coderaiser

View GitHub Profile
@lovasoa
lovasoa / node-walk.es6
Last active March 11, 2025 15:15
Walk through a directory recursively in node.js.
// ES6 version using asynchronous iterators, compatible with node v10.0+
const fs = require("fs");
const path = require("path");
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) yield* walk(entry);
else if (d.isFile()) yield entry;
@serverwentdown
serverwentdown / server.js
Last active January 29, 2019 20:18 — forked from mixonic/server.js
// Bug fixes for current versions.
//
// This server will start a bash shell and expose it
// over socket.io to a browser. See ./term.html for the
// client side.
//
// You should probably:
//
// npm install socket.io
@branneman
branneman / better-nodejs-require-paths.md
Last active April 11, 2025 10:39
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@gmccreight
gmccreight / master.vim
Last active November 21, 2024 14:36
A script that gives you a playground for mastering vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@jmervine
jmervine / ssl_test.md
Created October 20, 2013 19:54
SSL Test Node.js/SPDY/Express.js vs. Nginx/SPDY vs. Nginx/SPDY -> Node.js/Express.js

HTTPS Test using SPDY

Node.js+node-spdy vs Nginx+SPDY

This is by no means a comprehensive test. It was done a laptop with a dump of Google's homepage as the content. Performance data was generated using 10000 connections to localhost using `httperf'. If you see any glaring holes though, please point them out. Cheers!

Findings summary:

  1. Node.js / node-spdy / Express.js: avg 139.1
  2. Nginx / SPDY -> Node.js / Express.js: avg 150.1
#!/bin/sh
git clone [email protected]:cloudcmd/io-ru
cd io-ru
git submodule init
git submodule update
cd _layouts && git checkout master
cd ../..
@Twipped
Twipped / gist:6903159
Last active August 13, 2017 16:23
SOA with Node.js Middle Layer

@ChiperSoft could you explain some of it in an email to me?

I suspect you may already have a general idea about it, since you've been arguing in favor of micro-services for some time. The basic idea is that you break your site down into lots of small applications.

Say you have a portal that is composed of multiple sections: front page, news, video, sports, discussion board, weather, video, etc. Each of those different sections would have their own backend content services driving them, independent APIs integrating with their own databases. You'd also have some form of centralized login & identity management service, some form of access control, and maybe a service for managing white-labeling if your portal is licensed by other companies.

Each of these sections on the site is a nodejs application by itself, responsible for handling only its own requests. This may be built using node's built in http server routines and a lot of in-house code, but most people are using some derivative of [Sencha Connect

@tmcw
tmcw / d3.md
Last active December 6, 2022 14:04
Accompaniment to dcjq

This is a more wordy, narrative accompaniment to my pretty bare presentation about d3 that I gave to the jQuery DC Meetup.

What is d3?

  • Not a chart library (though you can make charts with it)
  • Not a map library (though you can make maps with it)

Which is to say, d3 can be used for building things, but the 'atomic parts' are lower-level than bar graphs or projections or so on. This is a powerful fact. It also means that d3 is a good basis for simple interfaces, like Vega.js, that make its power accessible in other ways.

  • Not a compatibility layer (it doesn't work with bad browsers)
@coderaiser
coderaiser / help.sh
Last active December 16, 2015 04:29
linux help file
#torrent
sudo apt-get install deluged deluge-console deluge-web #password deluge
#aria2c http://aria2.sourceforge.net/
#создать архив c прогрессбаром и записать его в файл
tar -c cloud9 |gzip --stdout | pv > cloud9.tar.gz
#ncurses problem debian
sudo apt-get install libncurses5-dev libncursesw5-dev
---
layout: nil
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in site.posts %}
<url>
<loc>http://tedhagos.com/misc/{{ post.url }}</loc>
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
<changefreq>daily</changefreq>