« first day (1564 days earlier)      last day (3374 days later) » 

12:18 AM
My work network has blocked xmlsucks.org as a "sex" related site
 
12:31 AM
I think they are right, if you look at its source code.
 
@AshwiniChaudhary Wow. I wonder what happened? It's linked to in a coding horror post.
I assume it wouldn't have been, in its current state
"mutant Zionist space-dragons" oh my
 
I assume they are trying to make a point about how much xml sucks
or not
thats weird
 
@AirThomas No idea, never visited that site before. Check its history on web.archive.org (blocked in India).
 
Why is that blocked in India?
 
12:47 AM
looks like it got hacked back in like 2009 is my guess
 
The April 2010 snapshot is the first one I come to that's blocked
Anyway, my ride's here. Rhubarb.
 
@AaronHall http://thenextweb.com/in/2014/12/31/vimeo-github-30-sites-blocked-india-content-isis/

Government [removed the ban](http://www.zdnet.com/article/india-lifts-block-on-vimeo-pastebin-internet-archive-others-still-banned) from some of the websites later on, but for me just GitHub works. Vimeo and rest of them end up with https://db.tt/dL0W57yp.
 
I hate censorship.
 
Hi All
I have a django query some thing like this:
Book.objects.filter(publisherID = 1).aggregate(Avg('price'))
It may return multiple items, if there are more than one item that have publisherID=1. So, how to get only one of them, ignore the rest
I am not sure about this:
Book.objects.get(publisherID = 1).aggregate(Avg('price'))
 
1:09 AM
Book.objects.get(publisherID = 1).aggregate(Avg('price')).first()
assuming its like sqlalchemy (I havent used the django flavor in a while)
 
@Joran think you want .filter there - .get will return 1 entry or raise an exception...
 
ahhh yeah ok ... it was just a guess ... Ive forgone django infavor of sqlalchemy+flask
bye
 
1:25 AM
@JoranBeasley first() did not work
@JonClements you are right. So, what is the solution?
I have tried this:
Book.objects.filter(publisherID = 1).aggregate(Avg('price'))[0]
 
Ummm... I think it's annotate - not aggregate...
 
It will also give an error: "Key error"
 
oh no, there is an aggregate in the latest Django's
Why do you have the [0] at the end?
 
to get the first item returned from filter
 
Well, if you look at the example
# Average price across all books.
>>> from django.db.models import Avg
>>> Book.objects.all().aggregate(Avg('price'))
{'price__avg': 34.35}
You'll see that you want ['price__avg']... not [0]
 
1:31 AM
Yes, that is right :)
It is a dict
but, it is not going to help me to get only one of publisherID = 1 items
 
Well, if you only want one of the items - what's the point of an average?
 
@JonClements Actually, I have duplicate records for some reason in the DB. I just want to avoid them
 
So you don't want an average then?
 
Well, I need. Because, publisherID =1 has multiple records, but some of them are duplicates
So, I want to take the average at the same time avoid the duplicates
 
and how do you recognise the duplicates?
 
1:38 AM
all columns are identical, other than time stamp
 
Sounds like you should have put constraints in your models :)
I only popped on for a minute - don't have time to help you sort that mess out... see you later
 
@JonClements :) thanks anyway.see u
 
2:29 AM
My django program wont let me run the server it says models aren't loaded yet here is a pastebin with the error message pastebin.com/mQcYh1tQ
 
 
2 hours later…
4:29 AM
django <3
it seems it has some interference during import time
 
5:10 AM
sleep little Pythonistas
sleep
zzzz
gnight!
 
5:32 AM
not sleepign here
 
5:57 AM
Cbg
That guy who asked me about explicitly setting __package__, started his reply with "Thanks, nice answers!". I guess I wasn't blatantly wrong :D
 
6:18 AM
@vaultah runpy: command not found :P
so it is not a general answer
 
runpy module works on both Python 2 and py3k...
 
cbg
 
yes but runpy is not installed runnable as such in ubuntu at all
 
7:00 AM
Cbg
 
7:33 AM
Cabbage!
 
Cbg
 
Cbg
 
cbg(all)
oh boy.. the chat is terrible on mobile as well as a full site viewed from a phone
i can't see why they cannot optimise and rethink it.. it is like this for almost 2 years now (maybe even more?)
 
@PeterVaro What phone? On my it is ... reasonable.
 
Mine it's okay as well
@PeterVaro cbg
Even the @name stuff works
 
7:49 AM
It looks a little ugly, but it's acceptable
 
