Agadir (2)
   Computers (13)
   Gadgets (4)
   General (36)
   Howtos (4)
   Japanese (5)
   Linux (12)
   Movies (4)
   Old Blog (90)
   Programming (5)
   Software (6)
   Web & Design (7)

 Subscribe to Posts
 Subscribe to Comments

Download Stage6 videos using Python

65 views
Old Blog, Programming

Here is a quick and dirty python script to download Stage6 videos.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- Python -*-
import urllib, sgmllib, sys, string, os, time, re
 
class MyParser(sgmllib.SGMLParser):
   def parse(self, s):
       self.feed(s)
       self.close()
 
   def __init__(self, verbose=0):
       sgmllib.SGMLParser.__init__(self, verbose)
       self.hyperlinks = []
       self.inside_a_element = 0
 
   def start_input(self, attributes):
       found = False
       for name, value in attributes:
           if name == "onclick":
               found = True
               continue
           if found == True and name == "value":
               self.hyperlinks.append(value)
               self.inside_a_element = 1
 
   def end_input(self):
       self.inside_a_element = 0
 
   def get_data(self):
       return self.hyperlinks[0]
 
class AppURLopener(urllib.FancyURLopener):
   def __init__(self, *args):
       self.version = "Lynx"
       urllib.FancyURLopener.__init__(self, *args)
 
urllib._urlopener = AppURLopener()
 
try:
   url = sys.argv[1]
except IndexError:
   print "Usage:", sys.argv[0], "URL"
   sys.exit(1)
 
f = urllib.urlopen(url)
s = f.read()
myparser = MyParser()
myparser.parse(s)
data = myparser.get_data()
p = re.compile(".*(http://video.stage6.com/.*/.divx).*")
 
try:
   m = p.match(data)
   video_url = m.group(1)
except AttributeError:
   print "Video not found >_<"
   sys.exit(1)
 
def hook(*a):
   print '%s: %s' % (fn, a)
 
fn = os.path.basename(url) + ".avi"
print url, "->", fn
urllib.urlretrieve(video_url, fn, hook)

To use it:

$ ./stage6.py http://www.stage6.com/user/Rudimc/video/1907059/Iaido---Batto---Takeda-Ryu-Tameshigiri
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
4 Comments »

Google Android’s Emulator

71 views
Old Blog, Programming
  • Get the Android SDK
  • Unzip it
  • Launch the emulator with: ./android_sdk_linux_m3-rc20a/tools/emulator
  • Enjoy !

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
No Comments »

Flymake in Emacs 22

77 views
Old Blog, Programming


1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
1 Comment »

Java Grep

77 views
Old Blog, Programming
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.FileReader;
import java.io.FileNotFoundException;
 
public class Grep {
  public static void error(String msg) {
    System.err.println(msg);
    System.exit(1);
  } 
 
  public static void main(String[] args) {
    BufferedReader input;
    Matcher matcher;
    Pattern pattern;
    String line;
 
    switch (args.length) {
    case 1:
      input =  new BufferedReader(new InputStreamReader(System.in));
      break;
    case 2:
      try {
        input =  new BufferedReader(new FileReader(args[1]));
      } catch (FileNotFoundException e) {
        input = null; // silly java
        error("Error: " + args[1] + ": " + e.getMessage());
      }
      break;
    default:
      input = null; // silly java
      error("Usage: java Grep PATTERN [file]");
    }
 
    pattern = Pattern.compile(".*" + args[0] + ".*");
 
    try {
      while ((line = input.readLine()) != null) {
        matcher = pattern.matcher(line);
        if (matcher.matches()) {
          System.out.println(line);
        }
      }
    } catch (IOException e) {
      error("Error parsing input: " + e.getMessage());
    }
  }
}
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
No Comments »

Insert a comment with username and date in emacs

81 views
Old Blog, Programming

Add the following to your .emacs file:

1
2
3
4
5
6
7
;; insert a comment w/ name and date
(defun insert-comment ()
  (interactive)
  (comment-dwim "")
  (insert-string "!!! ")
  (insert-string (getenv "USER"))
  (insert (format-time-string " %Y%m%d: ")))

To use it, just type “M-x insert-comment“.
If it’s too much work for you, you can add a shortcut for it, again, in your .emacs, after the insert-comment definition, add the following:

(global-set-key "\C-xv" 'insert-comment)

Now you can insert your comment with just “C-x v

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
No Comments »
Page 1 of 11
WP Theme GlossyBlue Modified by Fahdos