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
/* | |
* 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'), |
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
/* | |
* 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'); |
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
// 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(); |
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') | |
, http = require('http') | |
, path = require('path') | |
, cheerio = require('cheerio'); | |
var archive = 'http://apod.nasa.gov/apod/archivepix.html' | |
, base = path.dirname(archive) + '/' | |
, target = 'archive/english/'; |
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 request = require('request'), | |
cheerio = require('cheerio'), | |
url= 'http://www.paginegialle.it/cinema-programmazione/Roma%20(RM)', | |
ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2'; | |
var parsePage = function(error, response, body) { | |
if (error || response.statusCode != 200) { | |
console.log(error); | |
} |
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
class Beanutils{ | |
//merge two bean by discovering differences | |
private <M> void merge(M target, M destination) throws Exception { | |
BeanInfo beanInfo = Introspector.getBeanInfo(target.getClass()); | |
// Iterate over all the attributes | |
for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) { | |
// Only copy writable attributes | |
if (descriptor.getWriteMethod() != null) { |
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
cheerio = require('cheerio') | |
Shred = require('shred') | |
shred = new Shred() | |
http = require('http') | |
URL = require('url') | |
server = http.createServer (request, response) -> | |
url = URL.parse(request.url, true) | |
urlToDiscover = url.query['url'] | |
startDiscovery urlToDiscover, (theImageURL) -> |
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 up the http server | |
console.log("Starting on port #{options.port}") | |
server.listen(options.port) | |
# Start up dnode and expose our remote secure API to the user. This API has built-in token based security so we will be ok if the | |
# web-socket is over https | |
remote = | |
db: dbSecure | |
dnode(remote).listen(server) |
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
# Now create a secure API to this | |
# library that requires authentication | |
# Users can only access these collections | |
collectionWhiteList = ["records", "sources", "searchers"] | |
# These collections don't need any authentication at all for | |
findWithNoAuthentication = ["sources"] | |
secureTemplate = (user, collectionName, cb, doneCB) -> | |
if not user? or not user.accessToken? |
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
// Map from CRUD to HTTP for our default `Backbone.sync` implementation. | |
var methodMap = { | |
'create': 'POST', | |
'update': 'PUT', | |
'delete': 'DELETE', | |
'read' : 'GET' | |
}; |