Mine it's fine
Do you have ?mobile=true in your url?
 
from .records import Record
from . import relations

from .. import dbh
from ..misc import consts, utils
from .. import images
relative imports ftw ^^
 
8:15 AM
Just found this in my code. So ugly
dt['fixed_post'] = loaded['fixed_post'] \
                        if loaded.get('fixed_post') else None
 
dt['fixed_post'] = loaded.get('fixed_post', None) ?
(As a Python noob)
 
Just dt['fixed_post'] = loaded.get('fixed_post')
 
Ok, mental block: I want to instantiate something n times in a listcomp. Here's a toy example:
>>> [x**x for x in itertools.starmap(random.random, [()] * 3)]
[0.8372125923493866, 0.7006399980201061, 0.8201524409181714]
There's gotta be a better way, right?
I feel like something very, very basic has just dropped entirely out of my memory.
 
8:36 AM
In [10]: [pow(random.random(), 2) for _ in range(3)]
Out[10]: [0.4048069605924381, 0.7646738699598644, 0.4054304155748905]
 
@ZeroPiraeus [pow(random.random(), 2) for _ in range(3)]
@vaultah Hey, I have seen that sneaky edit :-D.
 
Haha, it's just one variable ;)
 
Heheheh, didn't explain myself properly. I need to refer to x twice; in my actual code x is an instance of a class I defined, and x**x is replaced by e.g. x.is_like(x).
 
Oh, right, both wrong :-).
 
I can just bite the bullet and use an actual for loop - in general I avoid tricksy uses of listcomps; it just feels like some really obvious idiom has temporarily escaped me.
 
8:42 AM
[x**x for x in (random.random() for _ in range(3))]
 
Bingo! Thanks @Fenikso, I knew it was something really simple.
 
Nested list comprehensions!
Or generators for that matter...
Anyway, I have learned itertools.starmap today.
 
Perils of coding at 05:44 due to insomnia ...
Then we helped each other ;-)
 
It is much more funny to code drunk than partially asleep.
 
Yes, that can be entertaining :-)
 
8:45 AM
But never use production database :-D.
 
I really need to stay away from SO. I'll keep down-voting answerers.
 
@GamesBrainiac I was going to answer that question :D
 
Yea. Did the guy even try to answer?
 
@GamesBrainiac Gah, they probably need it.
 
I don't want a damn thesis, I just want to see an honest attempt.
 
8:48 AM
list(map(lambda x: x * x, islice(iter(random.random, None), 3)))
 
Yea, that ain't a generator. ;)
 
@AnttiHaapala Where are you coming from, sir, LISP?
 
no, I am coming TO lisp :d
 
@AnttiHaapala me too :)
 
I like the composable functions more than 1 syntax for 1 use case, one for another
 
8:49 AM
I went from Java to Clojure, got scared and came back a bit and ended up at Python :)
 
@AnttiHaapala Still better than to Perl :-P.
 
@Fenikso have some unicorn points for your trouble :-)
@AnttiHaapala You're evil :-)
 
@ZeroPiraeus Sorry, I only take fairy dust.
 
there are some tihngs I'd like to wrap on python, maybe have a source filter for the features, like binding partial funcs such as this could be written as
map(math.pow($, 2), ...)
which would compile exactly as functools.partial(math.pow, ...)
though partial does not support rightmost args at all
hmhm
if only python could look like javascript :D
 
@AnttiHaapala Is that the darkness call? Because I cannot hear you :-).
 
8:54 AM
re-cbg
 
cbg @ffis :-)
 
I love python libs, I love most of the syntax but not all :D
I still love it the most of all programming languages tried so far :D
 
@Fenikso Nexus 6
I'm not saying it is "unusable", but it could be way better than that
 
anywho -- if I want to download "tons of stuff" from another server inside my flask app, how would I do that? I mean, how would I make it multithreaded?
simply using the python's threading?
or is there a flask specific one?
 
9:01 AM
gong gong gong
 
@PeterVaro which browser?
 
@Ffisegydd the last one has linkedin access tokens :D
 
That is some serious gongage.
 
I'm using Firefox for Android
tbh it is working as it worked on my iPhone
so the porblem is not in the phone or the OS or the browser itself
(nor the screensize)
it is just.. clunky
 
I modflagged it
but doubt they will do anything :D
if the op didnt request
 
9:03 AM
 
@PeterVaro Contrary lot of Android browsers Firefox has its own rendering engine. You may want to try Chrome or Habit browser (based on default which is Chromium I think in Android 5), or Dolphin (which uses their rendering engine Jetpack).
 
