« first day (1684 days earlier)      last day (3265 days later) » 
03:00 - 16:0016:00 - 00:00

wim
3:29 AM
dumb git question
I use git checkout somefile to revert local changes in a file
I also use git checkout branchname to switch branch
what happens if there is a conflict in a filename and branch name?
 
Why don't you create a sample repo and try? ;-)
 
There's an order of preference between all the different identifiers.
Otherwise, there's a more verbose syntax to describe things.
I think, I can't remember the exact reference.
 
➜  chumma git:(chumma) ✗ git checkout master
M       master
Switched to branch 'master'
It switches branch in my case
 
git checkout -- master would refer to the file
 
Hmmm, yeah. git status suggests that
 
3:56 AM
hey hey hey!
 
4:15 AM
I am using python and django for web application. Is it possible for the django signal receiver to inform the already loaded page that the data has changed and request for a reload ??
 
I have a question with regards to class attributes and class instance attributes.
class Account(object):
	balance = 0
	holder = 0
	def __init__(self, account_holder):
		self.balance = 0
		self.holder = account_holder
I do not see __init__ as attribute of class Account.
little type above: it is type(self) but not self in __init__()
 
@davidism Hammered it
 
 
1 hour later…
6:06 AM
Hey up
 
Cabbage @Ffisegydd :-)
 
 
1 hour later…
7:10 AM
would you use the above Python library ^
@overexchange ide sucking there
 
Looks like IDLE
 
@Ffisegydd would you use a library that used c_char_p from CTypes as a buffer for pure-python code...
or that has gems like: if chunk.strip() is None or chunk.strip() == '':
 
No. But that's because I only understood half the words in your question
Ah that second part looks terrible
 
it checks if the .strip() would return None :P
me accidentally None
 
7:17 AM
self.get_string_buffer().replace("}{", "}%s{" % NEW_LINE)
"because me accidentally no newline"
 
Sup brah
 
(I'm still bearded in the working world :))
 
Yes but you're ruggedly handsome, or so I'm led to believe... by you...
 
You got my Valentine's Day card!
 
Eventually, the cologne you sprayed it with set off the sniffer dogs at the airport.
 
7:20 AM
@RobertGrant ssh, Fizzy's gf was quite upset by your card
 
Yeah we do not mention it anymore, I'm still recovering from the beating.
 
@Ffisegydd I think it's because it was real toilet water. Not that store-bought stuff.
Hm
@Ffisegydd D3 question: lots of examples use the csv method to load data. Is there any advantage over embedding it in the javascript on the page?
(One possible one: it doesn't block while processing a lot of data, so you can have a loading screen)
 
cbg
 
7:41 AM
Wow I didn't expect that
 
@Robert what if your data is in an actual csv?
 
No, if it's coming out of a database
 
As in, in production.
 
And I can chuck it straight onto the page, or I can have a separate route that generates csv data on the fly
 
Ah I see
Don't know then. I suppose the blocking would be a main thing.
 
7:42 AM
Cool, thanks
 
7:52 AM
Cabbage!
@wim Branch is matched first. To make sure you can either use git checkout HEAD filename or git checkout -- filename (the -- separates the branch and path part). Or even git checkout HEAD -- filename to be very explicit.
 
@AnttiHaapala wouldn't that algorithm give E for A A A B C D E?
 
I don’t understand that algorithm.
> But if you must confirm that the chosen element is indeed the majority element, you must take one more linear pass through the data to do it.
 
Yeah that also was weird :) I think that's referring to the fact that there may be a tie, but I don't know.
 
I would like that thing to have a live example test thingy.
 
My own algorithm is O(1): return the first element in the list. You must take one linear pass through the data to confirm it.
I would like @AnttiHaapala to give me a wise answer to my data :)
 
8:04 AM
I thought that was referring to a tie also.
 
8:23 AM
There.
And yes, E is the result
I wonder if the paper is more clear on that.
I don’t have a postscript converter here though… :/
Meh.
Fortran code.
Why don’t they use pseudocode!?
Weirdest paper I have ever read…
(and that says a lot)
 
Oh, I get it
It also requires a majority
 
But isn’t A in the majority in AAABCDE?
 
That's my example as well
No, because a majority must be at least half of the total
 
Oh, that kind of a majority!
 
Basically the algorithm is ridiculously limited
 
8:30 AM
Ah right!
 
Who cares about absolute majority?!
 
Well that sucks.
 
Super useless.
 
