implementation

How would I implement a ranking algorithm in my website to sort database data?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 05:54:11
问题 I want to implement a ranking system on a website I've been working on and have decided to go with the Hacker News algorithm. My reasoning for choosing this algorithm is simply because it's been described here. I was looking at this Python code (the language I'm using to build my site) and couldn't figure out how I would implement it. def calculate_score(votes, item_hour_age, gravity=1.8): return (votes - 1) / pow((item_hour_age+2), gravity) Given the tables: posts: id | title | time

Automating a Job at Work: Importing Powerpoint Bullet Text into an Excel Sheet

人盡茶涼 提交于 2019-12-06 05:43:36
问题 I have been asked to automate a particular task at work today which takes up a lot of our time! The following is what needs to be done and I would appreciate any help on how I can do this (Implementation Advice) within the realms of my knowledge, if possible. Problem I have a PowerPoint document (.ppt). I would like to extract text from there (the text is in bullet point format). I would like to insert these bullets points into an Excel sheet, each bullet point should be a row. I would also

Clarity in classes implementing multiple interfaces (alternative to delegation):

独自空忆成欢 提交于 2019-12-06 05:00:27
问题 Let's say we've got the following: IFirst = Interface(IUnknown) function GetStuff: Integer; end; ISecond = Interface(IUnknown) function GetOtherStuff: Integer; end; TFirstSecond = class(TInterfacedObject, IFirst, ISecond) private function GetStuff: Integer; //implementation of IFirst function GetOtherStuff: Integer; //implementation of ISecond; end; I have never liked the fact that in TInterfacedObject there seems to be no way to distinguish between which methods implement which interfaces.

Implement stack (push, pop and findmin) in O(1)

痞子三分冷 提交于 2019-12-06 01:15:34
I have already seen two stack implementation of this question but I am really confused as how one could get O(1) operation. consider following example: S1[3542761986759] S2[3332221111111] The idea/algorithm here is Push element E on S1 Check to see if top of S2 >= E and if true, insert E on S2 But when getMin is called, we return top of S2 but that leaves S2 in weird state as S2 contains repeated current min elements, so the solution is to search next minimum element in S2 and return it. This is O(n). Can anyone please help me to understand the solution? Using a linked list store the current

Which Erlang implementation of OpenId should I use, if any?

天大地大妈咪最大 提交于 2019-12-05 23:14:32
问题 I'd need an Erlang implementation of the OpenId protocol. I found the following, but it seems to be a project on its early stage. http://code.google.com/p/erlopenid/ Any hint or suggestion on what should I use? 回答1: I finally found all the existing Erlang implementations for OpenID thanks to the following search engine for Erlang projects: http://projects.trapexit.org/web/ Here are the results: http://github.com/etnt/eopenid http://github.com/brendonh/erl_openid http://github.com/pib

python parent class 'wrapping' child-class methods

Deadly 提交于 2019-12-05 22:45:28
问题 I have the following situation in my python code: class Parent(object): def run(self): print "preparing for run" self.runImpl() print "run done" class Child(Parent): def runImpl(self): print "child running" However, I have several such 'decorators', doing different setup/teardown steps before and after 'runImpl', and I don't like having to define run() , runImpl() , runImplSingleProcess() etc. I am looking for a solution of the following form: class Parent(object): @wrapping_child_call def

Can i create an android application as template?

我只是一个虾纸丫 提交于 2019-12-05 20:07:57
I'm not sure if its the right title but ill explain what i mean. I'm making more than one android application, but they have the same structure sliding menu , list view , about me , costume dialog with (copy,share,like) with some modifications in the styles (colors, backgrounds , fonts , menu strings ) my qustion is : is there any way to use the structure as library or implemntation or anu other way insted of coping the same codes in every projects ? Basically what you want to do is to create an Android library . Just develop it like a normal application, with Activities and layout . Please

Is an OutputStream in Java blocking? (Sockets)

不问归期 提交于 2019-12-05 18:15:32
问题 I am currently writing naive network code for a project and a mate hinted me at the possibility that when I send a package of information from the server to all clients in an iterative fashion I might get intense lag when one of the clients is not responding properly. He is reknown for trolling so I was kind of sceptical when implementing a secondary thread that is now responsible to send data over to a client, having a queue that the Server simply adds the packages over that is then read by

Do other operating systems implement the Linux system call splice?

半城伤御伤魂 提交于 2019-12-05 12:10:56
In an application I am developing I use splice on Linux for socket-to-socket data transfer. Do other operating systems (specifically at least Windows, OS X and FreeBSD) implement splice or an equivalent solution? Is it possible to imitate socket-to-socket data splice ing on Windows with sendfile ¹ + memmap ¹? ¹ Both exist on Windows under different names which I do not remember. Update You can see the performance improvements of splice vs user space buffers on Linux. DF , DR , F , MF , MR are my application in its different tunneling modes, NX is NGINX web server -p+t uses the Linux system

floor()/int() function implementaton

僤鯓⒐⒋嵵緔 提交于 2019-12-05 09:03:27
Does anyone have an idea how is the method/function Int() or floor() implemented? What I am looking for a respective implementation as the following is for abs() function. Int Abs (float x){ if x > 0 return x; else return -x } I am struggling to find a solution for it without using the modulus operator. TheJubilex Seems to me like floor(n) = n - (n % 1) should do the trick. Using the IEEE 754 binary floating point representation one possible solution is: float myFloor(float x) { if (x == 0.0) return 0; union { float input; // assumes sizeof(float) == sizeof(int) int output; } data; data.input