Wednesday, April 18, 2012
Wednesday, February 1, 2012
// 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
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
Wednesday, September 28, 2011
Jquery Changelog
testing
More Examples
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)
some helper functions
Sunday, March 6, 2011
Thursday, February 24, 2011
How To Safely Store A Password | codahale.com
Use
bcryptUse 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.
Friday, February 4, 2011
First ever aerial footage of uncontacted Amazon tribe released
New film footage released today shows uncontacted Indians on the Brazil-Peru border in never-seen-before detail. It is the first-ever aerial footage of an uncontacted community.
Rather_depressing comments on My friend in Egypt was online today....
Liveleak mirror rehosted/reuploaded (Not by me)
NSFW - The diplomatic car that ran over 20 people in cairo (28th-Jan-2011)
NSFW - Police van running a pedestrian down
Possibly NSFW - Protester dragging plain clothed officer from water cannon truck
fuck the the police
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."
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.
...
Steve Carell vs Stephen Colbert on Islam Christianity
an honest debate from both sides