Voir les contributions

Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.

Sujets - CJ Jackson
1
Off-topic / Iran Nuclear Plants Hit By Virus Playing AC/DC
« le 29 Juillet 2012 à 11:10 »
http://www.businessweek.com/news/2012-07-25/iran-nuclear-plants-hit-by-virus-playing-ac-dc-report

Latest virus aimed at shutting down Iran's nuke plants not only shuts them down, but plays AC/DC "Thunderstruck" at full volume all night long :lol:
2
Off-topic / 8-bit Google Maps
« le 1er Avril 2012 à 02:15 »
4
Off-topic / Pilko's Pump Pants
« le 13 Novembre 2011 à 01:55 »
5
Off-topic / Modular Autoembed Script in Python
« le 18 Octobre 2011 à 15:25 »
embedder/__init__.py
Code: [Sélectionner]
import re
from importlib import import_module
from _lib.shortcode import shortcode
from ._list import __embedlist


def execute(user, url):
    msg = ''
    for list in __embedlist:
        match = re.match(list['re'], url, flags=re.I)
        if match:
            try:
                module = import_module('_lib.embedder.' + list['module'])
                return module.execute(user, match, 640, 376)
            except:
                msg = "\nModule Failed to load"
    url = "[url]" + url + "[/url]" + msg
    code = shortcode(user=user, filter=['url'])
    url = code.execute(url)
    return url

embedder/_list.py
Code: [Sélectionner]
__embedlist = [
    {
        're': '^http(s?)://([a-z]*).youtube.com/(watch|index)\?(.*)v=(?P<youtubeid>[a-zA-Z0-9]+)',
        'module': 'youtube'
    },
    {
        're': '^http(s?)://([a-z]*).youtube.com/v/(?P<youtubeid>[a-zA-Z0-9]+)',
        'module': 'youtube'
    },
    {
        're': '^http(s?)://youtu.be/(?P<youtubeid>[a-zA-Z0-9]+)',
        'module': 'youtube'
    },
    {
        're': '^http(s?)://www.metacafe.com/watch/(?P<metacafeid>\d+)/(?P<metacafename>[a-zA-Z0-9_-]+)(/?)',
        'module': 'metacafe'
    },
    {
        're': '^http(s?)://www.dailymotion.com/(.*)video/(?P<dailymotionid>[^_]+)',
        'module': 'dailymotion'
    },
    {
        're': '^http(s?)://www.gametrailers.com/video/(?P<gametrailersname>[a-zA-Z-]+)/(?P<gametrailersid>\d+)(/?)',
        'module': 'gametrailers'
    },
    {
        're': '^http(s?)://([www.]?)collegehumor.com/video/(?P<collegehumorid>\d+)(/?)',
        'module': 'collegehumor'
    },
    {
        're': '^http(s?)://www.funnyordie.com/videos/(?P<funnyordieid>[a-zA-Z0-9]+)(/?)',
        'module': 'funnyordie'
    },
    {
        're': '^http(s?)://revision3.com/(?P<r3group>[a-zA-Z0-9]+)/(?P<r3title>[a-zA-Z0-9]+)(/?)',
        'module': 'revision3'
    },
    {
        're': '^http(s?)://www.break.com/([a-zA-Z-]+)/(?P<breakname>[a-zA-Z-]+)-(?P<breakid>\d+)(/?)',
        'module': 'break'
    },
]

I studied the links from (& only from) http://embed.ly/providers  :eheh:  Great thing about re in python is that it's allows named groups, much better than counting the groups.

embedder/youtube.py
Code: [Sélectionner]
from django.template import Context, loader


def execute(user, match, width, height):
    youtubeid = match.group('youtubeid')

    template = loader.get_template('embedder/youtube.html')
    context = Context({
        'youtubeid': youtubeid, 'width': width, 'height': height
    })

    return template.render(context)

All of the modules were very easy to code because the urls had id's in them, except revision3 that required HTML DOM, just to get the id from meta tag.  Also I had to use database caching for revision3 because HTML DOM is damn slow.  It's took about two hours to get revision3 to work.

embedder/revision3.py
Code: [Sélectionner]
from django.template import Context, loader
import hashlib
import json
from embed_cache.models import embed_cache
import urllib2
import html5lib
from html5lib import treebuilders
import re


def execute(user, match, width, height):
    r3group = match.group('r3group')
    r3title = match.group('r3title')
    prehash = "revision3/" + r3group + "/" + r3title
    hash = hashlib.new('ripemd160')
    hash.update(prehash)
    hash = hash.hexdigest()

    try:
        object = embed_cache.objects.get(hash=hash)
        data = json.loads(object.data)
        r3id = data['r3id']
        del data
        del object
    except:
        try:
            parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder("dom"))
            dom = parser.parse(urllib2.urlopen(match.group(0)).read())
            for node in dom.getElementsByTagName('meta'):
                if node.getAttribute('property') == 'og:video':
                    content = node.getAttribute('content')
                    break
            pattern = 'http://revision3.com/player-v(?P<theid>[0-9]+)'
            match2 = re.match(pattern, content, flags=re.I)
            if match2:
                r3id = match2.group('theid')
                data = {'r3id': r3id}
                data = json.dumps(data)
                object = embed_cache.objects.create(hash=hash, data=data)
                del object
                del data
            else:
                return ""
        except:
            return ""

    template = loader.get_template('embedder/revision3.html')
    context = Context({
        'r3id': r3id, 'width': width, 'height': height
    })

    return template.render(context)

As you can see each module has it's own template (or html code).  I can't believe how most of it was ridiculously easy in Python.
6
Off-topic / WIFI Kill
« le 10 Octobre 2011 à 22:40 »
http://forum.xda-developers.com/showthread.php?t=1282900

I haven't tested this, but others have said its works. Got to love the open source nature of Android! :niark:
7
Off-topic / Simple & Effective URL Routing System
« le 20 Juin 2011 à 00:52 »
http://cj-jackson.com/2011/06/19/simple-effective-url-routing-system/

What do you guys think about the script?  :)
8
Off-topic / Windows XP End Of Support Countdown Gadget
« le 13 Mai 2011 à 19:45 »
Windows XP End Of Support Countdown Gadget,

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=53a27766-0168-4617-b44e-74b2886cec6d&pf=true

Oh, you might want to have a look at the system requirements! What can I say it's a Gadget!  :lol:
9
Off-topic / Spambots
« le 11 Avril 2011 à 17:21 »
Unfortunately spambots have got through reCAPTCHA, fortunately, the email address they use are so random, none of them have Gravatar. Those spambots programmers thought they outsmarted me, but they failed because they overlooked Gravatar (which is probably blocked by the great firewall of China)  :D

What your opinion?