I got an algorithm for ya: winner, _ = Counter(votes.split()).most_common(1)
I call my algorithm "Delegate to some magical implementation"
Possibly it doesn't work, because most_common may return a list
 
Counting also makes just a single pass.
 
8:33 AM
Or probably a dict
 
Majority by counting is at most O(n) too. It takes a single pass over the list, and then a single pass over the result count list.
 
@Ffisegydd you know when I said yesterday that I didn't want to just paste D3 code and fiddle with it til it worked, I wanted to understand it? Well THAT'S ALL OVER
 
It just takes linear space, but who cares about that. The set of candidates is likely constant too, so if we move that to the input, we have constant space.
 
@poke yeah it's bizarre that they're trying to optimise it
 
8:36 AM
Maybe for when there are quintillions of humans spread across the galaxy and we need to count their votes or something
 
Sucks if there isn’t a majority then…
 
@Bob bahahahaha
I swear Mike Bostock is the only person who knows how D3 works and every other piece of code is just one of his examples that's been copied and fiddled with.
3
 
That actually sounds realistic.
 
@Ffisegydd well that makes me feel a bit better :)
There's that Cubism D3 plugin that he wrote to make charts easier, I might have a look at that at some point
 
Once you figured out how d3 works, please tell me.
 
8:57 AM
:)
I figured out a little bit of it :)
Although this thing I'm doing now I'm basically copying blind. And no matter how good I am at javascript debugging, it's still better not to type "guarter" instead of "quarter" in the first place.
 
I’m about to jump out of the window… someone thought it was a good idea to drill somewhere on the floor above us during work time… it’s not stopping, just a constant, loud drilling sound
 
Got the same here. I'm back up at uni for the day and they're remodelling the lab next door.
 
9:26 AM
@Ffisegydd even this tutorial on rendering d3 on the server says at the bottom that it's based on a Mike Bostock gist that renders a pie chart on the server!
I know it's a bit early to say this about D3, but I think I love Mike Bostock
 
10:02 AM
@RobertGrant notice that it changes the majority only if the count is 0
it is about majority, not plurality
 
cbg all :)
 
@RobertGrant yes, it would return E,
 
@AnttiHaapala yeah we worked it out :)
 
because there is no majority :D
I was like "oh this guy is good", then I realized that moore and boyer are the boyer-moore.
 
So even amazing people come up with useless stuff for papers eventually.
 
10:12 AM
Yeah it seems like the formalisation of a pretty basic logic problem
 
Pew pew
 
Gone
My identicon is awesome
 
A new one
 
This ^
 
11:37 AM
Sometimes, I would just like to troll on questions…
Like this one. “Is it possible?” – “No, it’s not. Sorry.”
 
To be fair, when I just started programming I was unsure if something is "possible", simply because I didn't yet grep some concepts
Don't kick someone just because they haven't heard of everything they need to hear to do a specific thing :(
 
Python Anywhere are great guys by the way
I've visited their office a few months ago when I was searching for a job :D
Has anyone else met them? ^^
 
No, but I've had an email exchange with one of them, and he seemed very cool
 
Cross posting from HN: "Can assign [] = (), but not () = []" bugs.python.org/issue23275
 
12:38 PM
cbg all
 
12:55 PM
morning friends
question of conventions; how do you inform new developers of required environment variables? Throw an error on startup?
 
I'd quite like that if I were using that software
 
Sure, "fail fast" is nice to have
 
prepare an installer?
 
@JanDvorak it's a meteor website so not sure how to do that, is that possible?
 
1:01 PM
@corvid permanent ones or temporary?
 
@poke Permanent, as in keys for APIs and whatnot
 
Does that have to be in the environment? Can’t you just provide a config file?
Environment variables should be used sparingly
 
I've already seen e-shops that start off with a config screen
 
I thought it was conventional to include secret keys. Short of that I guess there could be a private collection on the server? ServiceConfiguration does that
 
Environment variables are everything but secret.
or private
 
1:04 PM
What's the proper solution usually?
 
Are they less so than a config file?
The 12-factor app recommends environment vars
 
Is there a standard way to write code that uses input/raw_input such that it behaves the same in both Python 2 and 3?
I could do:
try:
    input = raw_input
except NameError:
    #we're already in 3.x and don't need to do anything
    pass
But I don't know if that's "official"
Or canonical or whatever you want to call it.
 
Isn't that what six does?
Disclaimer: I've only ever heard of six
 
import sys

print(sys.version_info.major)
# 3
if sys.version_info.major < 3:
    input = raw_input
Is my guess
 
@RobertGrant I can put config files behind file system security, yes.
 
1:16 PM
And yes, six basically does that and gives you some helper methods
 
@poke what would you think of using a mongo collection via serverside only? Would that be insecure?
 
I personally like to have configuration in some way that I can modify without having to invoke some other system
 
Installing a third party library is probably a bit much. I just wanted the "correct" code snippet for Python program works from command prompt but does not work when opened in Windows
 
But generally, sure, you can put configuration in a database.
 
not a great idea - database can be stolen
 
1:23 PM
Not if it's really heavy!
Opinion based and/or recommendation request
What the... Too broad? He can add details until the cows come home and it will still be opinion based
 
Is there a way to tell if I'm using the version of pip in my venv?
I'm in venv\Scripts\, so it should use the venv pip, right? I'm super new to venvs.
 
You don't need to go into the directory
Just run venv\Scripts\activate.bat
 
Sweet, thanks.
 
@MorganThrapp Once you got a bit more familiar have a look at virtualevwrapper
 
@MorganThrapp there is a windows version of that, but to be honest I find it easier to have a venv in the project dir anyway
 
1:36 PM
Halla
how can I keep user in the same form instance after they clicked save?
 
Don't send them somewhere else
 
@RobertGrant Not sure if I agree :P But I linked to the windows version already :D
 
Oh you sly boots
 
1:48 PM
@wonderb0lt I'd used it in Linux, but I didn't know there was a windows version. Thanks.
 
Hello guys :)
 
