Skip to content

Instantly share code, notes, and snippets.

View m040601's full-sized avatar

somename123 m040601

View GitHub Profile
@m040601
m040601 / mygist-1
Created October 14, 2010 09:06
lastfm mp3 down - wget and awk
#!/bin/bash
url='http://www.last.fm/music/+free-music-downloads?page=1'
num=$(wget -O- -q "$url" | awk -vRS="</[aA]>" '/class=\"lastpage\"/ {gsub(/.*>/,""); print}')
for((i=1;i<=$num;i++))
do
url="http://www.last.fm/music/+free-music-downloads?page=$i"
wget -O- -q $url | awk 'BEGIN{ RS="</[aA]>" }
/http:\/\/freedownloads.last/{
gsub(/.*href=[\047\042]/,"")
@m040601
m040601 / mechanize gists - 1)ggrks
Created October 14, 2010 10:08 — forked from rummelonp/ggrks
goog link/tit - only mech needed, shebang
#!/usr/bin/ruby -Ku
# only needs mech/noko retrievs goog link/titf
args = ARGV
if args.length == 0
puts "Usage: ggrks [-n num] [-p page] [query]"
puts "Try `gglks --help' for more information."
exit
end
@m040601
m040601 / hatena-land-post.rb
Created October 14, 2010 10:13 — forked from shokai/hatena-land-post.rb
hatena posts - noko/mech/openuri
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'nokogiri'
require 'kconv'
require 'open-uri'
USER = 'username'
PASS = 'passpass'
@m040601
m040601 / README
Created October 14, 2010 10:19 — forked from biangle/README
post file - mecha/yam/ENV
= A submission script for AizuOnlineJudge(AOJ; http://rose.u-aizu.ac.jp/onlinejudge/index.jsp ).
== Requirement
- Ruby1.9.x
- Mechanize (execute '$ gem install mechanize' if you don't have it)
== How to use.
1. Edit submit.auth.yaml with your AOJ id and Password.
2. Place your answer program XXXX.c in the same directory (XXXX is the problem id).
3. $ ruby submit.rb XXXX
@m040601
m040601 / fetchgists.rb
Created October 14, 2010 10:38 — forked from grantmichaels/fetchgists.rb
fetch gists/from user - very simple mechanize with arg
require "rubygems"
require "mechanize"
@mechanize = WWW::Mechanize.new{|agent| agent.user_agent_alias = "Linux Mozilla"}
STDOUT.sync = false
def fetch_data(url)
STDERR.puts "fetching #{url}"
urls = @mechanize.get(url).search("a").map{|x| x['href']};
@m040601
m040601 / yet%20another%20third%20file
Created October 15, 2010 06:26
found on the context wiki - scrape (hpricot,openurl etc) , convert (own rb funcs)
##############3
#open and scrap
######################################
#scan_page.rb = Retrieves the html page of interest from the server,
# navigates to links within the main page and construct a
# context document
#!/usr/bin/ruby
@m040601
m040601 / anki_lookup_sentences_wget_sed_jedict_server.sh
Created October 17, 2010 10:01
description of this gist - one or more file containing scraps (anki_lookup_sentences_wget_sed_jedict_server etc...)
#!/bin/sh
# ./lookup-sentences 1 < ./deck-exported.txt > ./deck-toimport.txt
# $Revision: 1.3 $ $Date: 2010/02/23 02:36:09 $
while read line
do
sentence=`echo "$line" | awk -F'\t' '{print $'"$1"'}' | sed 's/<[^<]*>//g'`
echo -ne "$line\t"
wget -O - "http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?9MIH$sentence" | \
\documentclass[21pt]{scrartcl}
\usepackage[]{forloop}
\usepackage[]{blindtext}
\setlength{\parindent}{0pt}
\usepackage[]{lmodern}
\newcounter{ct}
\usepackage{pgfpages}
\edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
\edef\pgfpageoptionwidth{\the\paperheight}
@m040601
m040601 / csv_2_yaml.rb
Created October 29, 2010 10:40
desc this gist - snippets yaml, csv, plain conversion and marshalling
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
# only works with ruby 1.8 ???
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
# "2","image/tiff","image/tiff","|tiff|tif|","/images/icon/blank.png"
#
@m040601
m040601 / delicious_hpricot_openuri.rb
Created October 29, 2010 14:59
fetch delicious data with Hpricot and OpenURI
class Delicious
class << self
def tag(username, name, count = 15)
links = []
url = "http://feeds.delicious.com/v2/rss/#{username}/#{name}?count=#{count}"
feed = Hpricot(open(url))
feed.search("item").each do |i|
item = OpenStruct.new
item.link = i.at('link').next.to_s