most recent 30 from stackoverflow.com 2016-05-25T17:45:43Z http://stackoverflow.com/feeds/ http://www.creativecommons.org/licenses/by-sa/3.0/rdf http://stackoverflow.com/q/37444274 0 Todd Crane http://stackoverflow.com/users/6382540 2016-05-25T17:44:54Z 2016-05-25T17:44:54Z <p>I am having a similar problem to this: <a href="http://stackoverflow.com/questions/11964437/hide-dynamically-added-buttons-based-on-an-if-statement">Hide dynamically added buttons based on an if statement</a>. With a JS mod for A Dark Room I am working on to increase my JS skills. Neither of these snippets are mine, and both are working perfectly.</p> <p>This is the code snippet to create the buttons:</p> <pre><code>build: function(buildBtn) { var thing = $(buildBtn).attr('buildThing'); if($SM.get('game.temperature.value') <= Room.TempEnum.Cold.value) { Notifications.notify(Room, _("builder just shivers")); retu false; } </code></pre> <p>This snippet makes sure that buttons stay visible, but I would like to change it so that when a max value is met the button is hidden.</p> <pre><code>//show button if one has already been built if($SM.get('game.buildings["'+thing+'"]') > 0){ Room.buttons[thing] = true; retu true; } </code></pre> http://stackoverflow.com/q/37444270 0 Yari http://stackoverflow.com/users/6382497 2016-05-25T17:44:43Z 2016-05-25T17:44:43Z <p>There is anybody that can help me with my App? I realized a menu in swift with SWReveal but the Menu doesn't work.. I have problems with the coections in the storyboard. Thanks!</p> http://stackoverflow.com/q/37444269 0 Hsin-yi Berg http://stackoverflow.com/users/6382572 2016-05-25T17:44:42Z 2016-05-25T17:44:42Z <p>As webhook implementer, I retu 409 (resource conflict) when client (webhook user) tries to register a webhook with exact same fields as an existing webhook (name, event types, subscription url, etc). However, I have also seen vendors who reject webhook registration if ONLY subscription url is the same (meaning they require clients to update existing webhook rather than create a new one if the subscription url is the same). So the question is... Are there situations/use cases where different webhooks with same subscription url are required? In which case, 2nd implementation would not be sufficient... Thank you!</p> http://stackoverflow.com/q/37444265 0 Johy Engine http://stackoverflow.com/users/4181681 2016-05-25T17:44:27Z 2016-05-25T17:44:27Z <p>Uploaded a flash ad to my site via Google DFP, an SWF file with HTML5 and static images for fall backs.</p> <p>The client and account rep have raised issue that the ad loads in their browser with a play button, requiring the viewer to click play to start the animation. They say the last guy in my position was able to make it not do that.</p> <p>Is there a way in DFP to ensure the ad will always load and play straight through?</p> http://stackoverflow.com/q/37444264 0 Tim Preston http://stackoverflow.com/users/6382517 2016-05-25T17:44:27Z 2016-05-25T17:44:27Z <p>I'm trying to find a list of users for a specific project (by projectKey) who possess the issueadmin permission. I've found a documented API that gets me pretty close:</p> <pre><code>api/permissions/search_project_permissions </code></pre> <p>but the response that I get back only has summary information: counts of groups/users for each permission type.</p> <p><a href="http://i.stack.imgur.com/cPLYX.png" rel="nofollow">search_project_permissions response</a></p> <p>Does anybody know if there's a way to get to the login details for the users?</p> http://stackoverflow.com/q/37444262 0 Akshay http://stackoverflow.com/users/6382513 2016-05-25T17:44:26Z 2016-05-25T17:44:26Z <h1>The request entity's media type 'multipart/form-data' is not supported for this resource.","ExceptionMessage"unsure emoticon"No MediaTypeFormatter is available to read an object of type 'SmsQueue' from content with media type 'multipart/form-data'.","ExceptionType"unsure emoticon"System.Net.Http.UnsupportedMediaTypeException","StackTrace"unsure emoticon" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable<code>1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable</code>1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"}"</h1> <p>//Prepare you post parameters $postArray = array( 'APIKey' => AUTH_KEY, 'number' => $mobile, 'text' => $message, 'senderid' => SENDER_ID, 'chael' => $chael, 'DCS' => $DCS, 'flashsms' => $flashsms, 'route' => $route</p> <pre><code>); </code></pre> <p>// init the resource</p> <pre><code>$ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postArray //,CURLOPT_FOLLOWLOCATION => true )); //Ignore SSL certificate verification curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //get response $curlOutput = curl_exec($ch); //Print error if any if (curl_ero($ch)) { echo 'error:' . curl_error($ch); } curl_close($ch); </code></pre> http://stackoverflow.com/q/37444263 0 Dice http://stackoverflow.com/users/2203415 2016-05-25T17:44:26Z 2016-05-25T17:44:26Z <p>I got a Samba4 Server ruing on a Debian. I let Linux user expire with the 'chage' command but I can't find a way to do so with the Samba user. The Samba users can still log in when the Linux user has expired.</p> <p>Is there a way to link the expiration from the Linux user to the Samba user? Or a expiration option for Samba user?</p> <p>PS: To add Samba users I use the smbpasswd -a command.</p> <p>Regards</p> http://stackoverflow.com/q/37444161 0 Barryman9000 http://stackoverflow.com/users/197472 2016-05-25T17:39:02Z 2016-05-25T17:44:18Z <p>Windows 10, iPad</p> <p>I'm ruing browsersync and trying to debug an iPad with this command:</p> <p><code>browser-sync start --proxy "www.mysite.com" --host my-ip-address --files /my-directory</code></p> <p>On the iPad I'm accessing the "Exteal Url" listed in the command window. On my desktop machine I can access the browsersync UI and enable things like "CSS Outlining" and the outlines show on the iPad but I'm trying to figure out how to get console errors from the iPad visible on my machine in weinre.</p> <p>The odd thing is I can type <code>alert('hi');</code> into the weinre console on my desktop and it will show the alret on the ipad, but none of the console errors from the ipad are showing on the weinre console.</p> <p>Any suggestions? Is there something better than weinre for debugging an iPad on a Windows machine?</p> <p>Thanks.</p> http://stackoverflow.com/q/37444156 -1 tazo todua http://stackoverflow.com/users/2377343 2016-05-25T17:38:51Z 2016-05-25T17:44:16Z <p>Is there a way to use the found occurrence within patte? i.e.</p> <p><code>$string='number23 cat99 dog23 car66';</code> </p> <p>for example, i want to find words that has number 23.... this doesnt work:</p> <pre><code>preg_match('/number(d{2}) (.*?)%1/si', $string, $new); </code></pre> http://stackoverflow.com/q/37444129 0 MechDog http://stackoverflow.com/users/5551426 2016-05-25T17:37:11Z 2016-05-25T17:44:17Z <p>I have a 'notes' object nested inside multiple other objects, for example 'user'. I want to only add/save a new note if someone has filled out something in the note_text field. I thought I found a way but it stops the saving of the rest of the object as well due to the error.</p> <pre><code>class User < ActiveRecord::Base has_many :notes accepts_nested_attributes_for :notes end class Note < ActiveRecord::Base belongs_to :user before_save :check_for_blank_note def check_for_blank_note if self.note_text.nil? || self.note_text.blank? false else true end end end </code></pre> <p>I was hoping to just stop the save on the notes and let the user be updated and saved.</p> http://stackoverflow.com/q/37444073 0 Vinod http://stackoverflow.com/users/1036903 2016-05-25T17:34:23Z 2016-05-25T17:44:18Z <p>My web project was ruing fine till yesterday however today when I start my tomcat server 7 it fails to start with below error in eclipse:</p> <pre><code>Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/CiscoQA_Automation_Framework]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ... 7 more Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:192) at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:157) at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1577) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInteal(StandardContext.java:5419) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 7 more Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1722) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573) ... 19 more </code></pre> <p>After referring <a href="http://stackoverflow.com/questions/10556201/java-lang-classnotfoundexception-httpservletrequest">here</a> and few other links I have cleaned up WEB-INF/lib and classpath and then added "log4j-web-2.3.jar" and "log4j-1.2.17.jar" in both WEB-INF/lib and class path. I have tried cleaning up the project and tomcat working directory as well nothing worked.</p> http://stackoverflow.com/q/37444006 -1 mati http://stackoverflow.com/users/6382340 2016-05-25T17:31:00Z 2016-05-25T17:44:42Z <p>I'm new to javascript.</p> <pre><code>var x = 5; function f(y) { retu (x + y) - 2}; function g(h) { var x = 7; retu h(x) }; { var x = 10; z = g(f); console.log(z) }; </code></pre> <p>The output is 15 (in f, x is taken to be 10 and y is 7).<br> I did not understand why x took the value from the 4th line and not from the 1st line (and why not the 3rd line).</p> http://stackoverflow.com/q/37443993 0 Daniel Ziga http://stackoverflow.com/users/557419 2016-05-25T17:30:25Z 2016-05-25T17:44:45Z <p>I'm developing a website using React 15.1.0 and I'm experiencing unexpected behavior when creating input elements in my React component.</p> <p>I have a React component which has a Step mechanism where the user fills out a form, goes to the next step, fills out another form etc.</p> <p>I have these steps defined in an array containing objects formed like this:</p> <pre><code>this.steps = [{ stepHeading: 'Step 1', stepDescription: 'Fill out the form part 1', stepFormMarkup: (<div className="row row--highlighted "> <div className="column form"> <fieldset className="forms js-forms forms--columns"> <FormInput id="input_SSC" type="text" required={true} label={this.labels.SSCInputLabel} validation={email} placeholder={this.labels.SSCInputLabel} onChange={this.onEmailChanged} /> </fieldset> </div> </div>) }, { stepHeading: 'Step 2', stepDescription: 'Fill out the form part 2', stepFormMarkup: (<div className="row row--highlighted "> <div className="column form"> <fieldset className="forms js-forms forms--columns"> <FormInput id="input_email" type="text" required={true} label={this.labels.EmailInputLabel} validation={email} placeholder={this.labels.EmailInputPlaceholder} onChange={this.onEmailChanged} /> <FormInput id="input_mobile" type="text" required={false} label={this.labels.MobileInputLabel} validation={phone} placeholder={this.labels.MobileInputPlaceholder} onChange={this.onMobileChanged} /> </fieldset> </div> </div>) }]; </code></pre> <p>I have a button click event that will increase the state property <code>currentStep</code> which then triggers a component update which should then render the markup from the next step in my <code>this.steps</code> array.</p> <p>What happens is that whatever I type into input field from <strong>Step 1</strong> will be auto inserted into the first input field of <strong>Step 2</strong>.</p> <p>I haven't been able to find an explanation anywhere online.<br> Does anyone know if React somehow keeps "state" of the previous instance and mistakes it with the new instance?</p> <p>Here is what my <code>FormInput</code> component looks like:</p> <pre><code>const FormInput = React.createClass({ this.id: 'input_id_missing', propTypes: { label: React.PropTypes.string, placeholder: React.PropTypes.string, type: React.PropTypes.string, validation: React.PropTypes.func, onChange: React.PropTypes.func, required: React.PropTypes.bool }, getInitialState() { retu { validation: {} }; }, handleInputChanged(event) { this.validate(event.target.value); }, validate(value) { let validation = this.props.validation && this.props.validation(value); this.setState({ validation: validation }); if (typeof this.props.onChange === 'function') { this.props.onChange(value, validation); } retu validation; }, render() { retu ( <div className={cx('form__field', { 'form__field--valid': (this.state.receivedInput && this.state.validation.valid), 'form__field--notvalid': (this.state.receivedInput && !this.state.validation.valid), 'form__field--labeled': this.props.label, 'form__field--not-labeled': !this.props.label })}> {this.props.label && (<label className="form__text form__label" htmlFor={this.props.id || this.id}>{this.props.label}</label>)} {this.props.required && (<label className="form__text form__text--error form__label form__label--required" htmlFor={this.props.id || this.id}>( Required )</label>)} <input id={this.props.id || this.id} type={this.props.type || 'text'} placeholder={this.props.placeholder} className="form__input form__text" onChange={this.handleInputChanged}/> </div> ); } }); </code></pre> http://stackoverflow.com/q/37443887 0 pm100 http://stackoverflow.com/users/173397 2016-05-25T17:24:25Z 2016-05-25T17:44:24Z <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/2974519/generic-constraints-where-t-struct-and-where-t-class" dir="ltr">Generic constraints, where T : struct and where T : class</a> <span class="question-originals-answer-count"> 6 answers </span> </li> </ul> </div> <p>I want to create a generic function but I want it to retu T? for value types byte T for reference types. The easy way is to create 2 functions:</p> <pre><code>public T GetRef<T> where T : class public T? GetStruct<T> where T : struct </code></pre> <p>But is there any way to do it so that I can just have one method (or one method name). I tried:</p> <pre><code>public T Get<T> where T : class public T? Get<T> where T : struct </code></pre> <p>but this is not allowed (the <code>where</code> clause is not part of the function signature). I cant imagine how to put the code in one function.</p> http://stackoverflow.com/q/37443752 1 E_J http://stackoverflow.com/users/6338079 2016-05-25T17:16:54Z 2016-05-25T17:44:36Z <p>I know this is basic but i actually don't even know what I've done wrong.</p> <pre><code>while True: try: end=int(input("If You Dont Want To Buy Anything Press 1 To ExitnOr If You Would Like To Try Again Please Press 2")) except ValueError: print("nPlease Enter Only 1 Or 2") if end==1: exit() elif end==2: continue </code></pre> <p>I have literally defined end at the start and yet the error is <code>NameError: name 'end' is not defined</code> I've even tried making end a global. </p> http://stackoverflow.com/q/37443311 0 user2064283 http://stackoverflow.com/users/2064283 2016-05-25T16:52:38Z 2016-05-25T17:44:46Z <p>I'm a begier with PHP Yii Framework 2</p> <p>I'm looking for a way to create a widget in which I could define a new text input with specific features, and use later in my form. </p> <p>I could not find any helpful online guide, someone can give me some help?</p> http://stackoverflow.com/q/37442916 -1 Ezequiel ezzekl Canul http://stackoverflow.com/users/6273192 2016-05-25T16:27:52Z 2016-05-25T17:44:52Z <p>good day I have the following query</p> <pre><code>SELECT G.guid, G.guLastName1, G.guFirstName1, G.guShowD, G.guPRInvit1 as guPR1, GP1.peN as guPR1N, pl.pppo as POST, pl.pppe, pl.pppo FROM Guests G left join Persoel GP1 on GP1.peID = G.guPRInvit1 LEFT JOIN (SELECT TOP 1 a.pppo, a.ppDT, a.pppe FROM PostsLog a where pl.pppe = GP1.peID ) as pl ON (pl.pppe = GP1.peID) --and DATEDIFF(DAY,pl.ppDT,G.guShowD)>=0) WHERE G.guShowD between @datefrom and @DateTo and G.gusr = @SalesRoom </code></pre> <p>the table PostsLog is a log of positions of the table persoel then i need the position of the persoel int the date range </p> <p>but when ruing I get the following error</p> <pre><code>The multi-part identifier "tb1.b" could not be bound. </code></pre> <p>can someone tell me I'm doing wrong. I'm not very good at SQL server and can not find my mistake</p> http://stackoverflow.com/q/37442907 0 user124697 http://stackoverflow.com/users/6382254 2016-05-25T16:27:24Z 2016-05-25T17:44:48Z <p>This is my first question on stack overflow. Recently I want to use <a href="https://github.com/junks/linkedInScraper" rel="nofollow">linked-in-scraper</a>, so I downloaded and instruct "scrapy crawl linkedin.com" and get the below error message. For your information, I use anaconda 2.3.0 and python 2.7.11. All the related packages, including scrapy and six, are updated by pip before executing the program. </p> <pre><code>Traceback (most recent call last): File "/Users/byeongsuyu/anaconda/bin/scrapy", line 11, in <module> sys.exit(execute()) File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/cmdline.py", line 108, in execute settings = get_project_settings() File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/utils/project.py", line 60, in get_project_settings settings.setmodule(settings_module_path, priority='project') File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 285, in setmodule self.set(key, getattr(module, key), priority) File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 260, in set self.attributes[name].set(value, priority) File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 55, in set value = BaseSettings(value, priority=priority) File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 91, in __init__ self.update(values, priority) File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/scrapy/settings/__init__.py", line 317, in update for name, value in six.iteritems(values): File "/Users/byeongsuyu/anaconda/lib/python2.7/site-packages/six.py", line 599, in iteritems retu d.iteritems(**kw) AttributeError: 'list' object has no attribute 'iteritems' </code></pre> <p>I understand that this error stems from d is not the dictionary type but list type. And since the error is from the code on scrapy, maybe it is problem on scrapy package or six package. How can I try to fix this error?</p> http://stackoverflow.com/q/37442548 0 Milad Barai http://stackoverflow.com/users/6377849 2016-05-25T16:10:52Z 2016-05-25T17:44:27Z <p>When i try to encrypt a MD5 hash of a key using AES ECB, And afterwards decrypt it i get diffrent results: </p> <p><strong>Before</strong>: >•ly†lrœËGQ2¶ª€</p> <p><strong>After</strong>: 0¦t‹ d)§¥›B?W</p> <p>The code i use for Encryption and Decryption is:</p> <pre><code>public class AES { private String a= "AES/ECB/NoPadding"; private byte[] key; Cipher c; public AES(byte [] key) throws NoSuchAlgorithmException, NoSuchPaddingException{ this.key = key; c = Cipher.getInstance(a); } public String encrypt(byte[] Data) throws Exception{ Key k = new SecretKeySpec(key, "AES"); c.init(Cipher.ENCRYPT_MODE, k); byte[] encoded = c.doFinal(Data); String encrypted= new String(encoded); retu encrypted; } public String decrypt(byte[] v) throws Exception{ Key k = new SecretKeySpec(key, "AES"); if(v.length%16!=0) retu null; c.init(Cipher.DECRYPT_MODE, k); byte[] decv = c.doFinal(v); String decrypted = new String(decv); retu decrypted; } } </code></pre> http://stackoverflow.com/q/37441604 -2 Steven Kwok http://stackoverflow.com/users/5125027 2016-05-25T15:28:52Z 2016-05-25T17:44:39Z <p>This is the array that is going to be processed: </p> <pre><code>[{:name => "blake"}, {:name => "blake"}, {:name => "ashley"}] </code></pre> <p>and I would like the result to be like this: </p> <pre><code>[{:name => "blake", :count => 2}, {:name => "ashley", :count => 1}] </code></pre> <p>I created a new hash called "count" then i used .each to iterate through the array and then count[:count] += 1 but it's not giving me what I'm looking for.</p> http://stackoverflow.com/q/37441284 0 Pierre D http://stackoverflow.com/users/758174 2016-05-25T15:15:18Z 2016-05-25T17:44:17Z <p>Is there a way to represent an arbitrary time span with a <code>pandas.Period</code>?</p> <p>Specifically, I was trying to contrive a <code>pandas.Period()</code> to represent an arbitrary <em>n</em>-day span (with the goal of making a multi-year <code>Period</code>).</p> <p>I tried a few things, and it seems that playing with the <code>freq</code> argument gets me more or less what I want. However, I was surprised by the unexpected <code>end_time</code> of the period in the case of the <code>freq</code> argument having a multiplier (as in <code>freq='2D'</code>).</p> <pre><code>import pandas as pd p = pd.Period(1970, freq='2D') p # Period('1970-01-01', '2D') p.start_time # Timestamp('1970-01-01 00:00:00') p.end_time # Timestamp('1970-01-04 23:59:59.999999999') p.end_time - p.start_time # Timedelta('3 days 23:59:59.999999') </code></pre> <p>Why? That's 4 days, not 2.</p> <p>However:</p> <pre><code>p+1 # Period('1970-01-03', '2D') (p+1).start_time # Timestamp('1970-01-03 00:00:00') </code></pre> <p>So, <code>(p+1)</code> gives me the expected (a period starting 2 days after <code>p</code>'s start).</p> <p>But what's the deal with <code>end_time</code>? What's the relationship between <code>freq='nD'</code> to actual duration in days?</p> <pre><code>def actual_span(n, unit='D'): p = pd.Period(1970, freq='{}{}'.format(n, unit)) retu p.end_time + pd.Timedelta(1) - p.start_time x = pd.DataFrame({'d': range(1, 10)}) x['span'] = x.n.apply(actual_span) print(x.set_index('n')) # span # n # 1 1 days # 2 4 days # 3 9 days # 4 16 days # 5 25 days # 6 36 days # 7 49 days # 8 64 days # 9 81 days </code></pre> <p>Why is it the square of the requested number of days?</p> <p>Note that <code>(p+1).start_time</code> is correct (gives us <code>n</code> days).</p> <p><sub>Small print: Python 3.51, Pandas <s>0.18.1</s> <em>correction:</em> 0.17.1.</sub></p> http://stackoverflow.com/q/37433955 2 vach http://stackoverflow.com/users/654799 2016-05-25T10:09:10Z 2016-05-25T17:44:15Z <p><code>Proto3</code> is not as strict as <code>Proto2</code>, and there are no <code>required</code> or <code>optional</code> fields, there are no custom <code>default</code> values.</p> <p>Given the following definition...</p> <pre><code>message Order { enum Side { BID = 0; ASK = 1; } int64 time = 1; double price = 2; double volume = 3; Side side = 4; } </code></pre> <p>There are default values for any of those fields, after all now there are no rules of what you must or must not provide before you <code>.build()</code> your object.</p> <p>So the default for <code>time</code> is <code>0</code>, <code>price</code> is <code>0.0</code> and <code>side</code> is <code>BID</code>, if you print an instance where you did not provide one of the fields <strong>or provided the default value</strong> then runtime will treat it as it was never provided in both cases, so its not possible to determine if the value was manually set to <code>BID</code> or it was taken as the default.</p> <p>For example if we execute the following code (its kotlin) </p> <pre><code>Order.newBuilder() .setPrice(1.0) .setVolume(2.0) .setSide(Order.Side.BID) .build() .apply { println(this) } </code></pre> <p>we will have this output</p> <pre><code>price: 1.0 volume: 2.0 </code></pre> <p>at the very least this is aoying as when you print your proto objects using standard <code>.toString()</code> or json printer you'll have this cropped output...</p> <pre><code>{ "price": 1.0, "volume": 2.0 } { "price": 1.0, "volume": 2.0, "side": "ASK" } { "price": 1.0, "volume": 2.0 } { "price": 1.0, "volume": 2.0, "side": "ASK" } </code></pre> <p>But what if your client does not necessarily care about default values and expects all fields to be present?</p> <p><strong>Question : is there a way to change this behaviour? at the very least how do we ensure that if value was set it is being shown?</strong></p> <p>Maybe there is a way to tell <code>protoc</code> to generate different code (affecting defaults behaviour)...</p> http://stackoverflow.com/q/37414663 0 user6376225 http://stackoverflow.com/users/6376225 2016-05-24T13:11:07Z 2016-05-25T17:44:26Z <p>Suppose there is one file.txt in which below content text is written:</p> <pre><code>ABC/xyz ABC/xyz/rst EFG/ghi </code></pre> <p>I need to write a shell script that can extract the first <strong>unique</strong> word before the first <code>/</code>.</p> <p>So as output, I want <code>ABC</code> and <code>EFG</code> to be written in one file.</p> http://stackoverflow.com/q/37414167 0 Nishant http://stackoverflow.com/users/3682549 2016-05-24T12:50:41Z 2016-05-25T17:44:51Z <p>I have the following data:</p> <pre><code>head(df2,20) LAF_Date variable value pos 1 2001-04-03 Net -1470 FALSE 2 2001-04-04 Net -17675 FALSE 3 2001-04-09 Net -13820 FALSE 4 2001-04-10 Net -16885 FALSE 5 2001-04-11 Net -18160 FALSE 6 2001-04-12 Net -19170 FALSE 7 2001-04-16 Net -13715 FALSE 8 2001-04-17 Net -17265 FALSE 9 2001-04-18 Net -11115 FALSE 10 2001-04-19 Net -600 FALSE 11 2001-04-20 Net -11375 FALSE 12 2001-04-23 Net -8200 FALSE 13 2001-04-24 Net -5600 FALSE 14 2001-04-25 Net -5300 FALSE 15 2001-04-26 Net 0 TRUE 16 2001-04-27 Net -110 FALSE 17 2001-04-30 Net 410 TRUE 18 2001-05-02 Net 0 TRUE 19 2001-05-03 Net -4000 FALSE 20 2001-05-04 Net -5750 FALSE </code></pre> <p>My second dataset:</p> <pre><code>ndtl2000 year ndtl oneperc minusoneperc 1 2016-03-30 9327290 93272.90 -93272.90 2 2015-03-30 8533285 85332.85 -85332.85 3 2014-03-30 7705560 77055.60 -77055.60 4 2013-03-30 6750454 67504.54 -67504.54 5 2012-03-30 5909082 59090.82 -59090.82 6 2011-03-30 5207969 52079.69 -52079.69 7 2010-03-30 4492826 44928.26 -44928.26 8 2009-03-30 3834110 38341.10 -38341.10 9 2008-03-30 3196939 31969.39 -31969.39 10 2007-03-30 2611933 26119.33 -26119.33 11 2006-03-30 2109049 21090.49 -21090.49 12 2005-03-30 1700198 17001.98 -17001.98 13 2004-03-30 1504416 15044.16 -15044.16 14 2003-03-30 1280853 12808.53 -12808.53 15 2002-03-30 1103360 11033.60 -11033.60 16 2001-03-30 962618 9626.18 -9626.18 17 2000-03-30 813345 8133.45 -8133.45 </code></pre> <p>I now plot both of these graphs together:</p> <pre><code>p <- ggplot() + geom_line(data = df2, aes(x=LAF_Date, y=value,color = "Net"),size=1.05,stat='identity', position='identity') + labs(color="") + scale_y_continuous(breaks = seq(-300000,500000, by = 100000),labels = comma) + scale_x_date(date_breaks = "3 year",date_labels = "%Y") + xlab('nYear') + ylab('Rs C') + labs(caption="Source:Data from RBI Website") + ggtitle("LAF Net Injections (+)/Absorption(-) in Rs C") + theme(plot.title = element_text(face="bold",size = 10,hjust = 0.5)) + theme(axis.text.x=element_text(size=7, color = "black")) + theme(axis.text.y=element_text(size=9, color = "black")) + theme( axis.title.x = element_text(vjust=-0.70,size=9), axis.title.y = element_text(vjust=0.55,size=9)) + theme(panel.background = element_rect(fill = "#fbfefe")) + theme(plot.background = element_rect(fill="#e0edbd" )) + theme(panel.grid.minor = element_line(colour = "black", linetype = "dotted",size = 0.3)) + theme(plot.caption=element_text(size=8, hjust=1.0, margin=margin(t=10))) + geom_line(data = ndtl2000, aes(x=year, y=oneperc, color = "oneperc"),size=1.05) + geom_line(data = ndtl2000, aes(x=year, y=minusoneperc, color = "minusoneperc"),size=1.05) + scale_y_continuous(breaks = seq(-300000,500000, by = 100000),labels = comma) + scale_x_date(date_breaks = "3 year",date_labels = "%Y") + labs(color="") + xlab('nYear') + ylab('Net LAF(Rs Cr)n') + labs(caption="Source:Data from RBI Website") + theme(plot.title = element_text(face="bold",size = 10,hjust = 0.5)) + theme(axis.text.x=element_text(size=7, color = "black")) + theme(axis.text.y=element_text(size=9, color = "black")) + theme( axis.title.x = element_text(vjust=-0.70,size=9), axis.title.y = element_text(vjust=0.55,size=9)) + theme(panel.background = element_rect(fill = "#fbfefe")) + theme(plot.background = element_rect(fill="#e0edbd" )) + theme(panel.grid.minor = element_line(colour = "black", linetype = "dotted",size = 0.3)) + theme(plot.caption=element_text(size=8, hjust=1.0, margin=margin(t=10))) + scale_color_discrete(name="",breaks=c("oneperc","minusoneperc"),labels=c("+1% of NDTL","-1% of NDTL")) + geom_hline(yintercept=0,color="black",size=0.7) p </code></pre> <p><a href="http://i.stack.imgur.com/uINso.png" rel="nofollow"><img src="http://i.stack.imgur.com/uINso.png" alt="enter image description here"></a></p> <p>I get the following beautiful plot. But to convey more info, what i would like to have is the negative values from df2 data to be shown in say red (values below 0 line) and positive values in say green.I did create a logical column in df2 having TRUE/FALSE values but i am unable to get the different colors....</p> <p>need help here....</p> http://stackoverflow.com/q/37412746 0 MyFault http://stackoverflow.com/users/4366529 2016-05-24T11:51:42Z 2016-05-25T17:44:26Z <p>I would like to configure PhpStorm this way:</p> <p><code>If/Else</code>Blocks in PHP code should be separated with a blank line.</p> <p>Example:</p> <pre><code><?php $hello = true; if($hello) { echo "Hello"; } else { echo "Bye"; } echo "...my friend"; ?> </code></pre> <p>should become</p> <pre><code><?php $hello = true; if($hello) { echo "Hello"; } else { echo "Bye"; } echo "...my friend"; ?> </code></pre> <p>I did not find any information about that in the JetBrains documentation.</p> <p>Any idea how to get this working?</p> http://stackoverflow.com/q/37404355 0 Kegan http://stackoverflow.com/users/6374025 2016-05-24T04:23:05Z 2016-05-25T17:44:15Z <p>thanks for helping in advance!</p> <p>I'm new to rails, and have been trying to follow this guide: <a href="https://www.youtube.com/watch?v=tyNepRO_ERc&feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=tyNepRO_ERc&feature=youtu.be</a></p> <p>I've implemented ActionCable in the past before school got busy, and not without some trouble then--and now it is causing me trouble yet again. I reach 17:00mins in that video with no problem, and everything makes sense--however when I send in the command it does not bring up any message. </p> <p>So, what I do see:</p> <p>"hello world" is showing up, but not any given input (not even upon reloading the page)</p> <p><strong>First in my terminal:</strong></p> <p>Started GET "/cable" for ::1 at 2016-05-23 21:45:00 -0600</p> <p>Started GET "/cable/" [WebSocket] for ::1 at 2016-05-23 21:45:00 -0600</p> <p>Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)</p> <p>RoomChael is transmitting the subscription confirmation</p> <p>RoomChael is streaming from room_chael</p> <p>RoomChael#speak({"message"=>"Travis: Neat!"})</p> <p>[ActionCable] Broadcasting to room_chael: "Travis: Neat!"</p> <p>RoomChael transmitting "Travis: Neat!" (via streamed from room_chael)</p> <p><strong>Web Console:</strong></p> <p>App.room.speak('Travis: Neat!')</p> <p>true</p> <p>I could post some code, I should post some code, but I am fairly sure that all of my code follows the video. I'll be sorting through it for awhile still, I'm just more looking for any tips/insight/help for other ideas/things to check. I've had a similar problem before in my previous attempts of implementing ActionCable, where the messages will even be sent in and processed, but not showing up until reloading the web page. </p> <p>Thank you for any help,</p> <p>... okay, I guess I better put some code first:</p> <p>javascripts/chaels/room.coffee</p> <pre><code>App.room = App.cable.subscriptions.create "RoomChael", # Called when the subscription is ready for use on the server coected: -> # Called when the subscription has been terminated by the server discoected: -> # Called when there's incoming data on the websocket for this chael received: (data) -> $('#messages').append "<div>#{data}</div>" speak: (message) -> @perform 'speak', message: message </code></pre> <p>javascripts/cable.coffee</p> <pre><code>#= require action_cable #= require_self #= require_tree ./chaels # @App ||= {} App.cable = ActionCable.createConsumer() </code></pre> <p>chaels/room_chael.rb</p> <pre><code>class RoomChael < ApplicationCable::Chael def subscribed stream_from "room_chael" end def unsubscribed # Any cleanup needed when chael is unsubscribed end def speak(data) ActionCable.server.broadcast 'room_chael', data['message'] end end </code></pre> <p>/controllers/rooms_controller.rb</p> <pre><code>class RoomsController < ApplicationController def show @messages = Message.all end end </code></pre> <p>/models/message.rb</p> <pre><code>class Message < ApplicationRecord after_create_commit { BroadcastMessageJob.perform_later self } end </code></pre> <p>/views/messages/_message.html.erb</p> <pre><code><p> <%= message.content %> </p> </code></pre> <p>/views/rooms/show.html.erb</p> <pre><code><h1>ActionCable Chat</h1> <%= render @messages %> </code></pre> <p>/config/environments/development.rb (Here I have inserted this line, which actually fixed the problem for me last time I tried using ActionCable months ago)</p> <pre><code>ActionCable.server.config.disable_request_forgery_protection = true </code></pre> <p>/config/cable.yml</p> <pre><code>production: adapter: redis url: redis://localhost:6379/1 </code></pre> <p>/config/database.yml</p> <pre><code>default: &default adapter: postgresql encoding: unicode pool: 5 timeout: 5000 development: <<: *default database: [InsertNameOfMyAppHere]_development </code></pre> <p>Honestly, I know, my Gemfile is a mess:</p> <pre><code> ruby '2.3.1' source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails','>= 5.0.0.rc1' gem 'pg' # Use sqlite3 as the database for Active Record #gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.1' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Unico as the app server # gem 'unico' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application ruing in the background. Read more: https://github.com/rails/spring gem 'spring' end gem 'devise', '>= 4.0.0.rc1' gem 'sass', '~> 3.4', '>= 3.4.20' gem 'acts_as_votable', '~> 0.10.0' #Idea/discussions: gem 'simple_form', '~> 3.2', '>= 3.2.1' gem 'puma' gem 'actioncable', '~> 5.0.0.rc1' gem 'therubyracer' gem 'execjs' gem 'record_tag_helper' gem 'redis' </code></pre> <p>My terminal upon starting the server</p> <pre><code>Array values in the parameter to `Gem.paths=` are deprecated. Please use a String or nil. An Array ({"GEM_PATH"=>["/Users/Kegan/.rvm/gems/ruby-2.3.1", "/Users/Kegan/.rvm/gems/ruby-2.3.1@global"]}) was passed in from bin/rails:3:in `load' => Booting Puma => Rails 5.0.0.rc1 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options [Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration. Puma starting in single mode... * Version 3.4.0 (ruby 2.3.1-p112), codename: * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://localhost:3000 Use Ctrl-C to stop </code></pre> <p>[In response to Graham Slick]</p> <p>App.room.speak(‘Does This Work?’) true</p> <p>———————————————————————</p> <p>Does This Work?</p> <p>———————————————————————</p> <p>Added Code: (Javascripts/chaels/room.coffee)</p> <pre><code> received: (data) -> console.log(data) $('#messages').append "<div>#{data}</div>" </code></pre> http://stackoverflow.com/q/37324975 6 Marco Zanetti http://stackoverflow.com/users/1197548 2016-05-19T13:39:26Z 2016-05-25T17:44:26Z <p>my issue is quite similar to <a href="http://stackoverflow.com/questions/37317295/missing-api-key-current-key-with-google-services-3-0-0">Missing api_key/current key with Google Services 3.0.0</a> but with a further level of complexity.</p> <p>I updated my app this moing to com.google.gms:google-services:3.0.0 and all the play-services 9.0.0 dependencies</p> <pre><code>compile 'com.google.android.gms:play-services-analytics:9.0.0' compile 'com.google.android.gms:play-services-ads:9.0.0' compile 'com.google.android.gms:play-services-identity:9.0.0' compile 'com.google.android.gms:play-services-gcm:9.0.0' </code></pre> <p>Now I get the infamous error </p> <blockquote> <p>Error:Execution failed for task ':hotelsclick:processDebugGoogleServices'. > Missing api_key/current_key object</p> </blockquote> <p>This seems to be due to a missing API key in the google-services.json file (so I was told). I got a new API key from <a href="https://developers.google.com/cloud-messaging/android/client#get-config">https://developers.google.com/cloud-messaging/android/client#get-config</a> and found the following field in it.</p> <pre><code> "api_key": [], </code></pre> <p>I guess I should put my Google Maps API key in there, but here it comes the double issue I'm experiencing:</p> <p>1- if I try and put the key inside that field, it doesn't work. I tried with both</p> <pre><code> "api_key": [{ "current_key": "AIzaSyBll61Ij0Swz1mbGz4rZzxquSacbHIt-AE" }], </code></pre> <p>and</p> <pre><code> "api_key": ["AIzaSyBll61Ij0Swz1mbGz4rZzxquSacbHIt-AE"], </code></pre> <p>the error remains the same.</p> <p>2- I've been using gradle in order to use dynamic building. I put the following in my module build.gradle:</p> <pre><code>buildTypes { release { minifyEnabled true shrinkResources true debuggable false resValue "string", "google_maps_api_key", "ABCDEFGHILMNO... my maps release API key" proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' zipAlignEnabled true } debug { resValue "string", "google_maps_api_key", "ZNTMRNCDNR... my google maps debug API key" debuggable true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } </code></pre> <p>In the Androidmanifest.xml file I have</p> <pre><code> <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_api_key" /> </code></pre> <p>Now, it's always been working until I updated to Google Services 3.0.0, I don't get why it doesn't work now. Shouldn't it grab the right API key from the compiled build.gradle file and put it in the manifest?</p> <p>So my double question is: why doesn't the dynamic API key fetching work anymore? And how can I fix this?</p> <p>Thank you</p> http://stackoverflow.com/q/36907767 4 Sebastian Kim http://stackoverflow.com/users/6249678 2016-04-28T07:14:04Z 2016-05-25T17:44:44Z <p>I'm getting "NSURLErrorDomain Code=-1004" error with Alamofire API calls, but <strong>only for few seconds after app started</strong> (or took a rest for few minutes while the app's opened and make a call after that)</p> <p>If I try to make the same call after few seconds, everything works fine. I searched all the Stack Overflow questions and checked all the possible causes below:</p> <ol> <li>No problem with Inteet coection</li> <li>"App Transport Security Settings" are correct and server's using https (I also tried "NSAllowsArbitraryLoads=true" but that didn't help)</li> <li>APIs working fine</li> </ol> <p>My gut feeling is that getting the network settings takes few seconds and when I make an API call before that's done, it just fails immediately. OR.. I'm using a Websocket in background that could be related?</p> <blockquote> <p>FAILURE: Error Domain=NSURLErrorDomain Code=-1004 "Could not coect to the server." UserInfo={NSUnderlyingError=0x137d39380 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x100201bb341a9f540000000000000000}, _kCFStreamErrorCodeKey=-2200, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=[FILTERED], NSErrorFailingURLKey=[FILTERED], _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2200, NSLocalizedDescription=Could not coect to the server.}</p> </blockquote> <p>Any suggestions?</p> <p><strong><em>UPDATED</em></strong></p> <p>Found that app makes 4 requests on launch, and 1 or 2 of them randomly fails, and I checked Nginx access and error log and there's no log for the failed calls at all.</p> http://stackoverflow.com/q/36666313 0 smileynor http://stackoverflow.com/users/5816362 2016-04-16T15:49:14Z 2016-05-25T17:44:16Z <p>Hi I'm new to GUI programming, so after trying PyQt for a short time I found Enaml which made the production much more easy. </p> <p>I'm trying to have a widget that can change the value of a datetime.datetime object or a datetime.time object, but it tus out they are read-only. So how could I do that? Can I change the variable to have read-and-write attributes, or maybe need a setter?</p> <p>My minimum working solution is:</p> <pre><code>from __future__ import print_function import datetime import os from atom.api import Atom, Unicode, Range, Typed, observe, Value, Bool class SimulationCase(Atom): startDateTime = datetime.datetime.strptime('05.03.2015-5','%d.%m.%Y-%H') currentDateTime = startDateTime endDateTime = startDateTime+ datetime.timedelta(days=int(5)) incrementTime = datetime.time(1,0,0) def main(): case = SimulationCase() print(case.currentDateTime) a = datetime.time(1,0,0) print(a) #This is where the problem occures, comment out the line under for a working solution. case.incrementTime = a if __name__ == '__main__': main() </code></pre> http://stackoverflow.com/q/16758353 2 Moolla http://stackoverflow.com/users/2017523 2013-05-26T10:32:29Z 2016-05-25T17:44:55Z <p>Is there a way to <code>slice</code> through a whole list while excluding a range of values or multiple range of values in the middle of the list?<br> For example: </p> <pre><code>list = [1,2,3,4,5,6,7,8,9,0] print list[......] #some code inside </code></pre> <p>I'd like the above code to print the list while excluding a range of values so the output would be: <code>[1,2,3,8,9,0]</code> or excluding multiple value ranges so the output would be: <code>[1,2,6,7,0]</code> by using the slice notation or any other simple method you can suggest.</p>
برچسب:
نویسنده: استخدام کار