Honestly, I use pyCharm to manage my venvs most of the time, but it has a couple things it can't quite do. (Like install local wheels into the venv)
 
Hi guys
 
Hi Soma
Welcome
 
I'm facing something very weird with Python and OpenCV :/
 
1:55 PM
What is it ?
 
cv2.waitKey doesn't wait at all
 
Are you doing cv2.waitKey or cv2.waitKey()?
Remember, you must call a function if you want it to be called.
 
cv2.waitKey(0)
 
@MarounMaroun can you please write me the code? — iYonatan 44 mins ago
 
1:57 PM
also tried with high number instead of 0
 
Sorry I have no experience with Opencv
 
Do you have at least one HighGUI window created and that window is active?
 
@vaultah The accepted answer with 2 upvotes is just golden
that's the worst code I've seen today and I'm dealing with PHP
 
@Kevin
 
user559633
at least php isn't nodejs
 
2:02 PM
hahaha
 
@Kevin no I didn't --'
 
Documentation says you need one, then
 
yes it does.. I never made the connection
excuse me, I've to hide for a bit.. Pleasure to meet you
 
I suspect the answer to this question is "just convert them to floats" but I expect OP will say "Ok, how do I do that? Right now they're stored in this super exotic data collection that holds mixed types, which I never mentioned earlier"
and commenters will say "how dare you suggest a limited precision data type! The OP may get irregularities in his results, even though Decimal(str(float(x))) == x for any Decimal value of x that has two digits after the decimal point"
 
2:26 PM
meetings are dumb :|
 
Just interject "but how does this affect the big picture?" and play cell phone games during the ensuing argument
 
@RobertGrant But will those scale?
 
That's right, "will it scale?" is more enterprisey than "what about the big picture?" these days.
 
Rob's bonus interjection: I'm not convinced that this fits with out $latest strategy
Lol I never actually looked at the Venn diagram before
 
2:34 PM
:D
It’s genius, right?
 
One of my coworkers suggested that we set up rain buckets, so that we can get our water from the cloud.
Enterprise water.
 
The cloud's dissolving - grab a bucket!
 
Just say stuff about cool front end technologies even if they don't fit the needs of the project. We should use angular and famo.us
 
Or meteor
 
user559633
@corvid pro-tip: don't do that when there are smart people at the meeting that might not like you
 
2:36 PM
well, in meteor's defense, it is very easy to use.
 
"How can we integrate social media into our project?"
"... We're writing pacemaker firmware."
"Yes, and your point is...?"
 
What’s more social than helping people with heart issues though?
 
