pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
678,259
0
How Does a Login system generally work with OOP? <p>Sorry if this is a badly formed question, but I'm trying to make my web applications (using PHP) more OO. *EDIT* I'm developing the Framework myself */EDIT* Everything is great so far, I've made a Front Controller system that taps into a MVC system. The FC figures out what page you want, loads the specific page Controller (*EDIT* which extends an abstract Controller Object */EDIT*), which gets anything it needs from Models, and then calls the appropriate View. Very basic.</p> <p>But now, I need to make an admin section (quasi-CMS). How does a login system fit into the grand scheme of things? Do you set controllers as needing a login? If so, how? What If you only want certain views of a controller requiring login?</p> <p>Thanks in advance.</p>
24,508,719
0
<pre><code>var d1 = new Date('2014-06-14 18:19:33').getTime(); var d2 = new Date('2014-07-01 13:00:22').getTime(); var d = d1 - d2; var result = d / 1000 / 60; </code></pre>
28,943,159
0
<p>If you are trying it on same field you can try to build the query like this replace the 'reference' with your field name</p> <p>reference:TSP AND reference:LAE AND NOT reference:N133</p> <p>and for different fields with other combinations</p> <ol> <li><p>reference:TSP AND name:Test AND NOT metadata:Superseded</p></li> <li><p>reference:(TSP AND LAE) AND name:Test AND NOT metadata:Superseded</p></li> <li><p>reference:(TSP AND LAE) AND name:(Test OR Wheel) AND NOT metadata:Superseded</p></li> <li><p>reference:(TSP AND LAE) OR name:(Test OR Wheel) AND NOT metadata:Superseded</p></li> <li><p>reference:(TSP AND LAE) OR name:(Test AND Wheel) AND NOT metadata:Superseded</p></li> </ol>
35,327,515
0
Can gradle script property extensions be shared between different scripts <p>If there is a build.gradle file as follows:</p> <pre><code>... apply from: 'Other.gradle' task hello { project.ext.hello = "hello" } </code></pre> <p>And Other.gradle has:</p> <pre><code>task getHello { println project.ext.hello } </code></pre> <p>I get an error saying:</p> <blockquote> <p>Cannot get property 'hello' on extra properties extension as it does not exist</p> </blockquote> <p>Is there a way to share property extensions between the scripts?</p>
1,740,297
0
How do I build a DNS Query record in Erlang? <p>I am building a native Bonjour / Zeroconf library and need to build DNS query records to broadcast off to the other machines. I have tried looking thru the Erlang source code but as I am relatively new to Erlang it gets kind of dense down the bowels of all the inet_XXX.erl and .hrl files. I have a listener that works for receiving and parsing the DNS record payloads, I just can't figure out how to create the query records. What I really need to know is what I need to pass into inet_dns:encode() to get a binary I can send out. Here is what I am trying to do.</p> <pre><code>{ok,P} = inet_dns:encode(#dns_query{domain="_daap._tcp.local",type=ptr,class=in}) </code></pre> <p>here is the error I am getting</p> <pre><code>10&gt; test:send(). ** exception error: {badrecord,dns_rec} in function inet_dns:encode/1 in call from test:send/0 11&gt; </code></pre>
3,860,099
0
<p>Of course you will, Microsoft China was in a similar situation back when their Juku Blogging Service was found out to be a rip-off of Plurk, and yes, line by line code copying.</p> <p>Microsoft responded with: <em>“Microsoft takes intellectual property seriously, and we are currently investigating these allegations. It may take some time due to the time zone differences with Beijing.”</em> when they were asked about it.</p> <p><a href="http://techcrunch.com/2009/12/14/microsoft-plurk-ripoff/" rel="nofollow">Here's a link to that article I was referring to.</a></p>
3,715,243
0
<p>Your best bet (I'm aware of) is to dig into the code in the django code, and see how it's done there. As I recall, they generate a salted hash so that the plain text values are never stored anywhere, but rather the hash and salt are. </p> <p>If you go into the django installation, and poke around for words like hash and salt, you should find it pretty quickly. Sorry for the vague answer, but perhaps it will set you on the right path.</p>
2,120,710
0
<p>I figured it out. Its because I was adding my list of data to itself so it had a bunch of duplicate data and it didnt like that.</p>
26,686,032
0
<p>The optimisation that would be nice is if on <code>Skip(k)</code> the first <code>.MoveNext</code> just sets the internal index to <code>k</code>, and I thought the JITter could do this, but it seems not to, for the versions I've tried.</p> <p>The code to be optimised is:</p> <pre><code>while (count &gt; 0 &amp;&amp; e.MoveNext()) count--; </code></pre> <p>from <a href="http://referencesource.microsoft.com/System.Core/System/Linq/Enumerable.cs.html#83ec6a20321060a1" rel="nofollow">SkipIterator</a> and:</p> <pre><code> public bool MoveNext() { if (_index &lt; _endIndex) { _index++; return (_index &lt; _endIndex); } return false; } </code></pre> <p>from <a href="http://referencesource.microsoft.com/mscorlib/system/array.cs.html#4864727bda517629" rel="nofollow">SZGenericArrayEnumerator</a>.</p> <p>(The reference source is 4.5.1, but reflector shows very similar code in 4.0.)</p>
3,907,921
0
Why java doesn't allow to make an instance method of parent class as more restrictive in child class <p>Polymorphism allows the programmer either to inherit, override or to overload an instance method of Parent Class. </p> <p>But, it won't allow to make an instance method of parent class as more restrictive in child class. i.e it wont allow to use same name of parent class instance method, to declare as private in the child class.</p> <p>Also JVM identifies the parent class version of an instance method, if child class didn't override it.</p> <p>Similarly why don't JVM identifies the parent class version of an instance method, if the child class makes it more restrictive?</p> <p>The more restrictive method of parent class in child class can be considered as child class specific method instead of overridden method by compiler.</p>
29,344,936
0
<p>Give the element an id. </p> <p>For example</p> <pre><code>&lt;td id="titleId" title="He is from KL working in Assyst at Kochi.Today Ind vs Aus match 2nd semi final Aus won the game India Lost"&gt;He is from....&lt;/td&gt; #titleId { background-color: #efefef; padding: 10px; color: red; border: 1px solid blue; text-align: justify; } </code></pre>
1,652,928
0
<p>It sounds like what you want is a <a href="http://en.wikipedia.org/wiki/Finite-state_machine" rel="nofollow noreferrer">'Finite State Machine'</a> where using those cases you can activate different processes or 'states'. In C this is usually done with an array (matrix) of function pointers.</p> <p>So you essentially make an array and put the right function pointers at the right indicies and then you use your 'var' as an index to the right 'process' and then you call it. You can do this in most languages. That way different inputs to the machine activate different processes and bring it to different states. This is very useful for numerous applications; I myself use it all of the time in MCU development.</p> <p>Edit: Valya pointed out that I probably should show a basic model:</p> <pre><code>stateMachine[var1][var2](); // calls the right 'process' for input var1, var2 </code></pre>
36,729,409
0
Importing EndNote .enl file into R Dataframe <p>I would appreciate it if someone can help me import <a href="https://www.dur.ac.uk/resources/its/info/guides/files/endnote/PALEO~1.ENL" rel="nofollow">this EndNote .enl file</a> into R Dataframe.</p>
4,212,279
0
<p>you can run this query and get all the sql queries that you need to run; </p> <pre><code>select concat( 'drop table ', a.table_name, ';' ) from information_schema.tables a where a.table_name like 'dynamic_%'; </code></pre> <p>you can insert it to file like</p> <pre><code>INTO OUTFILE '/tmp/delete.sql'; </code></pre> <h1>update according to alexandre comment</h1> <pre><code>SET @v = ( select concat( 'drop table ', group_concat(a.table_name)) from information_schema.tables a where a.table_name like 'dynamic_%' AND a.table_schema = DATABASE() ;); PREPARE s FROM @v; EXECUTE s; </code></pre>
6,257,440
0
<p>In general, <strong>Complexity can be reduced by abstracting your repetitive code into reusable, easily-maintainable components</strong>. </p> <p>In your particular case, the complexity can be reduced by <strong>implementing the <a href="http://www.codeinsanity.com/2008/08/repository-pattern.html" rel="nofollow">Repository</a> and <a href="http://devlicio.us/blogs/jeff_perrin/archive/2006/12/13/the-specification-pattern.aspx" rel="nofollow">Specification</a> patterns</strong> to make your code more consistent, easier to read, and easier to maintain. </p> <p>There is a very helpful sequence of articles by Huy Nhuyen explaining the repository pattern, the specification pattern and how to effectively combine them with the Entity Framework for better code. These are available at:</p> <ul> <li><a href="http://huyrua.wordpress.com/2010/07/13/entity-framework-4-poco-repository-and-specification-pattern/" rel="nofollow">Entity Framework 4 POCO, Repository and Specification Pattern</a></li> <li><a href="http://huyrua.wordpress.com/2010/08/25/specification-pattern-in-entity-framework-4-revisited/" rel="nofollow">Specification Pattern In Entity Framework 4 Revisited</a></li> <li><a href="http://huyrua.wordpress.com/2010/12/16/entity-framework-4-poco-repository-and-specification-pattern-upgraded-to-ctp5/" rel="nofollow">Entity Framework 4 POCO, Repository and Specification Pattern [Upgraded to CTP5]</a></li> <li><a href="http://huyrua.wordpress.com/2011/04/13/entity-framework-4-poco-repository-and-specification-pattern-upgraded-to-ef-4-1/" rel="nofollow">Entity Framework 4 POCO, Repository and Specification Pattern [Upgraded to EF 4.1]</a></li> </ul>
14,384,364
0
<p>That doesn't "guarantee" a result from <a href="http://linux.die.net/man/3/malloc" rel="nofollow"><code>malloc()</code></a>. If malloc returns <code>NULL</code> there's probably a reason for it (out of memory for example). And you might throw yourself into an infinite loop.</p> <p>Furthermore, if you're running this on a Linux platform:</p> <blockquote> <p>By default, Linux follows an optimistic memory allocation strategy. This means that when malloc() returns non-NULL there is no guarantee that the memory really is available.</p> </blockquote> <p>That means that lets say calling malloc over and over again did happen to return something non-NULL, due to Linux's "optimistic" strategy, a non-NULL still doesn't guarantee you got anything that will work.</p> <p>I think this code is setting you up for a debugging nightmare.</p>
5,688,578
0
<p>Because flash[] is an array you could delete element inside it. When we use recaptcha gem, the flash array contain <strong>recaptcha_error</strong> element, so you just only delete this element with : <strong>flash.delete(:recaptcha_error)</strong> inside your controller.</p> <p>For example :</p> <pre><code>if verify_recaptcha(:model=&gt;@object,:message=&gt;"Verification code is wrong", :attribute=&gt;"verification code") &amp;&amp; @object.save #your code if succes else flash.delete(:recaptcha_error) #your code if its fail end </code></pre> <p>Maybe it could help you. Thanks</p>
14,442,051
0
<p>You can do something like : </p> <pre class="lang-dart prettyprint-override"><code>class MenuItemCollection implements List&lt;MenuItem&gt; { final _list = new List&lt;MenuItem&gt;(); MenuItemCollection(); noSuchMethod(InvocationMirror invocation) =&gt; invocation.invokeOn(_list); } </code></pre>
803,112
0
Max DB size in SQL Server 2000 MSDE <p>We are currently evaluation our hosting options and the cheapest suitable option we've found only has SQL Server 2000 MSDE as the db server.</p> <p>What is the max size of a db on the server? Is there a max total size for dbs combined?</p>
21,257,299
0
<pre><code>update your code with this. &lt;filter name="groupby_order" icon="terp-gtk-jump-to-rtl" string="Order Reference" domain="[]" context="{'group_by' :'order_id'}"/&gt; and pass &lt;field name="context"&gt;{'search_default_groupby_order': 1}&lt;/field&gt; in act_window. Hope this will be useful to you. </code></pre>
14,532,232
0
Rails : get authenticity token from inside a controller <p>I need to do a POST to another controller from inside a prior controller, how do I get the value for the authenticity_token from inside a controller?</p> <p>TY, Fred</p>
28,994,884
0
<p>Once you get your DOM element, which I am assuming is what "el" is, you can simply use the getElementsByTagName() method to get the anchors. This will return an array of elements matching the tagname supplied. </p> <p>In your case it would be:</p> <pre><code>var anchors = el.getElementsByTagName('a'); </code></pre> <p>An example: <a href="http://jsfiddle.net/d3fs7g05/1/" rel="nofollow">http://jsfiddle.net/d3fs7g05/1/</a></p>
27,533,223
0
<p>Since you reported that it was running when <code>len(nextList) == 0</code>, this is probably because <code>nextList</code> (which isn't a list..) is an empty bytes object which isn't equal to an empty string object:</p> <pre><code>&gt;&gt;&gt; b"" == "" False </code></pre> <p>and so the condition in your line</p> <pre><code>while nextList != "": </code></pre> <p>is never true, even when <code>nextList</code> is empty. That's why using <code>len(nextList) != 22</code> as a break condition worked, and even</p> <pre><code>while nextList: </code></pre> <p>should suffice.</p>
37,580,293
0
Jquery : Product between 2 lists of inputs into a 3rd list <p>I don't have much experience in jQuery, I'm facing the following challenge</p> <p>I have the following table</p> <pre><code>&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;Qty&lt;/td&gt; &lt;td&gt;Description&lt;/td&gt; &lt;td&gt;Unit Price&lt;/td&gt; &lt;td&gt;Total Price&lt;/td&gt; &lt;tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr id="itemRow"&gt; &lt;td&gt;&lt;input type="text" name="quantity"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="description"/&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="unitPrice"/&gt;/td&gt; &lt;td&gt;&lt;input type="text" name="totalPrice"/&gt;&lt;/td&gt; &lt;tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;input type="text" name="total"/&gt; </code></pre> <p>Additionally, I'm able to clone #itemRow as many times as required, enlarging the amount of items.</p> <p>The idea is to calculate the total price for each row (by <code>quantity</code> * <code>unitPrice</code>) and assign it to <code>totalPrice</code>. And assign the sum of <code>totalPrice</code> to <code>total</code>.</p> <p>This is the javascript I'm using, but I get an error that says "cantidades[i].val() is not a function"</p> <pre><code>function calculate(){ var $total = $('#total'); var $cantidades = $('input[name=quantity]') var $unitarios = $('input[name=unitPrice]') var $totales = $('input[name=totalPrice]') var len = $cantidades.length; $total.val(0); for (var i = 0; i &lt; len; i++){ // calculate total for the row. ERROR HERE! $totales[i].val($cantidades[i].val() * $unitarios[i].val()); // Accumulate total $total.val($totalExento.val() + $totales[i].val()); } } </code></pre> <p>What am I missing? I think I'm not getting "jQuery objects" from the selector but I'm not sure hot to do this. </p> <p>Thanks in advance!</p>
38,863,396
0
<p>I also got exactly the same error like yours. In my case I comment out or deleted the following line under onServiceDiscover method. It works suddenly.It may not be the answer, Hope it will give you some clue to solve.</p> <pre><code> disManuf = gatt.getService(DIS_UUID).getCharacteristic(DIS_MANUF_UUID); disModel = gatt.getService(DIS_UUID).getCharacteristic(DIS_MODEL_UUID); disHWRev = gatt.getService(DIS_UUID).getCharacteristic(DIS_HWREV_UUID); disSWRev = gatt.getService(DIS_UUID).getCharacteristic(DIS_SWREV_UUID); readQueue.offer(disManuf); readQueue.offer(disModel); readQueue.offer(disHWRev); readQueue.offer(disSWRev); </code></pre>
26,825,668
0
<blockquote> <p>FeedListActivity is the Fragment activity. Now i need to add the Feedlistactivity as a Fragment in my Main Activity. How can i achieve this ?</p> </blockquote> <p>A fragmentActivity is not a fragment. It's an activity with support for fragments, it was introduced to make older android builds backward compatible with fragments -- if you're targeting newer API's only you can ignore it. To make make FeedListActivity() a fragment...you must extend from fragment. </p> <pre><code>Fragment newFragment = new Fragment(); </code></pre> <p>This line here should be creating a new instance of FeedList after you make it a fragment.</p>
34,966,139
0
<p>Code coverage, linting, etc. are provided by various services that you have to sign up with. For example, <a href="https://coveralls.io" rel="nofollow">coveralls.io</a> provides test coverage. Another popular service that provides many different types of code analysis and coverage tools is <a href="https://codeclimate.com" rel="nofollow">Code Climate</a>. Most of those sites provide badges you can add to your GitHub repo, usually in the README.</p> <p>For example, a repo I maintain has accounts with Travis, Gemnasium, and Code Climate, and I have badges for those services on my README: <a href="https://github.com/monfresh/ohana-sms" rel="nofollow">https://github.com/monfresh/ohana-sms</a></p>
40,930,765
0
php Multithreading where child process pick task automatically once there job done <p>As I am new in PHP multi-threading. Kindly help me to create a dummy program in which child process didn't wait to complete the process instead of that pick up the other task from pending jobs. I am facing an issue like I have 256 workers(threads) to complete my work but once a thread complete their work they become zombie and didn't do any work just wait for all the threads to complete then after all cycle start all over.</p>
35,106,773
0
<p>Use <a href="http://www.postgresql.org/docs/current/static/queries-union.html" rel="nofollow">UNION</a>:</p> <pre><code>select id, name, email, phone from table1 union select id, name, email, phone from table2 union select id, name, email, phone from table3; </code></pre> <p>In the above query identical rows from different tables will be presented as one row. If you want all rows from all tables use UNION ALL.</p> <p>Use INTERSECT to select only identical rows in all three tables:</p> <pre><code>select id, name, email, phone from table1 intersect select id, name, email, phone from table2 intersect select id, name, email, phone from table3; </code></pre>
36,699,078
0
MySql: How to reduce execution time of this Query? <p>How to customize this query, It takes around 30 Second to take out results, total records in 'videos' table are about 0.5 million, 3 million members are present in 'Members' Table, is there any alternate Query or should i break this query in 2 select queries ?</p> <p>user_id is Indexed vid_id is Indexed</p> <pre><code>select a.ref_url , a.source , a.video_name , a.viewers , b.username , c.points from members_videos a inner join Members b on a.user_id = b.user_id inner join rankings c on c.user_id = b.user_id where a.cat_ids in (123,234,52,234,423,122) not in (110,99) order by a.vid_id Desc limit 10 </code></pre>
28,694,684
0
<p>usually, when the DB upgrade is incremental, you could use an elegant <code>switch</code>:</p> <pre><code>public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { switch( oldVersion ){ case 1: migrateFrom1(); case 2: migrateFrom2(); case 3: migrateFrom3(); } } </code></pre> <p>notice the absence of <code>break</code> statements.</p>
23,896,055
0
<p>I have had this issue too, try removing the following from your CSS </p> <p>background-attachment: fixed; </p>
25,962,925
0
<p>The Recurring Payments API is what you want. Specifically, Express Checkout would be for PayPal payments and Payments Pro (DoDirectPayment / PayFlow) would be for direct credit card processing without a PayPal account.</p>
30,848,914
0
<p>You have added the entry to root's crontab, while your Cloud SDK installation is setup for a different user (I am guessing ubu121lts).</p> <p>You should add the entry in ubu121lts's crontab using:</p> <pre><code>crontab -u ubu121lts -e </code></pre> <p>Additionally your entry is currently scheduled to run on the 0th minute every hour. Is that what you intended?</p>
563,405
0
<p>What is it that you want to style, the list item or the anchor. You probably want to style the anchor, so add it to that</p>
4,356,996
0
What does a Connection Timeout mean in the context of a select() call <p>I've noticed that sometimes select returns with Connection Timed out set on errno, but I dont know why it would do this, how would it know? And how are you suppose to deal with this? (Im guessing it means that one of the connections timed out, perhaps an ACK wasnt heard back from at an appropriate time). Id imagine the only legit case of this would be if a server socket is in there and you ran a nonblocking connect before? In which case running a connect on this socket again would return to you whether it was connected or not, and that would be the way to handle that.... but is there a better way?</p> <p>Thanks in advance.</p>
19,325,241
0
<p>Based on your edited requirements, I would:</p> <ol> <li><p>get your app running on new server with blank mongodb </p></li> <li><p>set up a reverse proxy that forwards both sub. and sub2.domain.com traffic to your app </p></li> <li><p>set up a CNAME that points sub2.domain.com to the new server </p></li> <li><p>copy over the DB data as found in <a href="http://stackoverflow.com/a/19305144/219238">Andrew's answer</a></p></li> <li><p>update your meteor.com app to just do a temporary redirect (something like window.location="http://sub2.domain.com")</p></li> <li><p>update your sub.domain.com CNAME to point to the new server</p></li> </ol> <p>This should result in minimal disruption; clients who connect to <a href="http://sub.domain.com" rel="nofollow">http://sub.domain.com</a> are auto-redirected to <a href="http://sub2.domain.com" rel="nofollow">http://sub2.domain.com</a> until the CNAME DNS change propagates. After a few days, the sub2 cname won't be needed anymore and you can remove the sub2 cname and entry from the reverse proxy.</p>
38,225,269
0
DWARF reading not complete types <p>How can I read a non complete types in DWARF dumps?</p> <p>For example we have a derived class:</p> <pre><code>class Base { public: int Base_var1; int Base_var2; .... } class OtherClass : public Base { int OtherClass_var1; int OtherClass_var2; .... } OtherClass otherClass(); </code></pre> <p>We compile this with GCC compiler and want to find all members of <code>otherClass</code> object. We get the next DWARF dump:</p> <pre><code>&lt;1&gt;&lt;20a&gt;: Abbrev Number: 15 (DW_TAG_variable) &lt;20b&gt; DW_AT_name : otherClass &lt;211&gt; DW_AT_type : &lt;0x131&gt; &lt;1&gt;&lt;131&gt;: Abbrev Number: 117 (DW_TAG_class_type) &lt;132&gt; DW_AT_name : OtherClass &lt;133&gt; DW_AT_declaration : 1 &lt;134&gt; DW_AT_sibling : &lt;0x150&gt; &lt;2&gt;&lt;135&gt;: Abbrev Number: 45 (DW_TAG_member) &lt;136&gt; DW_AT_name : OtherClass_var1 &lt;137&gt; DW_AT_type : &lt;0x12&gt; &lt;138&gt; DW_AT_data_member_location: 2 byte block: 23 8 (DW_OP_plus_uconst: 8) ...... </code></pre> <p>We have a variable <code>otherClass</code>, which have a type of <code>0x131</code>. This type have <code>DW_AT_declaration</code> flag, which means that this is non complete type. Type at <code>0x131</code> have all members of it's main class (<code>OtherClass_var1</code> and <code>OtherClass_var2</code>), but don't have any information about derived members.</p> <p>If continue reading DWARF dump, then in some place we get this:</p> <pre><code>&lt;1&gt;&lt;500&gt;: Abbrev Number: 150 (DW_TAG_class_type) &lt;501&gt; DW_AT_specification: &lt;0x131&gt; &lt;502&gt; DW_AT_byte_size : 2696 &lt;503&gt; DW_AT_containing_type: &lt;0x560&gt; &lt;504&gt; DW_AT_sibling : &lt;0x36078&gt; &lt;2&gt;&lt;135&gt;: Abbrev Number: 45 (DW_TAG_member) &lt;136&gt; DW_AT_name : Base_var1 &lt;137&gt; DW_AT_type : &lt;0x12&gt; &lt;138&gt; DW_AT_data_member_location: 2 byte block: 23 8 ..... </code></pre> <p>There is a definition for our base class and this definition have <code>DW_AT_specification</code> tag, which shows where to find a other part of this class (main part).</p> <p>How can we correctly read this <code>otherClass</code> object? At this moment I have to store array of all types and when I get a <code>DW_AT_declaration</code> tag, I should go through array and find a type with specification to this type.</p> <p>And how can I get a absolute address of derived members? We have a absolute address of variable <code>otherClass</code>. Then member <code>OtherClass_var1</code> would have the same address as <code>otherClass</code>. Member <code>OtherClass_var2</code> would have address of <code>OtherClass_var1</code> plus a byte size of <code>OtherClass_var1</code>. But how can we calculate the address of derived members <code>Base_var1</code> and <code>Base_var2</code>?</p>
31,923,472
0
<p>To link to a form you need: </p> <pre><code>Form2 form2 = new Form2(); form2.show(); this.hide(); </code></pre> <p>then hide the previous form</p>
12,125,172
0
<p>There's a lot of questions here. You will want to use the GoogleCredential class to gain a new access token from an existing refresh token, that you well need to store (using whatever method you want, such as MemoryCredentialStore).</p> <p>The access token only lasts for an hour and there is not way to change this.</p> <p>Here is an example using the installed flow:</p> <pre><code>import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Collections; import java.util.List; import java.util.Properties; import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.auth.oauth2.TokenResponse; import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse; import com.google.api.client.http.HttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson.JacksonFactory; import com.google.api.services.bigquery.Bigquery; import com.google.api.services.bigquery.Bigquery.Datasets; import com.google.api.services.bigquery.BigqueryScopes; import com.google.api.services.bigquery.model.DatasetList; class BigQueryInstalledAuthDemo { // Change this to your current project ID private static final String PROJECT_NUMBER = "XXXXXXXXXX"; // Load Client ID/secret from client_secrets.json file. private static final String CLIENTSECRETS_LOCATION = "client_secrets.json"; static GoogleClientSecrets clientSecrets = loadClientSecrets(); private static final String REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"; // Objects for handling HTTP transport and JSON formatting of API calls private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); private static final JsonFactory JSON_FACTORY = new JacksonFactory(); private static GoogleAuthorizationCodeFlow flow = null; // BigQuery Client static Bigquery bigquery; public static void main(String[] args) throws IOException { // Attempt to Load existing Refresh Token String storedRefreshToken = loadRefreshToken(); // Check to see if the an existing refresh token was loaded. // If so, create a credential and call refreshToken() to get a new // access token. if (storedRefreshToken != null) { // Request a new Access token using the refresh token. GoogleCredential credential = createCredentialWithRefreshToken( HTTP_TRANSPORT, JSON_FACTORY, new TokenResponse().setRefreshToken(storedRefreshToken)); credential.refreshToken(); bigquery = buildService(credential); // If there is no refresh token (or token.properties file), start the OAuth // authorization flow. } else { String authorizeUrl = new GoogleAuthorizationCodeRequestUrl( clientSecrets, REDIRECT_URI, Collections.singleton(BigqueryScopes.BIGQUERY)).setState("").build(); System.out.println("Paste this URL into a web browser to authorize BigQuery Access:\n" + authorizeUrl); System.out.println("... and type the code you received here: "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String authorizationCode = in.readLine(); // Exchange the auth code for an access token and refesh token Credential credential = exchangeCode(authorizationCode); // Store the refresh token for future use. storeRefreshToken(credential.getRefreshToken()); bigquery = buildService(credential); } // Make API calls using your client. listDatasets(bigquery, PROJECT_NUMBER); } /** * Builds an authorized BigQuery API client. */ private static Bigquery buildService(Credential credential) { return new Bigquery.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).build(); } /** * Build an authorization flow and store it as a static class attribute. */ static GoogleAuthorizationCodeFlow getFlow() { if (flow == null) { flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, Collections.singleton(BigqueryScopes.BIGQUERY)) .setAccessType("offline").setApprovalPrompt("force").build(); } return flow; } /** * Exchange the authorization code for OAuth 2.0 credentials. */ static Credential exchangeCode(String authorizationCode) throws IOException { GoogleAuthorizationCodeFlow flow = getFlow(); GoogleTokenResponse response = flow.newTokenRequest(authorizationCode).setRedirectUri(REDIRECT_URI).execute(); return flow.createAndStoreCredential(response, null); } /** * No need to go through OAuth dance, get an access token using the * existing refresh token. */ public static GoogleCredential createCredentialWithRefreshToken(HttpTransport transport, JsonFactory jsonFactory, TokenResponse tokenResponse) { return new GoogleCredential.Builder().setTransport(transport) .setJsonFactory(jsonFactory) .setClientSecrets(clientSecrets) .build() .setFromTokenResponse(tokenResponse); } /** * Helper to load client ID/Secret from file. */ private static GoogleClientSecrets loadClientSecrets() { try { GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(new JacksonFactory(), BigQueryInstalledAuthDemo.class.getResourceAsStream(CLIENTSECRETS_LOCATION)); return clientSecrets; } catch (Exception e) { System.out.println("Could not load clientsecrets.json"); e.printStackTrace(); } return clientSecrets; } /** * Helper to store a new refresh token in token.properties file. */ private static void storeRefreshToken(String refresh_token) { Properties properties = new Properties(); properties.setProperty("refreshtoken", refresh_token); System.out.println(properties.get("refreshtoken")); try { properties.store(new FileOutputStream("token.properties"), null); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } /** * Helper to load refresh token from the token.properties file. */ private static String loadRefreshToken(){ Properties properties = new Properties(); try { properties.load(new FileInputStream("token.properties")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return (String) properties.get("refreshtoken"); } /** * * List available Datasets. */ public static void listDatasets(Bigquery bigquery, String projectId) throws IOException { Datasets.List datasetRequest = bigquery.datasets().list(projectId); DatasetList datasetList = datasetRequest.execute(); if (datasetList.getDatasets() != null) { List&lt;DatasetList.Datasets&gt; datasets = datasetList.getDatasets(); System.out.println("Available datasets\n----------------"); for (com.google.api.services.bigquery.model.DatasetList.Datasets dataset : datasets) { System.out.format("%s\n", dataset.getDatasetReference().getDatasetId()); } } } } </code></pre> <p>An alternative to authorization via storing and using a refresh token to acquire a new access token in your installed application is to use a <a href="https://developers.google.com/accounts/docs/OAuth2ServiceAccount" rel="nofollow">server to server service account authorization</a> flow. In this case, your application will need to be able to securely store and use a unique private key. Here is an example of this type of flow using the Google Java API Client:</p> <pre><code>import com.google.api.client.http.HttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson.JacksonFactory; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.services.bigquery.Bigquery; import com.google.api.services.bigquery.Bigquery.Datasets; import com.google.api.services.bigquery.model.DatasetList; import java.io.File; import java.io.IOException; import java.security.GeneralSecurityException; public class JavaCommandLineServiceAccounts { private static final String SCOPE = "https://www.googleapis.com/auth/bigquery"; private static final HttpTransport TRANSPORT = new NetHttpTransport(); private static final JsonFactory JSON_FACTORY = new JacksonFactory(); private static Bigquery bigquery; public static void main(String[] args) throws IOException, GeneralSecurityException { GoogleCredential credential = new GoogleCredential.Builder().setTransport(TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId("[email protected]") .setServiceAccountScopes(SCOPE) .setServiceAccountPrivateKeyFromP12File(new File("my_file.p12")) .build(); bigquery = new Bigquery.Builder(TRANSPORT, JSON_FACTORY, credential) .setApplicationName("BigQuery-Service-Accounts/0.1") .setHttpRequestInitializer(credential).build(); Datasets.List datasetRequest = bigquery.datasets().list("publicdata"); DatasetList datasetList = datasetRequest.execute(); System.out.format("%s\n", datasetList.toPrettyString()); } } </code></pre>
16,500,581
0
Call different (localized) view based on current culture <p>I'm using <code>LocalizationAttribute</code> which implements <code>ActionFilterAttribute</code> to localize views. I simply put <code>[Localize]</code> on controller. I was using LocalizeStrings.resx files to apply based on which language is on current thread. Everything works for this simple case (with localized strings). Now I want to localize complete pages (not just strings).</p> <p>To acomplish this which approach do you use?</p> <p>Do I need to identify which thread is current on controller and based on that value to call view:</p> <pre><code>public ActionResult AboutUs() { switch (Thread.CurrentThread.CurrentUICulture.Name) { case "en-US": return View("EnglishUSView"); case "de-DE": return View("GermanView"); default: return View(); } return View(); } </code></pre> <p>or do you recommend something else ?</p>
2,960,535
0
<p>You can <strong>relate</strong> things however you want. A popular approach is using non-sequential UUID values as identifiers so that you can query discrete data sources for related data.</p> <p>The problem is <strong>integrity</strong> ... without relational constraints, things can get messy. A well coded application can deal with this however.</p> <p>I would also ensure you use caching wherever popular to avoid the overhead of many datasources. </p>
3,237,987
0
<p>Each element in the array is represented by a single object in Core Data so, yes, you have to create an object for each element. If you didn't have to do this then you wouldn't have an object graph in the first place. </p> <p>You do have to check for an existing object because every object in the Core Data stack is utterly unique. However, doing so is no more complicated than checking for the same data in an array or a SQL table. </p> <p>Core Data's strength is the management of data models with complex relationships between data entities. That is often overkill for data that is little more than a single, dumb table with no relationships. However, the ease of integration with the UI and other parts of the app/system usually pays for the up front overkill in inputting that single table. </p>
10,593,004
0
How do I change this query? <p>How do i change the SELECT query from this:</p> <pre><code>$tre = mysql_query("SELECT System_id, Full_name FROM accounts WHERE Full_name LIKE '". mysql_real_escape_string($_GET['q'])."%' LIMIT 5"); </code></pre> <p>To having this query below in $tre:</p> <pre><code>SELECT DISTINCT contacts.friend_id, accounts.full_name, accounts.system_id FROM contacts, accounts WHERE (contacts.system_id = '$sid' AND contacts.friend_id = accounts.system_id) OR (contacts.friend_id = '$sid' AND contacts.system_id = accounts.system_id) </code></pre> <p>I want the to place the second query inside of $tre = mysql_query(); </p> <p>I am having trouble doing so because the second query has brackets in them and being new i am not sure how to do it correctly.</p>
22,598,860
0
HTML Image Link not working properly in android phonegap app <p>I am developing a FM Radio streaming app. When user presses in toggle button the streaming should stop when clicked again it should start. </p> <p>streaming works fine but the portion where user needs to touch is not exactly coming on top of that toggle icon. Its coming slightly some where on the top portion of the icon. The portion I have circled and shown in picture.</p> <p>How to create Image button with simple css and html for this case </p> <pre><code>&lt;a href="#" style="position:fixed;top: 1%;left: 5%;" onclick="toggleAudio('http://kantipur-stream.softnep.com:7248');"&gt; &lt;img src="images/toggle.png"&gt; &lt;/a&gt; </code></pre> <p><img src="https://i.stack.imgur.com/tQIVL.png" alt="enter image description here"></p>
19,262,116
0
<blockquote> <p>I used documentMode instead of simply checking (if(document.querySelector)) to help me debug this problem further</p> </blockquote>
24,372,774
0
<p>Yes it will, assuming <code>&lt;src&gt;</code> is a directory in <code>ADD &lt;src&gt; &lt;dest&gt;</code>.</p> <p>The <a href="https://docs.docker.com/reference/builder/#add" rel="nofollow"><code>ADD</code></a> command is a bit tricky but mostly for the <code>&lt;dest&gt;</code> part. For instance, the <code>ADD</code> command behaves differently depending on when <code>&lt;dest&gt;</code> ends with a slash or not.</p>
1,006,453
0
<p>That is one way. It's nice and simple, but a bit messy. You could get rid of the storyboard and on each tick, increment a local value by the tick interval and use that to set your time. You would then only have one time piece.</p> <p>Or... A more elegant and re-usable way would be to create a helper class that is a DependencyObject. I would also just use a StoryBoard with a DoubleAnimation an bind the Storyboard.Target to an instance of the DoubleTextblockSetter. Set the storyboard Duration to your time and set the value to your time in seconds. Here is the DoublerBlockSetterCode.</p> <pre><code>public class DoubleTextBlockSetter : DependencyObject { private TextBlock textBlock { get; private set; } private IValueConverter converter { get; private set; } private object converterParameter { get; private set; } public DoubleTextBlockSetter( TextBlock textBlock, IValueConverter converter, object converterParameter) { this.textBlock = textBlock; this.converter = converter; this.converterParameter = converterParameter; } #region Value public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( "Value", typeof(double), typeof(DoubleTextBlockSetter), new PropertyMetadata( new PropertyChangedCallback( DoubleTextBlockSetter.ValuePropertyChanged ) ) ); private static void ValuePropertyChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args) { DoubleTextBlockSetter control = obj as DoubleTextBlockSetter; if (control != null) { control.OnValuePropertyChanged(); } } public double Value { get { return (double)this.GetValue(DoubleTextBlockSetter.ValueProperty); } set { base.SetValue(DoubleTextBlockSetter.ValueProperty, value); } } protected virtual void OnValuePropertyChanged() { this.textBlock.Text = this.converter.Convert( this.Value, typeof(string), this.converterParameter, CultureInfo.CurrentCulture) as string; } #endregion } </code></pre> <p>Then you might have a format converter:</p> <pre><code>public class TicksFormatConverter : IValueConverter { TimeSpanFormatProvider formatProvider = new TimeSpanFormatProvider(); public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { long numericValue = 0; if (value is int) { numericValue = (long)(int)value; } else if (value is long) { numericValue = (long)value; } else if (value is double) { numericValue = (long)(double)value; } else throw new ArgumentException("Expecting type of int, long, or double."); string formatterString = null; if (parameter != null) { formatterString = parameter.ToString(); } else { formatterString = "{0:H:m:ss}"; } TimeSpan timespan = new TimeSpan(numericValue); return string.Format(this.formatProvider, formatterString, timespan); } public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>I almost forgot the TimespanFormatProvider. There is no format provider for timespan in Silverlight, so it appears.</p> <pre><code>public class TimeSpanFormatProvider : IFormatProvider, ICustomFormatter { public object GetFormat(Type formatType) { if (formatType != typeof(ICustomFormatter)) return null; return this; } public string Format(string format, object arg, IFormatProvider formatProvider) { string formattedString; if (arg is TimeSpan) { TimeSpan ts = (TimeSpan)arg; DateTime dt = DateTime.MinValue.Add(ts); if (ts &lt; TimeSpan.FromDays(1)) { format = format.Replace("d.", ""); format = format.Replace("d", ""); } if (ts &lt; TimeSpan.FromHours(1)) { format = format.Replace("H:", ""); format = format.Replace("H", ""); format = format.Replace("h:", ""); format = format.Replace("h", ""); } // Uncomment of you want to minutes to disappear below 60 seconds. //if (ts &lt; TimeSpan.FromMinutes(1)) //{ // format = format.Replace("m:", ""); // format = format.Replace("m", ""); //} if (string.IsNullOrEmpty(format)) { formattedString = string.Empty; } else { formattedString = dt.ToString(format, formatProvider); } } else throw new ArgumentNullException(); return formattedString; } } </code></pre> <p>All that stuff is re-usable and should live in your tool box. I pulled it from mine. Then, of course, you wire it all together:</p> <pre><code>Storyboard sb = new Storyboard(); DoubleAnimation da = new DoubleAnimation(); sb.Children.Add(da); DoubleTextBlockSetter textBlockSetter = new DoubleTextBlockSetter( Your_TextBlock, new TicksFormatConverter(), "{0:m:ss}"); // DateTime format Storyboard.SetTarget(da, textBlockSetter); da.From = Your_RefreshInterval_Secs * TimeSpan.TicksPerSecond; da.Duration = new Duration( new TimeSpan( Your_RefreshInterval_Secs * TimeSpan.TicksPerSecond)); sb.begin(); </code></pre> <p>And that should do the trick. An it's only like a million lines of code. And we haven't even written Hello World just yet...;) I didn't compile that, but I did Copy and Paste the 3 classes directly from my library. I've used them quite a lot. It works great. I also use those classes for other things. The TickFormatConverter comes in handy when data binding. I also have one that does Seconds. Very useful. The DoubleTextblockSetter allows me to animate numbers, which is really fun. Especially when you apply different types of interpolation.</p> <p>Enjoy.</p>
2,345,241
0
<p>See <a href="http://deniskrjuchkov.blogspot.com/2010/02/oracle-challenge.html" rel="nofollow noreferrer">http://deniskrjuchkov.blogspot.com/2010/02/oracle-challenge.html</a> - I suspect there is an explanation of an issue you've faced.</p>
26,724,077
0
Automating ASP MVC.NET Web api documentation on the /Help page <p>I've been following the instructions that talk about creating help pages for the Web API, one example being <a href="http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages" rel="nofollow">http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages</a></p> <p>I know that to get descriptions for REST paths, you place these xml comments above the respective methods.</p> <pre><code>/// &lt;summary&gt; /// Looks up some data by ID. /// &lt;/summary&gt; /// &lt;param name="id"&gt;The ID of the data.&lt;/param&gt; </code></pre> <p>But say I have many paths or many Web API projects and I want to make this process a little faster. Where could I start if I wanted even simple 1 sentence descriptions to be automated. I would be ok, with simple description, maybe pulled from the name or convention of the method name and a mention of the parameter types that it expect. Just very simple stuff to build off of.</p> <p>I was thinking initially that this automation project would reside in the same solution as the Web API that you're targeting, it would just be another separate project. Thanks.</p>
10,003,292
0
<p>Take a look at these</p> <p><a href="http://code.google.com/p/geoxml3/" rel="nofollow">The geoxml3 project is an effort to develop a KML processor for use with Version 3 of the Google Maps JavaScript API, it now allows access to individual markers, polylines and polygons, rendered from KML.</a></p> <p><a href="http://www.birdtheme.org/useful/v3tool.html" rel="nofollow">Some useful demos with KML</a></p>
4,250,209
0
<p>Well, just do what the error message tells you.</p> <p>Don't call <code>setContentView()</code> before <code>requestFeature()</code>.</p> <p><strong>Note:</strong></p> <p>As said in comments, for both <code>ActionBarSherlock</code> and <code>AppCompat</code> library, it's necessary to call <code>requestFeature()</code> before <code>super.onCreate()</code></p>
22,901,498
0
<p>the result of an <code>expr</code> is internally represented as a float. When you turn it back to a string in an implicit way, you get a lossless* string conversion, which is most readable in scientific notation, so that's what's used. If you don't want that, don't let tcl do the conversion, but be wary that you give up the exact string representation:</p> <pre><code>% puts [expr {1. / 8 / 1000000}] 1.25e-7 % puts [format "%f" [expr {1. / 8 / 1000000}]] 0.000000 % puts [format "%.20f" [expr {1. / 8 / 1000000}]] 0.00000012500000000000 </code></pre> <p><sub>*lossless only as of Tcl8.5</sub></p>
6,916,143
0
<p>You should be fine sharing a single blob container reference as long as you are not trying to perform an update on the container itself (even then, I think it would still be fine in most scenarios like List). In fact, you don't really even need the container reference if you are sure it exists:</p> <pre><code>client.GetContainerReference("foo").GetBlobReference("bar"); client.GetBlobReference("foo/bar"); //same </code></pre> <p>As you can see, the only reason to get a container reference is if you want to perform an operation on the container itself (list, delete, etc.). If you keep the blob references in separate threads, you will be fine.</p>
7,826,094
0
<p>Your code is working fine for me (Tested on <strong>firefox</strong> &amp; <strong>ie8</strong>).</p> <p>Am doubted, since you have pointed to same page for three hyperlinks. This might you confused to see that it is not redirecting to next page.</p> <p>Change the hyperlink filename for three links and test it, once again.</p>
18,334,943
0
pandoc-ruby error when running documented example <p>When running the following script using pandoc-ruby (directly from the documentation) I get an error.</p> <pre><code>require 'rubygems' require 'pandoc-ruby' puts PandocRuby.convert('# Markdown Title', :from =&gt; :markdown, :to =&gt; :html) </code></pre> <p>Output:</p> <pre><code>[dan@FIOS-RH test-markdown]$ ruby convert.rb /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:250:in `format_flag': undefined method `length' for :from:Symbol (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:241:in `create_option' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:225:in `prepare_options' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `inject' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in `each' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in `inject' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in `prepare_options' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:227:in `prepare_options' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `inject' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in `each' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in `inject' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in `prepare_options' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:131:in `convert' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:86:in `convert' from convert.rb:3 [dan ]$ pandoc --version pandoc 1.11.1 ... [dan ]$ ruby --version ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] pandoc-ruby version: 0.7.4 </code></pre> <p>Am I missing something obvious?</p>
22,559,948
0
<p>I have done a simple communication from an open frameworks client to a node.js server via OSC protocol. It is very popular in the OF world, and it can be read by a bunch of similar software and frameworks (processing.org, PureData, VVVV, Max/MSP, etc)</p> <p>Here you have some different chooses for OSC implementation via UDP:</p> <p><a href="https://nodejsmodules.org/tags/osc" rel="nofollow">https://nodejsmodules.org/tags/osc</a></p>
246,423
0
<p>Probably by modifying the "System Power States" as <a href="http://www.codeproject.com/KB/mobile/WiMoPower1.aspx" rel="nofollow noreferrer">described here</a> (but in c#)</p> <p>That article also describes a way to prevent the mobile device to sleep (which is not exactly what you may want), by calling the native function SystemIdleTimerReset() periodically (to prevent the device from powering down).</p>
5,070,173
0
<p>A little late reply here, but right now, in Texas, I've got my nephew digging a 60in X 16in X 4ft hole just outside my home office. Into it I'll be placing a 40ft copper tubing "radiator". This with be the "core" of a geothermal loop to cool my mac. Yeah, it's wildly watercooled because the mods cause me to exceed the TDP (it's a MacPro1,1) of the case, but even before that my office got uncomfortably hot. Now it just causes my computer to shut down when I try to encode video. Not good.</p> <p>In the UK you should be able to do the same (well, cool your room at least) with just a ground loop, a cheap pump, and a fan with more copper tubing coiled behind it. My project has ended up costing me quite a bit because of its complexity and mistakes make along the way, but a simple system to cool just the room should cost less than £150-200 and is definitely a DIY project you and your dad could do.</p> <p>One of of the biggest reasons to do this are the electricity (cooling) costs saved for me, literally several hundred $ per year. And it's "Green" cooling. But the biggest reason is for the amount of science I've learned in the past 3 months.</p> <p>Talk to your Dad about it. It's been fun, and would be a good project for a young Scottish engineer!</p>
24,980,200
0
<p>You asked about Java, but in case you meant something more basic I will try to answer more generally.</p> <p>Given a Filter Coefficients (You have an approximation of the Laplacian filter) the way to apply it on an image is <a href="http://en.wikipedia.org/wiki/Convolution" rel="nofollow">Convolution</a> (Assuming the Filter is LSI - Linear Spatially Invariant).</p> <p>The convolution can be computed directly (Loops) of in the frequency domain (Using <a href="http://en.wikipedia.org/wiki/Convolution_theorem" rel="nofollow">Convolution Theorem</a>).</p> <p>There are few things to consider (Real World Problems):</p> <ol> <li>The convolution "Asks" for pixels beyond the image. Hence boundary conditions should be imposed ("Pixels" beyond the image are zero, constant, nearest neighbor, etc...).</li> <li>The result of the convolution is bigger then the input image due to the "Filter Transient". Again, logical decision should be made.</li> <li>If you're limited to Fixed Point math, proper scaling should be made after the operation (Rule of Thumb, built to keep the image mean, says the sum of all filter coefficients should be 1, hence you need the scaling).</li> </ol> <p>Good Luck.</p>
26,764,482
0
<p>Javascript will let you access all the styles applied to the document. Check each one to see if it contains the color.</p> <p><strong>CSS</strong></p> <pre><code>&lt;style&gt; .first-selector div { color: #3C3C3C; } .second-selector span { background-color: #3C3C3C; } .third-selector { border: 1px solid #3C3C3C; } .fourth-selector .nothing { color: red; } &lt;/style&gt; </code></pre> <p><strong>JS:</strong></p> <pre><code>&lt;script&gt; function getColorRules(color) { //convert hex to rgb, since hex color styles are internally stored as rgb if (/[#]{0,1}[0-9A-F]{6}/.test(color)) { color = color.replace('#', ''); var r = parseInt(color.substr(0, 2), 16); var g = parseInt(color.substr(2, 2), 16); var b = parseInt(color.substr(4, 2), 16); color = "rgb(" + r + ", " + g + ", " + b + ")"; } var returnArray = []; //grab all stylesheets var sheets = document.styleSheets; for (var i in sheets) { //to work in FF or chrome var rules = sheets[i].rules || sheets[i].cssRules; for (var r in rules) { //console.log(rules[r]); if (rules[r].cssText !== undefined) { //ignore empty or non css properties if (rules[r].cssText.indexOf(color) &gt; -1) //if the color is found in the style rule { //add it to an array var style = { selector: rules[r].selectorText, style: rules[r].style.cssText.split(":")[0] }; returnArray.push(style); } } } } return returnArray; } console.log(getColorRules("#3C3C3C")); //[{ selector=".first-selector div", style="color"}, { selector=".second-selector span", style="background-color"}, { selector=".third-selector", style="border"}] console.log(getColorRules("red")); // [{ selector=".fourth-selector .nothing", style="color"}] &lt;/script&gt; </code></pre>
14,711,145
0
<p>Try to check in web.inf file if by any parameter is their from where you can change the date. Otherwise as earlier comment change the system date and restart the server.</p>
30,270,397
0
<p>It depends on what browsers you want to support. You could use</p> <pre><code>label { all: initial; // or all: unset } </code></pre> <p>but be aware that it's not really widely supported yet. It works on IE 11, Firefox, Opera &amp; Chrome, but not Safari or most mobile browsers. Still, a good one to know if and when it becomes more widely supported :)</p>
6,833,440
0
<p>You have to use the same string replacement as with AR find</p> <p><code>Listing.find_by_sql(["SELECT * FROM listings WHERE industry = ?", @user_industry])</code></p> <p><a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-find_by_sql">API documentation</a></p>
6,203,699
0
<p>You can iterate over the returned drives from your WMI query and add the deviceid and "Disk GB" results to a string value. Then you can write the resulting string value to the Excel cell. One way to do this would be like this:</p> <pre><code>$a = New-Object -comobject Excel.Application $a.Visible = $True $b = $a.Workbooks.Add() $c = $b.Worksheets.Item(1) $outputstring = "" foreach ($drive in $driveinfo) { $outputstring += "$($drive.deviceid) $($drive."Disk GB") GB`n" } $c.cells.item(1,1) = $outputstring </code></pre>
22,170,922
0
<p>Yes you do. The Primary key is what allows the many to one relationship to exist.</p> <p>This requirement is already catered for by the branch_id column. </p> <p>The item_id column is not required for the one-to-many relationship in your example.</p>
8,132,598
0
<p>If you don't want the previous <code>Activity</code> to be shown on the back button press, you can specify this in the AndroidManifest.xml like:</p> <pre><code>&lt;activity android:name="sample.activity.MyActivity" android:noHistory="true" /&gt; </code></pre> <p>This will prevent the <code>Activity</code> from being put into the history stack and allow the back button to quit (assuming you add the noHistory flag to every previous <code>Activity</code>) </p>
503,687
0
<pre><code>Select Case Product WHEN 'Banana' Then 'Fruit' WHEN 'Apple' Then 'Fruit' WHEN 'Orange' Then 'Fruit' ELSE Product END FROM Table </code></pre>
3,089,521
0
<p>Looking in the Migration Guide there's a section called <a href="http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzao.doc/mi10970_.htm" rel="nofollow noreferrer">Upgrading a WebSphere MQ client from Version 6.0 to Version 7.0</a> which suggests a possible explanation. It states that as of v7 the TCP tuning is stored in the client configuration file. So if you have enabled TCP Keepalive in the Windows registry, the v7 client will ignore it. The format and location of the file is described in <a href="http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaf.doc/cs13350_.htm" rel="nofollow noreferrer">WebSphere MQ client configuration file</a>.</p> <p>Of course for this to be the problem, there has to be a socket leak. You did not mention which version of WMQ V7 client you have but the Fix Pack README files do show a number of APARs related to socket leaks, failure to clean up after disconnects and so forth. None of these directly mention C# or .Net but there are enough problems around connection/disconnection issues to make it worth an upgrade.</p> <p>So first &amp; easiest fix to attempt is to add TCP Keepalive to the client configuration file and see if it helps. Disable connection sharing while you are in there as well. It's not supposed to be a factor but then it's not supposed to leak sockets either. Can't hurt. Next is to apply <a href="http://www-01.ibm.com/support/docview.wss?rs=171&amp;uid=swg27006037" rel="nofollow noreferrer">Fix Pack 7.0.1.2</a> (latest as of this writing) and see if that fixes the problem. After that, it's PMR time. Hope that helps.</p>
1,809,795
0
<p>At the very least you can now output assembler from gcc like this:</p> <p><code>gcc -c -S test.c -o test.asm</code></p> <p>Then you can inspect the output of generated C code for educational purposes.</p>
16,273,022
0
<p>Visual Studio Test Explorer window has integration with Visual Studio Profiler. You just need to right click on the Test in the Test Explorer window and choose Profile Test.</p> <p><img src="https://i.stack.imgur.com/r4FkD.png" alt="enter image description here"></p>
20,568,435
0
<p>You have to add rule like this. </p> <pre><code>'rules'=&gt;array( 'site/index/city/&lt;city:.*?&gt;'=&gt;'site/index', '&lt;controller:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/view', '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;', '&lt;controller:\w+&gt;/&lt;action:\w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;', ), </code></pre>
26,887,744
0
<p>You need to combine all of the product IDs into an array and use <em>that</em> as the value for ecomm_prodid. There should only ever be one google_tag_params assignment, not multiple (unless you are doing something crazy with multiple firings of the tag which probably isn't a good idea...)</p> <p>For example, say you had your 12 products. For the sake of clarity lets say that the IDs are 1,2,3,4,5,6,7,8,9,10,11,12.</p> <p>This is what you want to get to:</p> <pre><code>&lt;script type='text/javascript'&gt; var google_tag_params = { ecomm_prodid: [1,2,3,4,5,6,7,8,9,10,11,12], ecomm_pagetype: 'product', ecomm_totalvalue: 1974.99 }; &lt;/script&gt; </code></pre> <p>Note that the ecomm_totalvalue should be a sum of the values of all products that are in the ecomm_prodid array, and should be a normal Number and not a string (no commas, no $ or £ etc)</p> <p>So, something like this:</p> <pre><code>var products = [{'id':'1','price':9.99},{'id':'2','price':4.99}]; var ids = []; var total = 0; $.each(products, function(key, value){ ids.push(value.id); total += Number(value.price); }); var google_tag_params = { ecomm_prodid: ids, ecomm_pagetype: 'product', ecomm_totalvalue: total }; </code></pre> <p>This would then be equivalent of something like this:</p> <pre><code>var google_tag_params = { ecomm_prodid: ["1", "2"], ecomm_pagetype: "product", ecomm_totalvalue: 14.98 }; </code></pre>
16,683,226
0
<pre><code>select color from table_name where width = $value and length = $value2 and height = $value3 </code></pre> <p>I assume you mean using SQL....</p>
28,950,544
0
<p>There are two problems with your code as far as I can see:</p> <p>You seem not to not even connect to mongo. In order to connect to mongo using mongoose you have to use</p> <pre><code>mongoose.connect('mongodb://...'); </code></pre> <p>Also, your database.js is not valid javascript. It's not the connection string itself that's the problem, but rather that you don't assign in to a variable.</p> <p>A correct way would be to assign the connection string to a property like this:</p> <pre><code>module.exports = { connString: 'mongodb://username:[email protected]:33669/dclubdb' }; </code></pre> <p>and then you could connect with</p> <pre><code>mongoose.connect(configDB.connString); </code></pre>
36,219,523
0
Mac OS X how many NSNotification centers are there on a workstation-mac <h1>Short question</h1> <p>on a workstation-mac (MacPro) I found 3 NSNotification centers:</p> <h2>call (swift)</h2> <pre><code>// 1. NSWorkspace Center let theWorkspaceCenter = NSWorkspace.sharedWorkspace ().notificationCenter // 2. NSDistributedNotification Center let theNSDistributedNotificationCenter = NSDistributedNotificationCenter.defaultCenter () // 3. Default Center let theDefaultCenter = NSNotificationCenter.defaultCenter () </code></pre> <p>Are there any more NSNotification centers?</p> <hr> <h1>Longer description</h1> <p><strong>1. NSWorkspace Center</strong></p> <h2>call (swift)</h2> <pre><code>let theWorkspaceCenter = NSWorkspace.sharedWorkspace ().notificationCenter </code></pre> <ul> <li>Very few notifications</li> </ul> <h2>Typical notifications</h2> <ul> <li>Computer goes to sleep</li> <li>Computer wakes from sleep</li> <li>Volume gets mounted / unmounted</li> </ul> <h2>Example</h2> <pre><code>NSWorkspaceScreensDidWakeNotification NSWorkspaceWillUnmountNotification </code></pre> <hr> <p><strong>2. NSDistributedNotification Center</strong></p> <h2>call (swift)</h2> <pre><code>let theNSDistributedNotificationCenter = NSDistributedNotificationCenter.defaultCenter () </code></pre> <ul> <li>Regular notifications</li> </ul> <h2>Typical notifications</h2> <ul> <li>Menue tracking</li> <li>Application comes to foreground</li> <li>backup</li> <li>systemBeep</li> <li>0:00 dayChange</li> </ul> <h2>Example</h2> <pre><code>com.apple.HIToolbox.beginMenuTrackingNotification com.apple.HIToolbox.frontMenuBarShown com.apple.backupd.NewSystemBackupAvailableNotification com.apple.systemBeep com.apple.calendar.DayChanged </code></pre> <hr> <p><strong>3. Default Center</strong></p> <h2>call (swift)</h2> <pre><code>let theDefaultCenter = NSNotificationCenter.defaultCenter () </code></pre> <ul> <li>Very much notifications (hundreds / thousands within a few seconds)</li> </ul> <h2>Example</h2> <pre><code>NSApplicationDidUpdateNotification NSViewNeedsDisplayInRectNotification NSWindowDidUpdateNotification </code></pre> <p>Thanks for any hint!</p>
5,573,525
0
<p>Typically, how I like to do it is to have a couple of different directories. Something like this:</p> <p><strong><code>Trunk</code></strong> (deploy here)</p> <pre><code> - Production - Staging - Development/whatever </code></pre> <p><strong><code>Branches</code></strong> (develop here)</p> <pre><code> - Master Branch (primary) - Secondary/Tertiary Branches </code></pre> <p><strong><code>Tags</code></strong> (Archive here)</p> <pre><code> - Name a tag appropriately (timestamp, version, edits) </code></pre> <p>Hope this helps. Feel free to ask questions.</p>
21,270,045
0
<p>It looks OK for me. That example is not working? But different thing is how you fire next Intent in onReceive method. Please try use your action in <code>myIntent = new Intent(YourActionClass.class);</code></p>
2,690,422
0
add(a,b) and a.add(b) <p>how can i transform a method (that performs a+b and returns the result) from add(a,b) to a.add(b)?<br> i read this somewhere and i can't remember what is the technique called...<br> does it depends on the language? </p> <p>is this possible in javascript?</p>
24,927,838
0
Accessing controller method from view in Ember <p>I would like to call a controller method which is not necessarily an action from my view. How can I achieve this?</p>
35,532,916
0
<p>The simplest and best way to address this problem is using toggle(). </p> <p>//html</p> <pre><code>&lt;button id="reloadButton"&gt; Hover me &lt;/button&gt; &lt;div id="reloadWarningBackground" style="display:none;"&gt; &lt;p&gt; Hello this is me &lt;/p&gt; &lt;/div&gt; </code></pre> <p>//Javascript</p> <pre><code>$('#reloadButton').hover(function() { $('#reloadWarningBackground').toggle(); }); </code></pre> <p><a href="https://jsfiddle.net/k1L5nzz3/" rel="nofollow">fiddle</a></p>
12,447,922
0
<p>I don't think it's working smoothly. Calling <code>openContextMenu(l)</code> will cause <code>item.getMenuInfo()</code> to be null (inside method <code>onContextItemSelected(MenuItem item)</code>). </p> <p>You should call <code>l.showContextMenuForChild(v)</code> instead of <code>openContextMenu(l)</code>.</p>
23,140,816
0
<p>Yes, too many variables will blow the stack.</p>
23,391,126
0
<p>UDP packets include a field for a 16 bit CRC checksum which the receiving operating system will use to check for packet corruption. If the checksum is present and fails, then the packet will be silently discarded. It is up to the application to notice that the packet disappeared and take corrective action.</p> <p>UDP checksums are enabled by default on all modern operating systems. It is possible to disable UDP checksums in IPv4, either at the socket or OS level. Doing so would reduce the CPU overhead of processing each packet at both the sender and receiver. This might be desirable if, for example, the application were calculating its own checksum separately. Without any checksum, there would be no guarantee that the bytes received are the same as the bytes sent.</p>
22,029,815
0
How to use the QT Jni class "QAndroidJniObject" <p>I'm a beginner of "QT for Android" and now I'm using it to develop a communication oftware based on mobile.I hava developed java functions that call android's api as a class in a .java document.In order to Simplify UI development,the UI is based on QT Widget program.Then I use the QT-JNI class "QAndroidJniObject" to call these java functions according to QT5.2 API document.Android resource file is stored in the directory:./android/src/com/comm/sipcall/SipCallSend.java.Since the less information in this regard,I developed the java and c++ program according to API document.But I encountered the following problems, and also hope to get answers: 1) The QT program is based on QT Widget.The java program needs to get the current application object Context in order to initialize java object.The c++ code I developed as following:</p> <pre><code>//c++: QPlatformNativeInterface *interface = QApplication::platformNativeInterface(); jobject activity = (jobject)interface-&gt;nativeResourceForIntegration("QtActivity"); QAndroidJniObject* at = new QAndroidJniObject(activity); QAndroidJniObject appctx = at-&gt;callObjectMethod("getApplicationContext","()Landroid/content/Context;"); //.pro: QT += core gui gui-private </code></pre> <p>Is this right?</p> <p>2) The java class contains a constructor function and three public functions:</p> <pre><code>java: package com.comm.sipcall; improt XXXX .... .... public class SipCallSend extends Activity { private Context context; // 接收QT的context public String sipToAddress = ""; public String sipDomain = ""; public String user_name = ""; public String pass_word = ""; public SipCallSend(){ Log.i("ddd","init"); sipToAddress = ""; sipDomain = ""; user_name = ""; pass_word = ""; } public void SetContext(Context cnt) { this.context = cnt; //Log.i("ccc",user_name); } public int Login(String domain,String username,String password){ .... sipDomain = domain; user_name = username; pass_word = password; ... return 0; } public int Call(String addrNum) { ... return 0; } } C++: QPlatformNativeInterface *interface = QApplication::platformNativeInterface(); jobject activity = (jobject)interface-&gt;nativeResourceForIntegration("QtActivity"); QAndroidJniObject* at = new QAndroidJniObject(activity); QAndroidJniObject appctx = at-&gt;callObjectMethod("getApplicationContext","()Landroid/content/Context;"); QAndroidJniObject* m_sipcall = new QAndroidJniObject("com/comm/sipcall/SipCallSend"); if (!m_sipcall-&gt;isValid()) return; m_sipcall-&gt;callMethod&lt;void&gt;("SetContext","(Landroid/content/Context;)V", appctx.object&lt;jobject&gt;()); QAndroidJniObject domain = QAndroidJniObject::fromString("10.3.56.54"); QAndroidJniObject username = QAndroidJniObject::fromString("1006"); QAndroidJniObject password = QAndroidJniObject::fromString("1234"); jint res = m_sipcall-&gt;callMethod&lt;jint&gt;("Login","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", domain.object&lt;jstring&gt;(), username.object&lt;jstring&gt;(),password.object&lt;jstring&gt;()); if (res!=0) return; QAndroidJniObject addrNum = QAndroidJniObject::fromString("1018"); res = m_sipcall-&gt;callMethod&lt;jint&gt;("Call","(Ljava/lang/String;)I",addrNum.object&lt;jstring&gt;()); </code></pre> <p>The "new QAndroidJniObject" returns non-empty,but the the following functions connot execute,why?</p> <p>3) I have tried to make the Context from c++ as a parameter of constructor function,but I found the code not running,why?</p> <pre><code>java: public SipCallSend(Context cnt){ this.context = cnt; } C++: QAndroidJniObject m_sipcall("com/comm/sipcall/SipCallSend","(Landroid/content/Context;)V",appctx.object&lt;jobject&gt;()); </code></pre> <p>4) According to QT5.2 API document,QAndroidJniObject provides a method named "callObjectMethod":</p> <pre><code>QAndroidJniObject myJavaString; ==&gt; "Hello, Java" QAndroidJniObject mySubstring = myJavaString.callObjectMethod("substring", "(II)Ljava/lang/String;" 7, 10); </code></pre> <p>But when I use it as following, the IDE prompts me the parameter are incorrect,why?</p> <pre><code>jint res = m_sipcall-&gt;callMethod&lt;jint&gt;("Login","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", domain.object&lt;jstring&gt;(), username.object&lt;jstring&gt;(),password.object&lt;jstring&gt;()); </code></pre> <p>Thanks...</p>
469,653
0
<p>Static objects are destroyed in the reverse of the order in which they're constructed (e.g. the first-constructed object is destroyed last), and you can control the sequence in which static objects are constructed, by using the technique described in Item 47, "<strong>Ensure that global objects are initialized before they're used</strong>" in Meyers' book <em>Effective C++</em>.</p> <blockquote> <p>For example to specify in some way that I would like a certain object to be destroyed last, or at least after another static onject?</p> </blockquote> <p>Ensure that it's constructed before the other static object.</p> <blockquote> <p>How can I control the construction order? not all of the statics are in the same dll.</p> </blockquote> <p>I'll ignore (for simplicity) the fact that they're not in the same DLL.</p> <p>My paraphrase of Meyers' item 47 (which is 4 pages long) is as follows. Assuming that you global is defined in a header file like this ...</p> <pre><code>//GlobalA.h extern GlobalA globalA; //declare a global </code></pre> <p>... add some code to that include file like this ...</p> <pre><code>//GlobalA.h extern GlobalA globalA; //declare a global class InitA { static int refCount; public: InitA(); ~InitA(); }; static InitA initA; </code></pre> <p>The effect of this will be that any file which includes GlobalA.h (for example, your GlobalB.cpp source file which defines your second global variable) will define a static instance of the InitA class, which will be constructed before anything else in that source file (e.g. before your second global variable).</p> <p>This InitA class has a static reference counter. When the first InitA instance is constructed, which is now guaranteed to be before your GlobalB instance is constructed, the InitA constructor can do whatever it has to do to ensure that the globalA instance is initialized.</p>
12,698,394
0
On the fly website manipulation using <p>I am trying to work out if I can alter the functionality of a website preferably through vba (access) or any other way that I can centrally manage. What I am trying to achieve is, depending on permissions, I would like users to log onto a website and the website is then changed on the fly to stop the user using normal functions of the website. For example some users have access to a submit button while others do not.</p> <p>I have seen that you can use VBA to parse websites and auto logon. I'm just not sure if its capable of doing any local scripting like greasemonkey does. </p> <p>Maybe I am looking at this wrong and can achieve this at the firewall level instead of running website scripts.</p> <p>Any ideas?</p>
12,427,493
0
Programmatically check for a change in a class in C# <p>Is there a way to check for the size of a class in C#?</p> <p>My reason for asking is:</p> <p>I have a routine that stores a class's data in a file, and a different routine that loads this object (class) from that same file. Each attribute is stored in a specific order, and if you change this class you have to be reminded of these export/import routines needs changing.</p> <p>An example in C++ (no matter how clumsy or bad programming this might be) would be the following:</p> <pre><code>#define PERSON_CLASS_SIZE 8 class Person { char *firstName; } </code></pre> <p>...</p> <pre><code>bool ExportPerson(Person p) { if (sizeof(Person) != PERSON_CLASS_SIZE ) { CatastrophicAlert("You have changed the Person class and not fixed this export routine!") } } </code></pre> <p></p> <p>Thus before compiletime you need to know the size of Person, and modify export/import routines with this size accordingly.</p> <p>Is there a way to do something similar to this in C#, or are there other ways of "making sure" a different developer changes import/export routines if he changes a class.</p> <p>... Apart from the obvious "just comment this in the class, this guarantees that a developer never screws things up"-answer.</p> <p>Thanks in advance.</p>
18,578,396
0
<p>You want a dynamic list of files(.txt,.tpl,.htm,.json), to avoid a change in JS source code to add more files. </p> <p>I don't know if is there a way to do that, but you must take care about the time that will take to download all this files. I suggest you to create a json file with all files that you want to download, and iterate through this array of files using ajax to get them. </p> <p>If you are try to get all module inside a directory, you need to create a js file: <code>&lt;package-all&gt;.js</code> that encapsulate an <code>require([all files],function());</code> for example.</p> <p>I believe that this is the only way to solve this.</p>
6,238,630
0
<p>The <a href="http://tips4java.wordpress.com/2008/11/06/wrap-layout/">Wrap Layout</a> might be a solution for you. It automatically moves components to the next line when a line is full.</p>
35,447,296
1
Trying to filter by an intermediate table <p>I'm trying to do this query</p> <pre><code>subsidiaries = self.con.query(Subsidiary)\ .options(joinedload(Subsidiary.commerce)\ .joinedload(Commerce.commerce_tags))\ .filter(CommerceTag.tag_id == id) </code></pre> <p>But it doesn't work, so to explain:</p> <p>The relationship between tables are:</p> <p><a href="https://i.stack.imgur.com/aH8Su.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aH8Su.png" alt="Relationship"></a></p> <p>I just want to obtain all the subsidiaries of all the commerces that has an specific tag, i want to do it with Subsidiary has the base class (i know that if i use Commerce it will be more easier), the reason is 'cause i convert it to a json value with the next format:</p> <pre><code>"subsidiaries": [ { "id": 1, "name": "some_name", "commerce": { "id": 1, "name": "Commerce Name" } } ] </code></pre> <p>Well, i can do the query with Commerce has base class, but i think that maybe iterating the commerces to obtain the subsidiaries is more expensive that doing it in the query.</p> <p>I don't want to load CommerceTag but i had it in joinedload 'cause it doesn't work with Join method.</p> <p>I need some help to do this :(</p>
29,169,321
0
Relationship between classes when using LINQ to SQL (no relationship in the DB) <p>I have two tables in my database -> Activities and Customers. Each Activity has a CustomerId, however the designers of the database haven't added any foreign key constraints. </p> <p>I want to be able to write </p> <pre><code>activity.Customer.Name //Returns name of the customer </code></pre> <p>So I need a way of telling LINQ to SQL to map the CustomerId in the Activity object to the correct Customer object.</p> <p>I could of course do :</p> <pre><code>var customers = db.Customers; var activities = db.Activities; </code></pre> <p>And then manually map them to each other, but that would be a pain...</p> <p>Is this is possible? Adding foreign key constraints is unfortunately not an option. </p>
31,899,013
0
<p>I think it wp bug. Add that to functions.php </p> <pre><code>add_filter('redirect_canonical', 'disable_custom_redirect'); function disable_custom_redirect ($redirect_url) { global $post; $ptype = get_post_type($post); if ($ptype == 'catalog') $redirect_url = false; return $redirect_url; } </code></pre>
11,413,176
0
ORA-06550 Error in PL/SQL <p>Well I am trying to run this script in PL/SQL. But I am constantly getting errors, I tried replacing single quotes with double quotes but no use. </p> <pre><code>ACCEPT p_name PROMPT "Enter Customer Name: " VARIABLE g_output VARCHAR2(200) DECLARE v_street VARCHAR2(30); v_city VARCHAR2(20); v_prov VARCHAR2(20); v_postal VARCHAR2(10); BEGIN SELECT cstreet, ccity, cprov, cpostal INTO v_address,v_city,v_state,v_zip FROM customer WHERE cname = "&amp;p_name"; :g_output := "&amp;p_name" || " " ||v_street || " " || v_city; :g_output := :g_output " " || v_prov || " " || v_postal; END; / PRINT g_output </code></pre> <p>Error:</p> <pre><code>Enter Customer Name: Ankur Kaushal old 10: WHERE cname = "&amp;p_name"; new 10: WHERE cname = "Ankur Kaushal"; old 11: :g_output := "&amp;p_name" || " " ||v_street || " " || v_city; new 11: :g_output := "Ankur Kaushal" || " " ||v_street || " " || v_city; :g_output := :g_output " " || v_prov || " " || v_postal; * ERROR at line 12: ORA-06550: line 12, column 27: PLS-00103: Encountered the symbol " " when expecting one of the following: . ( * @ % &amp; = - + ; &lt; / &gt; at in is mod remainder not rem &lt;an exponent (**)&gt; &lt;&gt; or != or ~= &gt;= &lt;= &lt;&gt; and or like between || indicator multiset member SUBMULTISET_ The symbol "." was substituted for " " to continue. Input truncated to 14 characters G_OUTPUT -------------------------------------------------------------------------------- </code></pre> <p>Any mistake I am making here?</p>
27,010,089
0
How to integrate rest Api with Magento <p>Hello I have Third Party REST API And I want to integrate that REST API with my Magento Project so, is that Possible in Magento?? And If Yes then how to integrate it in my Magento Project Please Help...... Thank in advance</p>
16,862,590
0
<p>Check this question: <a href="http://stackoverflow.com/questions/16052758/kendoui-uploader-remove">KendoUI Uploader Remove</a></p> <p>For me, changing the return type did it.</p> <p>From</p> <pre><code>public ActionResult RemoveFile(string[] fileNames) { return Content(""); } </code></pre> <p>To</p> <pre><code>public ActionResult RemoveFile(string[] fileNames) { return Json(""); } </code></pre> <p>I left my SaveFile() function with <code>return Content("");</code></p>
28,491,762
0
<blockquote> <p>I have read the documentation and it seems like if this flag is set when calling an Activity, if the user presses the back button or that Activity is finished(), it still remains on the stack.</p> </blockquote> <p>No, the Activity will not remain on the stack, but its entry will be shown in the recent task list, you can click on that entry to re-launch this Activity just as you re-launch your application.</p>
4,757,835
0
<p>A bit late, but maybe it will still help you or someone else looking for this, the messages are themed in <a href="http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_status_messages/6" rel="nofollow">theme_status_messages()</a> but you don't have any context about them at this point. However...</p> <p>Form errors are added through <a href="http://api.drupal.org/api/drupal/includes--form.inc/function/form_set_error/6" rel="nofollow">form_set_error()</a>, which stores them in an static array according to the form field name, you can access that through <a href="http://api.drupal.org/api/drupal/includes--form.inc/function/form_get_errors/6" rel="nofollow">form_get_errors()</a>.</p> <p>Now, you can load these errors and then look up the error messages in that error array and use the key as the id.</p>
35,207,148
0
<p><strong>For MVC6</strong>, You need to decorate the controllers with <code>Area</code> attribute. if you do not prefer to add this to individual controllers, you may simply create a base call which has Area decoration and inherit your other controllers from that.</p> <pre><code>[Area("Admin")] public class AdminArea : Controller { } public class OrdersController : AdminArea { public IActionResult Index() { return View(); } } public class ProductsController : AdminArea { public IActionResult Index() { return View(); } } </code></pre> <p><strong>MVC 5 and below</strong></p> <p>You do not need to put that attribute on your controller name, You can simply specify the area name in the area route registration.</p> <pre><code>public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Admin_default", "Admin/{controller}/{action}/{id}", new { action = "Index", controller= "YourDefaultCtrl", id = UrlParameter.Optional } ); } </code></pre>
27,493,867
0
<p>At first I thought you needed to include <code>ob_end_clean</code> like:</p> <pre><code>ob_start(); call_user_func( 'test', $args ); $ret_func = ob_get_clean(); $data = preg_replace( $re, $ret_func, $data); ob_end_clean(); </code></pre> <p>But then I ran a basic test myself doing this:</p> <pre><code>&lt;?php $i = 0; for($i=0; $i&lt;10; $i++) { ob_start(); test(); $ret_func = ob_get_clean(); echo '&lt;p&gt;' . $ret_func . '&lt;/p&gt;'; ob_end_clean(); //tried with this commented out as well echo '&lt;p&gt;' . $ret_func . '&lt;/p&gt;'; } function test() { echo rand(0,100); } ?&gt; </code></pre> <p>And it made no difference if I included <code>ob_end_clean</code> or not. So your problem is probably actually how you are rebuilding the <code>args</code> array in each iteration of the loop.</p>