Skip to content

Instantly share code, notes, and snippets.

@ericchen
ericchen / NokogiriXPathNamespaces
Created April 16, 2012 06:59 — forked from Ameeda/NokogiriXPathNamespaces
Selecting elements in some namespace using Nokogiri with XPath
2 ways to extract elements from within XML namespaces using Nokogiri
When trying to select elemenets in the default namespace, e.g. "xmlns= http://www.w3.org/2005/Atom", try the following two ways. Note the xmlns=" attribute on entry element:
Original xml:
Nokogiri::XML(@xml_string).xpath("//author/name").each do |node|
puts node
end
1. Define a namespace context for your XPath expression and point your XPath steps to match elements in that namespace. Define a namespace-to-prefix mapping and use this prefix (a) in the XPath expression.
@ericchen
ericchen / tls-cert-generator.rb
Created July 9, 2012 03:23 — forked from ibc/tls-cert-generator.rb
Autosigned TLS Certificate Generator (including SubjectAltName fields for "URI:sip" and "DNS")
#!/usr/bin/ruby
# Runs as follows:
#
# ~$ ruby tls-cert-generator.rb
require "openssl"
require "socket"
server {
listen 8080;
server_name example.dev www.example.dev;
location / {
root /Users/Cobby/Sites/Example;
if ($host = 'www.example.dev' ) {
rewrite ^/(.*)$ http://example.dev:8080/$1 permanent;
}

How to install PhantomJS on Ubuntu

Version: 1.9.7

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
# -*- coding: utf-8 -*-
from scrapy.item import Item, Field
class RamenStyle(Item):
shop_id = Field()
style = Field()
soup = Field()
class RamenReview(Item):
review_id = Field()
@ericchen
ericchen / pinterest_spammer.rb
Created May 28, 2016 09:37 — forked from v-pukman/pinterest_spammer.rb
Post to Pinterest using Ruby and Mechanize
# Usage example:
#
# s = PinterestSpammer.new
# s.sign_in 'your_account_email', 'your_account_password'
# s.get_boards # get boards list, that contains board_id (for example - 455708124733779520)
# s.create_pin(455708124733779520, 'https://xyz.xyz/', 'http://rubyonrails.org/images/rails.png', 'Spammer!')
#
#
require 'mechanize'
class PinterestSpammer