This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http') | |
| , httpProxy = require('http-proxy') | |
| , ns = require('node-static') | |
| , file = new(ns.Server)('./public') | |
| , url = require('url') | |
| , querystring = require('querystring') | |
| ; | |
| // | |
| // Create a proxy server with custom application logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var obj = { "tricky": 'these "tick∫."' }; | |
| var str = ''; | |
| // | |
| // npm install json-streamify | |
| // | |
| require('json-streamify').streamify(obj, function(data) { str += data; }); | |
| console.log('%s', str); | |
| console.log('%s', JSON.stringify(obj)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- start auto-generated posts --> | |
| <?php while (have_posts()) : if (has_tag('featured')) { the_post(); } ?> <!-- <== BROKEN HERE --> | |
| <div class="content" style="background: url(<?php bloginfo('template_url'); ?>/images/dummy-images/coffee.jpg);"> | |
| <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> | |
| <div class="entry"> | |
| <?php the_content(); ?> | |
| </div> | |
| </div> | |
| <?php endwhile; ?> | |
| <!-- end auto-generated posts --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var str = '63737472696b65'; | |
| var num16 = parseInt(str, 16); | |
| var str2 = 'f'; | |
| console.log(parseInt(str2, 16)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Routes | |
| app.get('/', userIsAuthenticated, function(req, res){ | |
| Doc.find( { loc : { $near : [50.62, -20.32], $maxDistance : 50 } } , function (err, docs) { | |
| res.render('index_authenticated.jade', { | |
| locals: { | |
| title: 'Welcome back to Gociety', | |
| status: 'logged in', | |
| currentUser: req.currentUser, | |
| user: req.currentUser, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var _ = require('underscore')._; | |
| var data = {"1":0.000007223714765952328,"2":0.0000039749105916010536,"3":0.0000032965765671970454,"7":0.0000020878318258914622,"8":0.000002736989620496371,"9":0.000003076694134649906,"10":0.0000013715180458375907,"12":0.000001159906569939701,"15":6.457211832654003e-7,"18":6.457211832654003e-7,"19":0.0000026097897823643283,"20":0.0000026097897823643266,"21":9.490144663143008e-7,"23":3.4414810316892216e-7,"24":8.821824616442793e-7,"26":0.0000024947065913923583,"38":0.000004404915773841593,"40":0.0000023785425864586267,"41":0.0000018918312871343038,"42":0.0000014913084470653296,"44":0.0000023665042941778225,"51":9.942056313768864e-7,"57":0.0000010616094029956584,"58":0.0000024056413215874137,"100":4.971028156884432e-7,"230":0.0000015658738694185964,"1998":0.000026218026718821232,"the":0.0007400023061007896,"Honourable":0.00022929140436720472,"Gildas":0.00001957342336773246,"L":0.00001957342336773246,".":0.0006657129490331946,"Molgat":0.00001957342336773246,",":0.0003656978308864 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var fs = require('fs') | |
| , path = './DELETEME.txt' | |
| , stream = fs.createWriteStream(path, { flags: 'w+', encoding: 'utf8' }) | |
| , data = { "I":0.18181818181818182,"bought":0.18181818181818182 } | |
| ; | |
| function cb(err) { | |
| if (err) console.log(err); | |
| console.log('cool, all done.'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findBeer(words) { | |
| //...code... | |
| getResults(word, function(err, result){ | |
| // now you can access things! | |
| console.log(err, result); | |
| }); | |
| } | |
| function getResults(word, callback) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Scraping Made Easy with jQuery and SelectorGadget | |
| // (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga) | |
| // by David Trejo | |
| // | |
| // Install node.js and npm: | |
| // http://joyeur.com/2010/12/10/installing-node-and-npm/ | |
| // Then run | |
| // npm install jsdom jquery http-agent | |
| // node numresults.js | |
| // |