Skip to content

Instantly share code, notes, and snippets.

View kdwinter's full-sized avatar

Kenneth De Winter kdwinter

  • Ghent, Belgium
  • 07:16 (UTC +02:00)
View GitHub Profile
require 'rubygems'
require 'json'
require 'net/http'
def google(query, service='web', optargs='')
url = "http://ajax.googleapis.com/ajax/services/search/#{service}?v=1.0&q=#{URI.encode(query)}&rsz=large" + optargs
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
result = JSON.parse(data)['responseData']['results']
require 'rubygems'
require 'json'
require 'net/http'
def google(query, service='web', optargs='')
url = "http://ajax.googleapis.com/ajax/services/search/#{service}?v=1.0&q=#{URI.encode(query)}&rsz=large" + optargs
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
result = JSON.parse(data)
require 'rubygems'
require 'scrubyt'
require 'cgi'
starttime = Time.now
google_data = Scrubyt::Extractor.define do
query = ['multi monitor']
fetch 'http://awesome.naquadah.org/wiki/index.php?search=%s&go=Go' % query.join('+')
link_title "//ul[@class='mw-search-results']//a[@title]", :write_text => true do
#!/usr/bin/env ruby
class ProcFile
include Enumerable
def self.parse_file(file)
file = File.expand_path(file, "/proc")
new(File.new(file))
end
#!/usr/bin/env ruby
require 'logger'
require File.dirname(__FILE__) + '/rules'
alias :L :lambda
class ParseError < RuntimeError; end
module Parser
extend self
@rule = ''
threads = []
foo.each do |bar|
threads << Thread.new(bar) do |bar|
# insert operations here
end
end
threads.each { |t| t.join }
#!/usr/bin/env ruby
@paclist = `pacman -Qqe | grep -v "$(pacman -Qmp)"`
@listfile = ENV['HOME'] + '/abs/paclist.txt'
f = File.new(@listfile, 'w+')
f.write(@paclist)
f.close
# Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#!/usr/bin/ruby -wW2
# AUR search program. Uses the RPC/JSON interface to query the db. Requires
# rubygems and the JSON gem. And a whole lot more now!
# {{{ Require statements
%w{optparse pp cgi open-uri pathname ftools zlib rubygems json facets/version facets/minitar facets/ansicode}.each do |lib|
require lib
end
local tag_properties =
{
{ name = '1', layout = layouts[1], mwfact = 0.618033988769 },
{ name = '2', layout = layouts[3] },
{ name = '3', layout = layouts[1] },
{ name = '4', layout = layouts[1] },
{ name = '5', layout = layouts[1] },
{ name = '6', layout = layouts[1] },
{ name = '7', layout = layouts[1] },
{ name = '8', layout = layouts[1] },