api-design

Tweepy - Exclude Retweets

蹲街弑〆低调 提交于 2019-11-30 05:15:54
Ultimate goal is to use the tweepy api search to focus on topics (i.e docker) and to EXCLUDE retweets. I have looked at other threads that mention excluding retweets but they were completely applicable. I have tried to incorporate what I've learned into the code below but I believe the "if not" piece of code is in the wrong place. Any help is greatly appreciated. #!/usr/bin/python import tweepy import csv #Import csv import os # Consumer keys and access tokens, used for OAuth consumer_key = 'MINE' consumer_secret = 'MINE' access_token = 'MINE' access_token_secret = 'MINE' # OAuth process,

Retrofitting void methods to return its argument to facilitate fluency: breaking change?

て烟熏妆下的殇ゞ 提交于 2019-11-30 02:04:55
"API design is like sex: make one mistake and support it for the rest of your life" ( Josh Bloch on twitter ) There are many design mistakes in the Java library. Stack extends Vector ( discussion ), and we can't fix that without causing breakage. We can try to deprecate Integer.getInteger ( discussion ), but it's probably going to stay around forever. Nonetheless, certain kinds of retrofitting can be done without causing breakage. Effective Java 2nd Edition, Item 18: Prefer interfaces to abstract classes : Existing classes can be easily retrofitted to implement a new interface". Examples:

Private class functions vs Functions in unnamed namespace

守給你的承諾、 提交于 2019-11-30 01:13:46
I've found myself that I tend not to have private class functions. If possible, all candidates to private class function rather I put in to unnamed namespace and pass all necessary information as function parameters. I don't have a sound explanation why I'm doing that but at least it looks more naturally to me. As a consequence I need to expose less internal details in the header file. What is your opinion - is it correct practice? In the semi large projects where I usually work (more than 2 million lines of code) I would ban private class functions if I could. The reason being that a private

C# Generics: If T is a return type, can it also be void? How can I combine these interfaces together?

六眼飞鱼酱① 提交于 2019-11-30 00:27:47
问题 I have the following interface that returns the generic parameter of type T using a callback... public interface IDoWork<T> { T DoWork(); } however I also have the following interface as well, but it won't invoke a callback since it returns void. public interface IDoWork { void DoWork(); } Can I combine these two interfaces and use runtime logic to determine the difference? How can I do that? 回答1: Unfortunately, they can't be combined. You can see this in the framework - that's why there is a

API Endpoint Semantics

北城以北 提交于 2019-11-29 19:57:20
Is an API endpoint the 'method', like https://api.foursquare.com/v2/venues/ or the full URL including non-query-string parameters like https://api.foursquare.com/v2/venues/5104 In other words, are these two separate endpoints or considered the same endpoint? http://myapi.com/somemodel/1 http://myapi.com/somemodel/2 According to this Wikipedia article , the endpoint is a web service, defined by a WSDL file, and does nothing more than define the address or connection point to a web service. It is typically represented by a simple HTTP URL string. Microsoft uses the term endpoint in various

When do I define objective-c methods?

泪湿孤枕 提交于 2019-11-29 19:20:34
I'm learning Objective-C, and have a C/C++ background. In object-oriented C++, you always need to declare your method before you define (implement) it, even if it is declared in the parent class. In procedural-style C, IIRC, you can get away with just defining a function so long as it is only called from something else in the same compilational unit (ie. the same file) that came later on in the file (well, provided you don't declare it elsewhere with "extern"). Now, in Objective-C, it appears that you only need to declare selectors in the header file if they are going to be used by something

API design and jQuery [closed]

穿精又带淫゛_ 提交于 2019-11-29 19:05:46
I have often heard that jQuery has made some poor API decisions. Although jQuery is not my favourite library it's the library I've used most often and I find it hard to point out specific mistakes in the API design or how it could have been improved. What parts of jQuery's API could have been done better, how could it have been implemented different and why would that different implementation be better? The question extends to both low level individual details of the API and high level details of the API. We are only talking about flaws in the API rather then flaws in the high level design /

Random high content download time in chrome?

纵然是瞬间 提交于 2019-11-29 03:43:18
We have an API which randomly takes high content download time in chrome, It works fine always in firefox and takes an only few ms . The response size is 20kb uncompressed and 4kb compressed. The same request also works fine using curl. Things that we have tried: Disabling If-None-Match header to disable cache response from the browser. Trying various compressions (gzip, deflate, br). Disabling compression. Disabling all chrome extensions. The same request works fine sometimes on chrome but randomly returns very high content download time. We are unable to understand the root cause of this

Default argument vs overloads in C++

十年热恋 提交于 2019-11-29 03:17:46
For example, instead of void shared_ptr::reset() noexcept; template <typename Y> void shared_ptr::reset(Y* ptr); one may think of template <typename Y = T> void shared_ptr::reset(Y* ptr = nullptr); I think performance difference is negligible here, and the second version is more concise. Is there any specific reason the C++ standard goes the first way? The same question has been asked for the Kotlin language, and default argument is preferred there. Update: std::unique_ptr::reset() follows the default argument design (see here ). So I think the reason std::shared_ptr::reset() uses overloads is

Retrofitting void methods to return its argument to facilitate fluency: breaking change?

偶尔善良 提交于 2019-11-28 23:37:59
问题 "API design is like sex: make one mistake and support it for the rest of your life" (Josh Bloch on twitter) There are many design mistakes in the Java library. Stack extends Vector (discussion), and we can't fix that without causing breakage. We can try to deprecate Integer.getInteger (discussion), but it's probably going to stay around forever. Nonetheless, certain kinds of retrofitting can be done without causing breakage. Effective Java 2nd Edition, Item 18: Prefer interfaces to abstract