Skip to content

Instantly share code, notes, and snippets.

View daithiw44's full-sized avatar

Dave Winders daithiw44

  • Dublin, Ireland
View GitHub Profile
@daithiw44
daithiw44 / server.js
Created April 26, 2017 09:01
Proxy Server for UI Design Team
'use strict';
let httpServer
, http = require('http')
, path = require('path')
, url = require('url')
, fs = require('fs');
let port = process.env.www_port || 3000;
let mimeTypes = {
@daithiw44
daithiw44 / server.js
Created April 6, 2013 20:12
MongoDB geoNear with Irish cities and mongoDB wrapper module MAL
//https://github.com/daithiw44/MAL/blob/master/examples/geo/server.js
//geoNaear
var MAL = require('../../lib/mal').MAL;
// Easy Way: Fire up a local instance of MongoDB
// settings object (username and password are not compulsory)
var dbsettings = {
host: 'localhost',
port: 27017,
db: 'malexamples',
options: {auto_reconnect: true}
@daithiw44
daithiw44 / server.js
Created September 4, 2012 22:33
Twitter GET users/profile_image/:screen_name, Nodejs get latest user profile_image output as a base64 encoded data URI, avoid the 302 redirect of the call with request module.
/*
* Access the profile image (Twitter GET users/profile_image/:screen_name) for a user with the indicated screen_name.
* Currently this resource does not return JSON (or XML), but instead returns a 302 redirect to the actual image resource.
* Use requests request.head with option followRedirect set to false to get the image file name from the json in the header response.
* Using the image file URL get the profile image and convert to base64 encoding to use as in this example as data URI (which could be saved to a DB/storage etc for later use etc).
* example call : http://127.0.0.1:4444/?screen_name=daithi44
*/
var http = require('http'),
request = require('request'),
@daithiw44
daithiw44 / server.js
Created September 1, 2012 20:18
GET users/profile_image/:screen_name, Nodejs get latest user profile_image and avoid the 302 redirect with request.
/*
* Access the profile image in various sizes for the user with the indicated screen_name.
* Currently this resource does not return JSON (or XML), but instead returns a 302 redirect to the actual image resource.
* Use requests request.head with option followRedirect set to false to get the image file name from the json in the header response.
* example : http://127.0.0.1:4400/?screen_name=daithi44
*/
var http = require('http')
, request = require('request')
, url = require('url');
@daithiw44
daithiw44 / gist:3032376
Created July 2, 2012 09:50
Nodejs Anagram Website Scraper with express and Domains, update to previous example gist: 1335009
// Updated example to utilize 'basic' Domains with express.
// Website Scraper that scrapes off a site (without permission I may add)
// had seen some screen scraping examples using jQuery this example is jQuery-less.
var express = require('express'),
request = require('request'),
jsdom = require('jsdom'),
builder = require('xmlbuilder').create(),
sys = require('util'),
createDomain = require('domain').create,
app = express.createServer();
@daithiw44
daithiw44 / NodeJS web scraper for Anagrams
Created November 2, 2011 21:40
NodeJS Web Scraper Anagram Example, written as a test some time ago with early Node Version, seems to still work.
//Web Scraper that scrapes a web page (without permission I may add).
//Simple test using node is all this is, no error handling etc.
//Returns JSON OR XML
//Format : localhost:'PORT'/scrape/'WORD'/'FORMAT'
//Example CURL
//JSON - curl -X GET http://localhost:3000/scrape/fundamental/json
//XML - curl -X GET http://localhost:3000/scrape/fundamental/xml
var express = require('express'),
request = require('request'),