DSM
Morning cabbage. (Although I'm about to step away for a second to get an enterprise drink.)
 
tweet #dying when the program breaks
 
@Kevin it will send out a status update when you're heart stops beating! Oh...
 
user559633
2:36 PM
that's actually sort of perfect -- tele-cardiacs
 
Apple already beat you to that with the watch.
 
Good morning, veggies.
 
user559633
@doctor plz help #dying #savecorvid #follow4follow
 
#noheartbeat
 
Chomps on a carrot What's up doc?
 
2:37 PM
I wonder if you can get Siri to call 911 automatically
 
user559633
i don't know about that, but i do know that the google glass doesn't distinguish between voices. what a fun week at the office that was
 
Heh. That sounds wonderful.
 
@tristan “RT to apply defibrillation”
 
user559633
i once wrote a server-bot that listened to twitter for messages as a PoC
 
@tristan heh
Okay, google. Safesearch off. Donkey porn.
 
2:40 PM
I remember when phones started to get voice activated stuff... we had great fun with a mate at works one - yelling at it "Call The King Of Spain" and it'd end up doing "Calling Dad"...
 
user559633
it would direct twit you when something broke, then you could reply with shell commands (e.g. @prod-web01; service nginx restart). it was pretty awesome.
 
I actually bought some voice dictation software which was crappy as hell and needed to be set up tediously for your voice.
 
I wonder if people shout XBOX OFF over xbox live to see if anyone's playing on speaker with Kinect
 
user559633
@RobertGrant amazing
 
DSM
I haven't been following, but I thought consumer voice software was decent enough these days.
 
2:41 PM
@DSM it's better than it was for sure :)
 
Yeah I thought Dragon was awesome
 
Training it was a bit of a chore - but after that - it wasn't too bad
 
@Robert I remember that E3 announcement where there were lots of reports afterwards that the XBOXes some people had been watching it through reacted to all the voice commands in the presentation.
 
user559633
Dragons ARE awesome
 
@tristan That sounds fun.
 
2:42 PM
Oh wait - I meant Eragon
Typo
@poke heh that's great
 
user559633
Heh, letting microsoft put audio and video feeds in your house. what could go wrong?
 
I am also reminded of a comic (maybe it was Dilbert???) where the character hooks his television up to The Clapper, and it shuts off whenever he watches a game show with an applauding audience.
 
cbg
 
2:57 PM
Man that must be a busy job posting the same text under almost every answer on SO (Jason C)
-1
A: python - replace words from a list

Vignesh Kalaiimport re words = ["Hello","name","test"] Flags=False my_str = "Hello my name is test" if any(my_str in word for word in words): Flags=True my_str=re.sub("|".join(words),"******",my_str)

 
nah, computers have features called "copy" and "paste" which make that easy
 
:O
Still, clicking on every thread and clicking "comment" on every answer, phew.
 
A lot people actually use scripts that automatically send the comment
 
That's just silly
 
So you just see something, and click auto comment and chose an item from the list.
278
Q: AutoReviewComments - Pro-forma comments for SE

Benjol No more re-typing the same comments over and over! This script adds a little 'auto' link next to all comments boxes. When you click the link, you see a popup with 6 configurable auto-comments (canned responses), which you can easily click to insert. This script was inspired by answers to thi...

 
3:02 PM
Huh.
TIL
 
user559633
i think it's less silly to use a script than it is to copy and paste out of a text file :]
 
user4238267
ok
 
Remind me to bring up solicitation during the next room meeting. Might be nice to have something added to the rules page.
 
I think we brought it up two meetings ago.
 
3:15 PM
Or, I guess asking if anyone is looking for work is reverse-solicitation. Remind me to bring that up too.
 
If someone reminds me to, I'll remind you.
 
okay, really weird question, but is it possible in a debugger to step back in code?
 
Similarly, if any regulars are looking for freelance work, maybe we could make a list of them on the wiki
@corvid I remember reading about a C++ debugger that could do that.
 
(I've posted that before.)
 
DSM
aargh
 
3:17 PM
That may have been it.
 
DSM
I was just about to post that. :-)
 
In general no, it is not possible, or at least not supported.
 
@corvid Yes, some do that. For example in Visual Studio, you can just drag the current line pointer upwards to go back in time.
 
DSM
It's the rightmost tab open on my browser..
 
@poke for all languages?
 
3:17 PM
.NET
 
debugging backwards in time is easy, just take a snapshot of the entire process memory every time a value changes.
 
I'm using JS :\ imo the worst language to debug short of assembly or C... or java
 
I think VS is doing it by executing the IL in reverse
 
or write in purely functional style so that everything is deterministic
@corvid if you're using JS, you're in luck, Elm is based in JavaScript
 
Really? That's pretty awesome, thanks @davidism
 
3:19 PM
on the other hand, you have to learn and use Elm instead of whatever you're using now
 
Is there a way to show a pixel grid in wxpython? I don't mind if it's a little hacky, I'm just doing it to position things.
 
define "pixel grid"
 
hi guys. I am wanting to learn to make an app to help client migrating their data to new environment. basically it just do simple things. NET STOP some services, move data then on new environment it will install a few things, and NET START the services.

the question is, should / could I made it with python (with UI) and some references about it. if not, what language should I use?
 
A grid that has a bunch of 1x1 squares.
Ideally semi transparent.
 
If you're about to say "I just want to draw horizontal and vertical lines in between each pixel on my screen", then you're out of luck unless your system has some serious sub-pixel rendering magic
 
3:23 PM
I know photoshop has something like that maddisondesigns.com/wp-content/uploads/2009/10/…
I assume they just use a little bit of trickery.
 
@MorganThrapp you're missing the joke, that image is zoomed in, so 1 image pixel != 1 screen pixel
 
@davidism That makes sense.
 
@davidism is that linux only? *sorry i am really a newbie
 
no
 
MS Paint has a "show grid" feature, but it doesn't work for 1x or 2x zoom.
 
3:26 PM
Yeah, I might just do a mockup in paint.net and then count pixels in that.
That's going to be a lot easier.
 
great, thanks
 
@vaultah this is the best avatar yet
 
:)
 