I also have cyanogen's own browser
I don't know what that is..
 
@PeterVaro this is fine from this phone :)
 
Not that it is guaranteed to give you better user experience. But may be worth trying.
 
9:10 AM
anywho => so, how would I run threads inside a Flask app?
 
@PeterVaro You should never even consider doing that.
If you have tasks, use flask-celery.
 
@GamesBrainiac that's exactly what I was looking for!
(and that's why I asked, because simple threads looked wrong to me)
 
@PeterVaro You're welcome ;)
 
@GamesBrainiac So why exactly is that wrong?
 
@Fenikso That would require a long answer.
 
9:18 AM
@Fenikso threads are hard.
 
Threads are evil. They killed my family. I have sworn revenge on them.
 
@RobertGrant Not that. Basically, you could end up spawning a lot of daemon threads that never die, since the webserver is still running.
 
That seems to agree with my statement :)
 
Well, threads are not hard, if you compare them to other methods of writing paralell code. They give you access to a shared state, they're easy to create, and modify etc etc. Compare that to making processes communicate with each other using signals i.e. IPC stuff. Now thats hard.
Instead of saying "threads are hard", its more like "threads are inadequate for the job".
 
anyone here expert with flaskadmin + sqlalchemy combination
 
9:22 AM
Nope.
 
@GamesBrainiac due to shared state they're also easy to create race conditions and introduce subtle bugs with, which is why they're actually hard :)
 
we are not using flask-sqla and will never do (this is a pyramid app with flask embedded), now the problem is that if an error occurs, the scoped session is not cleaned and rollbacked, it seesm that no one really used flask_admin without flask-sqla
flask-admin.readthedocs.org/en/v1.0.9/db_sqla this is what we are following, but passing in the session: admin.add_view(ModelView(SomeModel, session))
 
@RobertGrant Well, if you lock stuff, its not hard. You have plenty of stuff in python to help with that. You indeed can create race conditions, but I think IPC with processes is harder, since you have to do a lot more signalling.
 
@GamesBrainiac So the long answer short is that if done incorrectly I can clog my server?
 
@RobertGrant How about we call it a truce by saying concurrency and paralellism is hard :D
 
9:26 AM
@GamesBrainiac I think we can agree that as long as you don't do something to create lots of undying threads in the web server, and you perfectly lock your shared state (disclaimer: list shortened), threads are easy, unless doing all that is hard, in which case threads are hard :)
 
@RobertGrant hi5 bratha :D
 
@GamesBrainiac you know it broseph
 
Are there any drawbacks of pathlib?
 
Apart from it being 3.4 only?
 
I call that a benefit :)
 
9:30 AM
Yes, @Ffisegydd
 
Well yeah so would I, but some people like to support Python 2.x
 
The reason for slow Python 3 adoption is the lack of bytecode forward compatibility. Discuss :)
 
no.
bytecode forward compatibility was never there.
 
That's what I mean by lack :) In any version of Python. E.g. Python2 bytecode isn't forward compatible.
 
I have never seen bytecode only python software
it is pretty pointless since decompiling is quite easy
1 reason for slow adoption is the C extension source incompatibility
 
and it is by far greater obstacle than the py source code incompatibility
dict(enumerate(List)) ^
 
GOOOOOOOOOONG
 
@AnttiHaapala I'm surprised that C extensions would become incompatible
 
@Ffisegydd That's actually quite cool ... the comments demonstrate exactly why the question is unclear.
 
@vaultah Some functionality, like deltree or copy are not supported, so you may need to use shutil or os anyway.
 
9:51 AM
With the help of pathlib, I managed to stop using os (in some modules). That's terrifying :I
 
Also it does not inherit from str, so passing to functions like open will require to either str(path) or path.to_posix(). But still better than wire in the eye I suppose :-).
 
@Fenikso hm, makes sense
 
