Wednesday, February 1, 2012

here is an example blog post...


// Esta es para llamado de datos remotos via xmlHttpRequest

function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
try {
// Mozilla / Safari
this._xh = new XMLHttpRequest();
} catch (e) {
// Explorer
var _ieModelos = new Array(
'MSXML2.XMLHTTP.5.0',
'MSXML2.XMLHTTP.4.0',
'MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP'
);
var success = false;
for (var i=0;i < _ieModelos.length && !success; i++) {
try {
this._xh = new ActiveXObject(_ieModelos[i]);
success = true;
} catch (e) {
// Implementar manejo de excepciones
}
}
if ( !success ) {
// Implementar manejo de excepciones, mientras alerta.
return false;
}
return true;
}
}

datosServidor.prototype.ocupado = function() {
estadoActual = this._xh.readyState;
return (estadoActual && (estadoActual < 4));
}

datosServidor.prototype.procesa = function() {
if (this._xh.readyState == 4 && this._xh.status == 200) {
this.procesado = true;
}
}

datosServidor.prototype.enviar = function(urlget,datos) {
if (!this._xh) {
this.iniciar();
}
if (!this.ocupado()) {
this._xh.open("GET",urlget,false);
this._xh.send(datos);
if (this._xh.readyState == 4 && this._xh.status == 200) {
return this._xh.responseText;
}

}
return false;
}


// Este es un acceso rapido, le paso la url y el div a cambiar
function _gr(reqseccion,divcont) {
remotos = new datosServidor;
nt = remotos.enviar(reqseccion,"");
document.getElementById(divcont).innerHTML = nt;
}



//Estas dos son para guardar

var urlBase = "update.php?";


function rateImg(rating,imgId) {
remotos = new datosServidor;
nt = remotos.enviar('update.php?rating='+rating+'&imgId='+imgId);
rating = rating * 25;
document.getElementById('current-rating').style.width = rating+'px';
}



















<div id="tweets">

<script type='text/javascript'>

$(function(){

$('#tweets').tweetable({username: 'bloggermint', time: true, limit: 5});

});

</script>

</div>





I hope this shit works....





<div id="tweets">
<script type='text/javascript'>
$(function(){
$('#tweets').tweetable({username: 'bloggermint', time: true, limit: 5});
});
</script>
</div>

Thats all for now
this is an example of embedded code

from flask import current_app
from flaskext.script import Manager, prompt_bool
from mare import create_app

from mare.extensions import SQLAlchemy
from mare.models import User, Video, Stats

app = create_app('mare')
manager = Manager(app)

db = SQLAlchemy()


@manager.command
def create_user(name, email, password, brokernum=None):
"""
Will create a user from supplied cli arguments.
Since 'create_user' knows to check for an existing user first
this will not create more than one of the same users.
"""

try:
user = User(name, email, password, brokernum)
db.session.add(user)

count = 0
for v in db.session.query(Video).all():
count += 1
s = Stats(user, v)
s.watched = 0
if count == 1:
s.status = 1
else:
s.status = 0
db.session.add(s)

db.session.commit()

except Exception, e:
print e




@manager.command
def create_db():
db.create_all()
#db.session.commit()





@manager.command
def drop_db():
if prompt_bool('Are you sure you want to destroy all your data?'):
db.drop_all()


@manager.command
def load_videos():
with open('mare/data/videos.dat', 'r') as f:
for line in f.readlines():
tup = line.strip().split("\t")
module = tup[0]
duration = int(tup[1])
title = tup[2]

v = Video()
v.module = module
v.duration = duration
v.title = title

db.session.add(v)
db.session.commit()



@manager.command
def full_test():
db.drop_all()
db.create_all()
load_videos()
stuart = User('Stuart Powers', 'test@test.com', 'test', brokernum=None)
db.session.add(stuart)
db.session.commit()

videos = db.session.query(Video).all()
for v in videos:
s=Stats(stuart,v)
db.session.add(s)
db.session.commit()

@manager.command
def run_stats():
for u in db.session.query(User).all():
ustats = u.get_stats()
lastwatched = filter(lambda x: x.status,ustats)
if lastwatched:
lastvid = sorted(lastwatched,key=lambda x: x.video.id)[-1]
print "%d\t%d\t%d\t%s" % (lastvid.video.id,lastvid.watched,lastvid.user.uid,lastvid.user.email)
else:
print "100\t100\t%d\t%s" % (u.uid,u.email)





@manager.shell
def make_shell_context():
return dict(
app=current_app,
db=db,
User=User,
Video=Video,
Stats=Stats
)

if __name__ == "__main__":
manager.run()

Wednesday, September 28, 2011

Jquery Changelog

