sente
Wednesday, April 18, 2012
Wednesday, February 1, 2012
here is an example blog post...
I hope this shit works....
Thats all for now
// 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()
Thursday, November 3, 2011
Subscribe to:
Posts (Atom)