Then again ...
Since you just edited your question (and so presumably think it's now clearer): how do you want to do that? You have three completely different solutions here in the comments that all answer your question as written. You need to provide more detail ... — Zero Piraeus 1 min ago
 
10:06 AM
or open should be made to accept a PATH afterall
@ZeroPiraeus now that we finally got the edit, everything is less clear :d
@Fenikso path.to_posix() is not right
1 stupidity there is in pathlib
 
@AnttiHaapala path.as_posix(), sorry.
 
Path.touch(mode=0o777, exist_ok=True)
@Fenikso even so, you are making the code not run properly on windows anymore :D
the touch method suffers from the PHP idiocy of overriding by arguments
 
@AnttiHaapala Actually, Windows supports forward slashes anyway.
 
who actually thought that the exist_ok=False should be even called "touch"
it should be "create"
 
cbg
 
10:13 AM
cbg
 
ok.. What UnicodeType ? It' s weirdo am getting global name 'UnicodeType' is not defined
 
dunno, it is something you invented?
or types.UnicodeType?
 
Noo.. Actually i playing xhtml2pdf and exactly this line github.com/chrisglass/xhtml2pdf/blob/…
 
you are running it with python 3 and it was written for python 2
aka sucks
@Raja it cant work in either python 2 or 3
are you running it with python 2 or python 3?
fix depends on it
anw must be the worst code i have seen today
 
Funny, as the last edit to the project is "compatibility with python 3.x".
 
10:20 AM
@Fenikso yeah, as you can see it had "import types", it is removed
 
Oh ..! My local version Python 2.7.6
 
so the UnicodeType has magically come from some star imports from another module
AND it is removed too
and there is no testing.
and it uses type() is ()
wtf
so:
@Raja add line UnicodeType = unicode after the imports and file a bug report
 
@AnttiHaapala Replied again, but I don't think we'll get anywhere ...
 
delete asap :D
downvote to oblivion
it even had +1 from someone, wtf?
 
That can only be a friend/colleague/sockpuppet.
 
10:26 AM
I hate unicode errors.
 
@GamesBrainiac Any specific reason?
 
Done
 
dont want that to pop to front page all the time someone edits :D
 
@Fenikso Unicode is messed up. To encode or decode, that is the question.
 
10:31 AM
@GamesBrainiac ha?
to go from unicode to an encoding you encode, to get from encoding to unicode you decode :D
 
Precisely, but what encoding, utf? cp<someshithere>? I've had trouble finding the correct encoding.
 
Gotta agree with @Antti - in 2.x it could be a royal pain, but it's really very straightforward in 3.x.
 
though unicode is also called encoding
utf-8 always out
 
@GamesBrainiac Only think I hate is that it gives error like UnicodeEncodeError: 'ascii' codec can't encode character '\u0161' in position 16: ordinal not in range(128) not giving you a clue what the hell is the string you got. But there is a way around it.
 
if in then try utf-8 first, if it fails, the national :d
@Fenikso never problem in python 3
instead you get the much more obvious TypeError: 'str' does not support the buffer interface which in fact does not tell a shit to the clueless either :D
 
10:34 AM
If you have filthy nasty evil data of some unknown encoding, chardet can be handy (but not in production code, just for working out what the hell you have).
 
yeah, the problem is you need more like neural algorithm to detect from small samples
especially latin-1 vs latin-9 :D
 
@AnttiHaapala How come? If I get UnicodeError, I always get that character '\u0161' in position 16 crap without clue. Even in Python3.
 
not so much context where to deduct which one it should be IF these chars occur
 
@AnttiHaapala Thanks initial error gone though i'm getting into " 'ascii' codec can't " error. I just want my user to download pdf of html page when click on the button. Is there any Django friendly ?
 
:D:D:D
so at which line @Raja
if in there?
 
10:44 AM
@Raja How about this? pypi.python.org/pypi/pdfkit
 
@Fenikso think that one is not the easiest
 
@AnttiHaapala Well, I judged by pdfkit.from_url('google.com', 'out.pdf', options=options) example.
 
on a related note I made an extension for firefox that would read url from command line and print the webpage to the given pdf, but it never saw any use...
@Fenikso if you can install it yes, if you cant, you need to compile C++ all day long
that is wkhtmltopdf
 
omg
so it is writing it into tempfile opened in binary mode, yay
 
10:51 AM
Could I ask someone something about red-black trees?
 
just ask
@Raja add there (for only python 2!!!)

try:
self._delegate.write(value)
except UnicodeError:
self._delegate.write(value.encode('UTF-8'))
and report a new bug
 
@AnttiHaapala According to my lecture notes:
Let x be the child of the node that we delete. Let w be its sibling node and p the father of x.
There are four cases:
1. Case 1: w is red. We cahnge the color of w to black and of p to red and we make a left rotation around the father of x.
@AnttiHaapala Why do we change the color p? Isn't is the node that we delete?
Or have I understood it wrong?
 
there was a nice anim about avl trees in starred msgs
I dont remember if it also had rb ... 1 moment
ah not there
they dont have rb
 
@AnttiHaapala From that what I wrote do you understand that p has to be deleted... Or have I understood it wrong?
 
wait a sec
ah you need to rotate it first before the deletion
 
11:00 AM
I know I've asked this before, but has anyone here used ansible?
 
I did try
 
@AnttiHaapala Looks like it to me too.
 
horrible as everything else
it means that the rotate algorithm can be general
 
@AnttiHaapala What did you dislike about it?
 
@AnttiHaapala Thanks, but after removing mimetype from HttpResponse the result shown in the page weird ( just random text and numbers...!)
That's working but i am not getting pdf
 
11:04 AM
@AnttiHaapala After that : "We change the color of w to black and of p to red and we make a left rotation around the father of x" it says that Now we have one of the cases 2,3 or 4. For example the case 2 is this: Both of the children of w are black. We chage the color of w to red, x to black and we transfer the black that we subtracted from w and x to p. If p was red it becomes black and the algorithm terminates. Otherwise, p gets double black and the algorithm continues until x=p.
@AnttiHaapala At which point do we delete p?
 
@Raja it is called pdf file...
@Raja you need to serve it with application/pdf
@GamesBrainiac ah I liked the fact that I didnt need ruby
but I disliked the fact that I still didnt have any clue as to what the hell am i doing
none of the stuff is really reusable
 
ahh, I see what you mean.
 
I mean,
I listened to 1 pres about how ansible saved the day
 
@AnttiHaapala Hm Thanks .. after putting content_type='application/pdf' everything works ...!. Now gonna investigate why the html color and images is not coming ...!
 
as to "now it is easy to replicate to another server platform"
but for us, we use aws, actually using snapshots etc is way easier than ansible
 
11:08 AM
Ahh, I see what you mean.
 
we just build for the general case that we can deploy from root system images (something like docker ought to even better)
I mean
I felt like writing ansible playbooks was as hodgepodge as writing shell scripts, only I didnt have any clue as to how to do it :d
and also ofc the fact that ansible does not need any stupid daemons on the targets
 
how long ago did you try it out?
I mean even now, there aren't that many resources for this.
 
within year
wait...
I was like "oh now I have written a work book that will install apache on the target server if it does not exist"
sudo apt-get install apache2 done
 
I see.
 
or even write a shell script for that :D
 
11:13 AM
lol
 
then i wrote 1 that would install postfix configs
it was like ...
well beccause we can do from images, it never needs to be redone but in case it needs it took 20 times more time to write that ansible scirpt than it does to do the work
 
Hmm. Honestly, Im just looking into ansible right now.
 
even so, it felt like the workbooks are not really generic
 
So, I really don't know what to expect.
 
tasks:
- name: install postfix
action: apt pkg=postfix state=installed
tags:
- postfix
- packages
^ it still says "apt" there
try install it on centos
it is like the 50 line ansible script could be replaced with a 5 line bash script :(
that would run some commands over ssh
 
11:19 AM
can you launch AWS instances with specific roles through snapshots?
 
hmm?
anything is possible ofc
the instances can also be provided data at launch
When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2: shell scripts and cloud-init directives. You can also pass this data into the launch wizard as plain text, as a file (this is useful for launching instances via the command line tools), or as base64-encoded text (for API calls).
 
english: these technologies are compatible to each other or for or with?
(I'm super confused here :P)
 
with
 
I'd go for "with"
 
11:30 AM
Ask the audience: 98% with, 1.6% for, 0.4% to
 
all righty then..
thanks, I wil use with then
 
comparable is a different thing then
Use compared to when the intent is to assert, without the need for elaboration, that two or more items are similar: She compared her work for women’s rights to Susan B Anthony’s campaign for women’s suffrage.

Use compared with when juxtaposing two or more items to illustrate similarities and/or differences: His time was 2:11:10 compared with 2:14 for his closest competitor.
 
@AnttiHaapala hmm...
 
in any case if you are talking about technologies compatible with each other I'd say with...
 
cel
I wonder how the triage should work if the cv-queue is stuffed.
 
I say "poor", but you know what I mean.
100 days to go, are we going to begin slowly ramping up political discussion until it even eclipses IndependenceGate @Jon?
 
I reckon everyone should just vote "Cute Yellow Puppy" as 5 year dictator (yes - I do see the irony in voting for a dictator) - but gimme 5 years, I'll sort this country out :)
 

« first day (1564 days earlier)      last day (3374 days later) »