@rene I'd say the 2 most important things we have as ROs is 1) a Trello board for keeping track of a) decisions, b) internal news (e.g. UserX is away for a month) and c) a problematic users list (aka naughty list) full of repeat offenders and what their behaviour tends to be (typically with links to chat messages) and 2) a Slack chat for real time private chat away from the room.
Slack is really invaluable, it might not be used for weeks at a time but is useful to have if necessary.
People may assume it's used to bitch about people in private :p and certainly for @Rob that is true, but a lot of the time it can actually be used to call each other out on behaviour.
Of course both of those things are internal, and you seemed to be after some externally facing ideas, but thought it was worth an explanation.
Hello people. I've got a project that is news aggregation. I found Flipboard to be a very good example. But on the internet during my research, I found a link where Evan Doll (the co founder of Flipboard) said, they have a generic scraper for almost every websites they scrape. But my question is, how is it possible to build a generic scraper since almost every website is built on a completely different structure?
@Ffisegydd Tnx for that insight. We are setting up something similar now. I understand that you'll need a back-channel to coordinate between RO's. My concern is indeed about the external facing part. I want to make sure that the regulars are conscious about the RO's moderation in-side the room. To prevent that it comes as a surprise that a RO steps in. I think I'm looking for a Theory of RO-ship and a RO-agreement.
We are doing the same atm. Our effort started here but we are in an update process as well. Let's keep each other informed about our findings/progress/tips&tricks
Lets say you have a string of characters, you want to replace certain characters or symbols with numbers, for instance the string 'abc' would turn into 'a' 0b100 'c'
This really can't be a string anymore, so I need to change it into either a list or something else, whats the best practice of doing this? I can change the string into a list and go over each character and replacing it with its encoding, I just wanted to see if there's a more pythonic way to do that
So I assign an encoding to each symbol. Lets say my string is 'aaabbccd '
After running huffman on it I'll have a list containing new encodings of the chars
since 'a' appears most of the times it'll get '11', b is '10', c '110', d '111'
Now what I do is replace the string with the new encodings, this saves space since the most frequent characters end up using a smaller encoding. so I need to go over the string and replace the characters there
@JRichardSnape Nice to see you got a bounty on that one. FWIW, calculating zeta(230 + 30j) with 120 digits of precision in mpmath the real part will be ok, but the imaginary part will only be accurate to 61 digits. To get 120 stable digits I had to go up to about 190 digits of precision.
it should be something like 0b11 0b11 0b11 0b10 0b10 0b110 0b111
sorry the string should have been 'aaaabbbccd'
It becomes like that because you create a tree with the probability of each character in some sort of fashion, the last level of depth has the least probability to appear in your data. After you do that you assign 1 to a left turn and 0 to a right turn from the root of your tree, then you start searching your tree for all of the symbols, creating the encoding as you go and voila
@GLaDOS: I'm slightly confused. Why does 'abc' become ['a', 0b100, 'c']? Why aren't all the characters in the string being replaced by their bitstring encodings?
@GLaDOS Of course. So you just save all the zeroes & ones produced by the Huffman encoding into a list, padding it if necessary to make the size a multiple of 8, and then parse that list in chunks, converting it into bytes using a technique similar to what I posted above. The answers to this question show a variety of ways to parse a list in fixed sized chunks.
I read the stream and run the characters through my huffman tree. whenever I reach a character I add it to my decompressed string and start the process again
@GLaDOS Python has nice tools for splitting & joining strings, so they're a handy way of playing with bit strings. Alternatively, you can use lists / tuples of 0 & 1 integers. I don't recommend handling your Huffman codes in 0b011 form as that's less convenient for manipulation, although I guess you can use the << and >> bitshifting operators as well as & and |
@GLaDOS I think the easiest way would be to store the encodings for each char in a dict, with the char as the key. If you store the codes as '011' style string then you can join the individual strings with the str.join method. Alternatively, store the codes as [0,1,1] style lists and join them with list.extend in a for loop.
@GLaDOS The first * in that zip thingy is affectionately known as the splat operator. It tells the function (zip, in this case), to extract the contents of the following tuple or list, and use each element of the tuple / list as a separate argument.
@PM2Ring yeah I looked into it and when they said that python refers to this as the unpacking operator (ruby refers as splat) it kind of clicked with things I learned a year or so back
Seriously. A business requirement to use the same local name as a global?!
@Martinj Pieters good catch of str. But what if in some business requirements wants me to do this. I can do this by using other language like Java and C++. You mean python doesn't have anything for this? — dnup10923 mins ago
@MartijnPieters It gets even better -- now he wants Python to support this alleged business requirement. "May be devs will consider to take the good things of others lang."
user559633
I still get a bit starstruck and have a bit of idol worship when answering in a thread alongside Martijn.
Prediction: If he doesn't work for a government, he'll be out of a job soon -- either the business will fail because of stupid requirements like that, or he'll get fired for his egregious misinterpretation.
@vaultah I tested the execution time of the two approaches, which showing the try-catch is slower when exception caught, why? see my answer below — zhangxaochen12 mins ago
def ind(e, L):
L.append(e)
index = L.index(e)
L.pop()
return index
@vaultah Obviously, you wouldn't want to do this if L was being used by a different thread, and also it will have some bad behavior for certain lengths of L. Avoids setting up a try/accept, though. I can't be bothered to time it or think about it any more right now, so if you like it, it's all yours.
Also, I guess del L[-1] might be faster than L.pop()
Ok. I want to parse a stream of bits, they are strings of zeros and ones. my stream could be a very big stream so I use a generator that yields 0x100 bits each time.
I take the chunk and start parsing it, I have a huffman tree and each bit is either a left or a right turn in my tree, until I get to a leaf. I might find myself reaching the end of the chunk before I got to a leaf, this will require a new chunk. I thought about the possibility of using yield to do something like that. It's not optimal so I'll probably do something else, but just out of curiosity, is it something that people do…
Is there anyway I can save some part of the history in an iPython session and automatically include all dependencies for that code as well ? ( imports and functions calls etc... )