Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
mrjjwright / gist:3240020
Created August 2, 2012 19:41
Extract largest image thumbnail from url using node and cheerio
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) ->
@youtalk
youtalk / redirect.http2https.js
Created July 31, 2012 12:42
Automatic redirection from HTTP to HTTPS with Node.js
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.configure('production', function () {
app.use (function (req, res, next) {
var schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (schema === 'https') {
@JoshuaEstes
JoshuaEstes / 000-Cheat-Sheets.md
Last active April 23, 2025 10:31
Developer Cheat Sheets for bash, git, gpg, irssi, mutt, tmux, and vim. See my dotfiles repository for extra info.
@larryfox
larryfox / LICENSE.txt
Last active February 22, 2022 21:27
Determine if an elements background color is light or dark!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2015 Larry Fox <http://larryfox.us>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@eugeniy
eugeniy / www-redirect.coffee
Created September 5, 2011 22:38
Redirect domains starting with www to non-www ones in node.js, express and coffeescript
express = require 'express'
app = module.exports = express.createServer()
# redirect to a non-www domain
app.get '/*', (req, res, next) ->
if req.headers.host.match(/^www\./)?
res.redirect 'http://' + req.headers.host[4..] + req.url, 301
else next()
@jeffrafter
jeffrafter / server.js
Created August 28, 2010 21:37
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {