Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env zsh
function resolve_symlink() {
local result=`readlink $1`
[ -z $result ] && echo $1 || $0 $result
}
function expand_path() {
cd -qP $1
pwd
@cyx
cyx / gist:219813
Created October 27, 2009 18:46 — forked from tpitale/gist:162954
#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/mongodb/bin
DAEMON=/opt/mongodb/bin/mongod
PIDFILE=/var/log/mongodb/mongodb.pid
LOGFILE=/var/log/mongodb/mongod.log
NAME=mongodb
DESC=mongodb
test -x $DAEMON || exit 0
class HomeController < ApplicationController
def index
if (@target_url = params["url"]) && !@target_url.blank?
@target_url = @target_url =~ %r{^http://} ? @target_url : "http://#{@target_url}"
filter_if_length_less_than = 40
@page = open(@target_url).read
doc = Nokogiri::HTML.parse(@page)
content = doc.search("h1,p,.comment")
content = content.reject { |node| node.text.gsub(/\W/,'').strip.length < filter_if_length_less_than }
content = content.reject { |node| (%w[noscript li] & node.ancestors.map { |e| e.name }).length > 0 }