3:33 PM
Is there a way in wxPython to change the kerning of a StaticText element?
Or in some other way make two StaticText instances with slightly different text appear to be the same length?
 
65
Q: How to create a zip archive of a directory

Martha YiHow can I create a zip archive of a directory structure in Python?

I have read all the answers to create zip file of current directory.
But due to some reason it is going into infinite loop and creating 4-5 GB file
And I have to kill the process to escape.
 
perhaps the zip file is being added to itself somehow. Try saving the zip somewhere other than the directory you're zipping.
 
^^
 
tried. same problem.
Is .git hidden directory the issue? Let me check.
 
@shantanuo welcome. Contrary to popular belief, we are not psychic. Please post code rather than narrating your problems to us.
 
3:39 PM
Beat me to it. Yes, I've exhausted my list of likely guesses and now would like to see the code before continuing.
 
user559633
Maybe your zipper is stuck
 
Badumtssssss.
 
lol
 
other directories are working fine. So this seems to be git issue.
 
DSM
Speak for yourself-- I can see the ending clearly. One will rise, and another will fall. The waterfall will run dry, but at what cost?
 
3:41 PM
The code has been picked from the page mentioned.
 
Hmm, perhaps I should add "check for invisible directories" to my psychic debugging act.
I'm willing to blame the problem on git.
 
@shantanuo did you consider debugging this? Print out lines to see what's going on. Step through it with pdb.
 
This will throw the error:
LargeZipFile: Zipfile size would require ZIP64 extensions
The directory is only 1 or 2 MB
 
what does du -hs /path/to/folder say?
 
yes. It says 1.4 GB When I have only 2 or 3 .py files in that folder.
Thanks for pointing this out. Why 1.4 GB for a few .py files?
 
3:49 PM
what does find /path/to/folder -type f | wc -l say?
 
312
 
So there's not "2 or 3 py files" at "1 or 2 MB", there's 312 files at 1.4 GB
 
ok. There was a big file in there. Let me try again.
 
DSM
...
 
3:51 PM
haha
 
import zipfile
zip = zipfile.ZipFile('Python2.zip', 'w')
This does not work though! I need to write something like /tmp/Python2.zip and then it works.
Does it mean it is not possible to create the zip file in cwd?
It would be great so that I could checkout along with zip file
 
If you use the phrase "this does not work" again without saying why it doesn't work, you will be kicked.
 
It gets into loop and I need kill kernal
 
11 mins ago, by davidism
@shantanuo did you consider debugging this? Print out lines to see what's going on. Step through it with pdb.
 
Just passed my viva. From henceforth I will only be answering to Dr. Fizzy.
6
 
3:58 PM
You'll always be just "Fizzy" to me. <3
 
@Ffisegydd Congrats, Dr. Fizzy!
 
@Ffisegydd Shut it Fizzyface
 
Does this mean you can get me scripts. ;)
 
And/or, congratulations
 
03:00 - 16:0016:00 - 00:00

« first day (1684 days earlier)      last day (3265 days later) »