## 0.2.6 (1 December 2010) Feature: - Updated to use jQuery 1.4.4 by default ## 0.2.5 (4 November 2010) Bugfix: - Download JQuery Rails UJS via HTTPS since Github is now HTTPS only ## 0.2.4 (16 October 2010) Features: - Updated to use the new jQuery 1.4.3 by default, with the IE .live() bug fixed - Always download the newest 1.x release of jQuery UI - Try to install unknown versions of jQuery, with fallback to the default - Print informative messages in the correct Generator style ## 0.2.3 (13 October 2010) Features: - Support Edge Rails 3.1 by depending on Rails ~>3.0 - Add Sam Ruby's assert_select_jquery test helper method - Use jquery.min only in production (and not in the test env) ## 0.2.2 (8 October 2010) Feature: - Depend on Rails >=3.0 && <4.0 for edge Rails compatibility ## 0.2.1 (2 October 2010) Bugfix: - Default to jQuery 1.4.1 as recommended by jQuery-ujs due to a bug in 1.4.2 (http://jsbin.com/uboxu3/7/) ## 0.2 (2 October 2010) Features: - Allow specifying which version of jQuery to install - Add generator tests (thanks, Louis T.) - Automatically use non-minified JS in development mode ## 0.1.3 (16 September 2010) Bugfix: - allow javascript :defaults tag to be overridden ## 0.1.2 (18 August 2010) Bugfix: - check for jQueryUI in the right place ## 0.1.1 (16 August 2010) Bugfix: - fix generator by resolving namespace conflict between Jquery::Rails and ::Rails

Posted via email from sente's posterous

testing

More Examples

  1. Get application ideas from /r/SomebodyMakeThis:

    r = reddit.Reddit sr = reddit.get_subreddit("somebodymakethis") # Adjust limit as desired ideas = sr.get_hot(limit=300) apps = filter(lambda x: "app" in x.title.lower(), ideas)

Posted via email from sente's posterous

some helper functions

def make_ascii(str,debug=False):
    s = ""
    for num,i in enumerate(str):
        try:
            i.encode("utf-8")
        except (UnicodeEncodeError, UnicodeDecodeError):
            if debug:
                import sys
                sys.stderr.write("error converting char %d\n" %num )
            continue
        else:
            s += i
    return s

def yield_tokens(line):
    for i, part in enumerate(re.split(r'\{\{(.*?)\}\}', line)):
        if i % 2:
            if part.startswith('!'):
                yield 'RAW', part[1:]
            else: yield 'CMD', part
        else: yield 'TXT', part

Posted via email from sente's posterous

Thursday, February 24, 2011

How To Safely Store A Password | codahale.com

Use bcrypt

Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt.

Why Not {MD5, SHA1, SHA256, SHA512, SHA-3, etc}?

These are all general purpose hash functions, designed to calculate a digest of huge amounts of data in as short a time as possible. This means that they are fantastic for ensuring the integrity of data and utterly rubbish for storing passwords.

A modern server can calculate the MD5 hash of about 330MB every second. If your users have passwords which are lowercase, alphanumeric, and 6 characters long, you can try every single possible password of that size in around 40 seconds.

Posted via email from sente's posterous

Thursday, February 3, 2011

China Bans Reincarnation Without Government Permission

MSNBC:

In one of history's more absurd acts of totalitarianism, China has banned Buddhist monks in Tibet from reincarnating without government permission. According to a statement issued by the State Administration for Religious Affairs, the law, which goes into effect next month and strictly stipulates the procedures by which one is to reincarnate, is "an important move to institutionalize management of reincarnation." But beyond the irony lies China's true motive: to cut off the influence of the Dalai Lama, Tibet's exiled spiritual and political leader, and to quell the region's Buddhist religious establishment more than 50 years after China invaded the small Himalayan country. By barring any Buddhist monk living outside China from seeking reincarnation, the law effectively gives Chinese authorities the power to choose the next Dalai Lama, whose soul, by tradition, is reborn as a new human to continue the work of relieving suffering.

At 72, the Dalai Lama, who has lived in India since 1959, is beginning to plan his succession, saying that he refuses to be reborn in Tibet so long as it's under Chinese control. Assuming he's able to master the feat of controlling his rebirth, as Dalai Lamas supposedly have for the last 600 years, the situation is shaping up in which there could be two Dalai Lamas: one picked by the Chinese government, the other by Buddhist monks. "It will be a very hot issue," says Paul Harrison, a Buddhism scholar at Stanford. "The Dalai Lama has been the prime symbol of unity and national identity in Tibet, and so it's quite likely the battle for his incarnation will be a lot more important than the others."

Read the whole story: MSNBC

Posted via email from sente's posterous

How Did God Get Started? » Arion » Boston University

THE USUAL SUSPECTS

One day in the Middle East about four thousand years ago, an elderly but still rather astonishingly spry gentleman took his son for a walk up a hill. The young man carried on his back some wood that his father had told him they would use at the top to make an altar, upon which they would then perform the ritual sacrifice of a burnt offering. Unbeknownst to the son, however, the father had another sort of sacrifice in mind altogether. Abraham, the father, had been commanded, by the God he worshipped as supreme above all others, to sacrifice the young man himself, his beloved and only legitimate son, Isaac.

...
via bu.edu

Posted via email from sente's posterous

This Week in God - The Daily Show with Jon Stewart - 12/01/04 - Video Clip | Comedy Central

Steve Carell vs Stephen Colbert on Islam Christianity

an honest debate from both sides

Posted via email from sente's posterous