Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
TypeError: Decimal('499.00') is not JSON serializable
>>> import smtplib
>>> gmail_smtp='74.125.127.109'
>>> handle = smtplib.SMTP(gmail_smtp, 25)
>>> handle.ehlo()
(250, 'mx.google.com at your service, [58.246.22.38]\nSIZE 35882577\n8BITMIME\nS
TARTTLS\nENHANCEDSTATUSCODES')
>>> handle.starttls()
(220, '2.0.0 Ready to start TLS')
>>> handle.login('[email protected]', 'xxxxxxx')
(235, '2.7.0 Accepted')
@lxneng
lxneng / ipython_virtualenv.py
Created July 22, 2011 04:01 — forked from EnigmaCurry/ipython_virtualenv.py
Setup ipython to work in a virtualenv
#Call this inside ~/.ipython/ipy_user_conf.py main()
import sys
import subprocess
from os import environ
if 'VIRTUAL_ENV' in environ:
#This is kludgy but it works; grab the right sys.path from the virtualenv python install:
path = subprocess.Popen(['python', '-c','import sys;print(repr(sys.path))'],
stdout=subprocess.PIPE).communicate()[0]
@lxneng
lxneng / gist:1096883
Created July 21, 2011 09:50
my hosts
~ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
@lxneng
lxneng / gist:1096882
Created July 21, 2011 09:50
my hosts
~ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

before

if(i-words < 0):
    start_point = 0
else:
    start_point = i - words

after

@lxneng
lxneng / hasInternets.js
Created July 12, 2011 03:35 — forked from scottjehl/hasInternets.js
quick check for online status with jQuery
//quick online/offline check
function hasInternets() {
var s = $.ajax({
type: "HEAD",
url: window.location.href.split("?")[0] + "?" + Math.random(),
async: false
}).status;
//thx http://www.louisremi.com/2011/04/22/navigator-online-alternative-serverreachable/
return s >= 200 && s < 300 || s === 304;
};
>>> document.cookie = 'visited=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
"visited=; expires=Thu, 01-Jan-70 00:00:01 GMT;"
>>> document.cookie
"_vis_opt_s=1%7C; _vis_opt_exp_16_exclude=1; C_SOURCEID=1iMdUrqQzWnr0hWYd6hfb1PHjDLHW7%26link%26200; __utmx=228830211.; __utmxx=228830211.; userid="qDVQs1QiohGOOarNtVwHYl,"; __utmz=127460183.1308566462.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmz=228830211.1309499889.69.35.utmcsr=192.168.0.117:5000|utmccn=(referral)|utmcmd=referral|utmcct=/shop/jassen; __utma=228830211.656686459.1304905179.1309230703.1309499889.69; 2s4uses=e434f7fc5fde45455f71fc683139c368577e6f5bgAJ9cQEoVQlzaG9wLnNpemVxAl1xA1ULc2hvcC5jb2xvdXJxBF1xBVUNc2hvcC5jYXRlZ29yeXEGWA0AAABqdXJrZW4tcm9ra2VucQdVA19pZHEIVSA0MzMwMTRkZmM3ODI0ZGViMTA0OTUyMzI3ZGVlMjJiOXEJVQ5fYWNjZXNzZWRfdGltZXEKR0HThPDan1JIVQ5fY3JlYXRpb25fdGltZXELR0HThPAv1KtcdS4=; NM_2STYLE4YOU=1d54e26f25e3c9797204b964f230b8550a2955fa49b6c97ff8f6e542d0c2918b; __utma=127460183.1554753308.1308566462.1309418988.1309917256.14; __utmc=127460183; vi

two sqlchchemy errors

sqlalchemy.exc.InternalError: (InternalError) current transaction is aborted, commands ignored until end of transaction block


sqlalchemy.orm.exc.DetachedInstanceError: Instance <Top at 0xc3d0d0c> is not bound to a Session; attribute refresh operation cannot proceed
@lxneng
lxneng / rails_3_1_rc4_changes.md
Created June 29, 2011 09:17 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]