pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
33,929,120
1
Sharing heavy calculations result when using DRF serializer with many=True <p>There is a simple DRF serializer which:</p> <pre><code>class MySeriliazer(serializers.Serializer): some_field = serializers.SerializerMethodField(read_only=True) def get_some_field(self, obj): some_list = utils.do_some_heavy_calculations() return some_list[obj.some_field] </code></pre> <p>As you see I have a <code>some_field</code> field which value is calculated via some function.</p> <p>When I get a single object it's a big of a problem, but when I use this serializer with <code>many=True</code> thus receiving multiple objects <code>do_some_heave_calculations</code> get called for each, which is very expensive.</p> <p>Moreover sometimes there are few fields which use the same heavy function. like:</p> <pre><code>class MySeriliazer(serializers.Serializer): some_field1 = serializers.SerializerMethodField(read_only=True) some_field2 = serializers.SerializerMethodField(read_only=True) def get_some_field1(self, obj): some_list = utils.do_some_heavy_calculations() return some_list[obj.some_field1] def get_some_field2(self, obj): some_list = utils.do_some_heavy_calculations() return some_list[obj.some_field2] </code></pre> <p>Function is called twice for each object. Not good. What are the options to solve this? Sure enough I can grab these results from some cache which is updated every second. But I think it's possible to extract these calculations somehow and share them during the serialization process.</p> <p>If needed - I use DRF generic views.</p>
29,540,871
0
Restore Purchase Not Working <p>I'm trying to add a restore option to my app, I have a button that calls this functions:</p> <pre><code>SKPaymentQueue.defaultQueue().addTransactionObserver(self) SKPaymentQueue.defaultQueue().restoreCompletedTransactions() </code></pre> <p>And I'm using the <em>paymentQueueRestoreCompletedTransactionsFinished</em> function, the problem is that the function fire every time the restore button is hit whether or not the user had bought the item. How can I check if the restore was successful and that the user had bought the item? </p>
6,580,639
0
Newbie and PHP Frameworks <p>I am a newbie in PHP Frameworks and would like to share/discuss some experience with you guys. Getting straight to the point, what I understand till now (from a newby stand of point is this):</p> <ul> <li>CodeIgniter + Doctrine + Twigg = Symfony:</li> <li><p>Zend + Doctrine + Twigg = Symfony</p> <ol> <li>Symfony 2, uses php5.3 (I realy like namespace stuff remind me .Net) but it lucks of tutorials right now (only partial jobeet translation to ver2)</li> <li>I enjoy CI community and noumerous tutorials, plus using Doctrine + Twigg I could achive the same with Symfony. </li> <li>Zend is more enterprise with lots of tutorials, but more difficult to grasp than CI.</li> </ol></li> </ul> <p>So the question is should I start with CI + Doctrine or learn directly Symfony2? Am I correct with the above assumptions?</p>
23,477,624
0
<p>You are declaring an array, if you want to add another array inside the first one, try something like this: </p> <pre><code>$obj = array( array("Office", "Orders", array("role" =&gt; "style")), array("Jacksonville", 1254, "magenta"), array("Orlando", 653, "blue"), array("Sarasota", 789, "green"), array("Stuart", 468, "yellow"), array("Tampa", 982, "cyan")); </code></pre>
3,421,501
0
<p>The text box has a <code>TabIndex</code> of 0 and <code>TabStop</code> set to true. This means that the control will be given focus when the form is displayed.</p> <p>You can either give another control the 0 <code>TabIndex</code> (if there is one) and give the text box a different tab index (>0), or set <code>TabStop</code> to false for the text box to stop this from happening.</p>
34,517,734
0
<p>So... May be it should be in <code>module Validatable</code>?</p> <ol> <li>Generate Validatables controler with this <a href="https://github.com/plataformatec/devise/wiki/Tool:-Generate-and-customize-controllers" rel="nofollow">Tools</a></li> <li>Customize this controller something like this: (Code of this module You could see <a href="https://github.com/plataformatec/devise/blob/master/lib/devise/models/validatable.rb#L57" rel="nofollow">This</a>)</li> </ol> <p>...</p> <pre><code>base.class_eval do validates_presence_of :email, if: :email_required? validates_uniqueness_of :email, allow_blank: true, if: :email_changed? validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed? validates_presence_of :password, if: :password_required? validates_confirmation_of :password, if: :password_required? validates_length_of :password, within: password_length, allow_blank: true validates_presence_of :question, if: :question_required? validates_format_of :question, with: answered_regexp, if: :answered_changed? end end ... def email_required? true end def question_required? true end </code></pre> <p>This is not complied solution, but I hope it help You...</p>
13,635,072
0
<p>Compilation is slowed down a bit because of the way that CodeContracts work. There is an IL re-writer that injects code into your methods based on the contracts that you specify. This happens after the C# compiler has come along and generated the IL for your assembly. </p> <p>The runtime performance difference is quite small and will not affect your code in a noticeable way. Unless you are developing some real-time stock trading system, I seriously wouldn't even worry about it.</p> <p>As far as disabling Code Contracts in Production, I would far rather have the added protection of Code Contracts that some possibly obscure error. An error in the code contract will tell you exactly where and why the Contract was violated as opposed to having to dig down in some deep call-stack just because some bad data was passed in 5 levels up the call-stack tree.</p> <p>If you are using or are planning to use <code>Contract.Requires&lt;TException&gt;</code> and do not enable 'Runtime Contract Checking', you'll get a runtime failure about the IL rewriter needing to be bound to the usage of Code Contracts. You will then be required to enable Runtime Contract Checking to get this to work.</p> <p>IMHO, the use of <code>Contract.Requires&lt;TException&gt;()</code> is far more useful than <code>Contract.Requires()</code> since you have control over the type of exception thrown.</p> <p>EDIT: One thing I forgot to add is that the IL Rewriter is completely independent of the C# compiler and there are no dependencies between the two.</p>
24,424,720
0
<p>Your PHP does not have the LDAP extension installed or enabled. It's needed for AD authentication. Your distribution probably has a separate package for it. Eg. php5-ldap or something.</p>
26,653,691
0
Android app integrating Spreadsheets API <p>My app accesses a spreadsheet from a user account, previously authenticad via the Google Plus Sign in button, all appropriate scopes and credentials have been selected in the Google API console, and I have a logged in GoogleApiClient with which I can access the user profile information.</p> <p>When I attempt to initialize a SpreadSheetService object:</p> <pre><code>SpreadsheetService service = new SpreadsheetService("SpreadSheetImport-v1"); </code></pre> <p>I get the exception related to the class com.google.common.collect.Maps:</p> <pre><code>10-30 13:50:34.280: D/SHEETS(17433): TRYING TO GET SPREADSHEET LIST! 10-30 13:50:34.280: D/AndroidRuntime(17433): Shutting down VM 10-30 13:50:34.280: E/AndroidRuntime(17433): FATAL EXCEPTION: main 10-30 13:50:34.280: E/AndroidRuntime(17433): Process: com.pazodediarada.dc, PID: 17433 10-30 13:50:34.280: E/AndroidRuntime(17433): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/collect/Maps; 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.google.gdata.wireformats.AltRegistry.&lt;init&gt;(AltRegistry.java:118) 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.google.gdata.wireformats.AltRegistry.&lt;init&gt;(AltRegistry.java:100) 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.google.gdata.client.Service.&lt;clinit&gt;(Service.java:555) 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.pazodediarada.dc.SpreadSheetImport.getSpreadSheetDeutschList(SpreadSheetImport.java:356) 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.pazodediarada.dc.SpreadSheetImport.onClick(SpreadSheetImport.java:146) 10-30 13:50:34.280: E/AndroidRuntime(17433): at android.view.View.performClick(View.java:4438) 10-30 13:50:34.280: E/AndroidRuntime(17433): at android.view.View$PerformClick.run(View.java:18422) 10-30 13:50:34.280: E/AndroidRuntime(17433): at android.os.Handler.handleCallback(Handler.java:733) 10-30 13:50:34.280: E/AndroidRuntime(17433): at android.os.Handler.dispatchMessage(Handler.java:95) 10-30 13:50:34.280: E/AndroidRuntime(17433): at android.os.Looper.loop(Looper.java:136) 10-30 13:50:34.280: E/AndroidRuntime(17433): at android.app.ActivityThread.main(ActivityThread.java:5001) 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.reflect.Method.invoke(Native Method) 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 10-30 13:50:34.280: E/AndroidRuntime(17433): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 10-30 13:50:34.280: E/AndroidRuntime(17433): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.collect.Maps" on path: DexPathList[[zip file "/data/app/com.pazodediarada.dc-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.pazodediarada.dc-2, /vendor/lib, /system/lib]] 10-30 13:50:34.280: E/AndroidRuntime(17433): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 10-30 13:50:34.280: E/AndroidRuntime(17433): ... 14 more 10-30 13:50:34.280: E/AndroidRuntime(17433): Suppressed: java.lang.ClassNotFoundException: com.google.common.collect.Maps 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.Class.classForName(Native Method) 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 10-30 13:50:34.280: E/AndroidRuntime(17433): at java.lang.ClassLoader.loadClass(ClassLoader.java:504) 10-30 13:50:34.280: E/AndroidRuntime(17433): ... 15 more 10-30 13:50:34.280: E/AndroidRuntime(17433): Caused by: java.lang.NoClassDefFoundError: Class "Lcom/google/common/collect/Maps;" not found 10-30 13:50:34.280: E/AndroidRuntime(17433): ... 19 more </code></pre> <p>My IDE is Eclipse ADT, I have imported the google api libraries as per <a href="https://developers.google.com/google-apps/spreadsheets/#retrieving_a_list_of_spreadsheets" rel="nofollow">Google Sheets Api</a>, both with this method described there or adding external jars, obtaining the same results.</p> <p>Any ideas?</p>
10,084,114
0
<p>If you don't get error on the declaration of dataProvider type T is defined as a parameter in a class declaration.<br> If so you should remove from method declarations. </p> <p>Good luck!</p>
22,759,218
0
<p>Put your nested loop into a function and return true/false whenever you want to break the loop?</p> <pre><code>bool Function() { for(int i = 0; i &lt; 10; ++i) { for(int j = 0; j &lt; 10; ++j) { if (error) { MessageBox.Show("THE ITEM ID DOES NOT EXIST.!"); return false; } } } return true; } </code></pre>
10,951,319
0
Canvas versus DOM - What is the most efficient image display method in HTML5? <p>StackOverflow users</p> <p>While making a html5 application/website, for such cases as an image gallery, where a large number of images are displayed sequentially or at the same time in the browser, is the use of the canvas element justified?</p> <p>As long as we are only talking about presenting an image, is there any point in using a canvas and drawing the image on it instead of using the DOM element &lt; img > tag? There will also be some image manipulation, like CSS3 transformations/moving/scaling/zooming and gesture recognition (drag, touch/tap, maybe pinch, etc.) which, as far as I know, are applicable to both the canvas and the img tags.</p> <p>It would also be important to keep things as much "html5"-ish as possible and also taking performance into account. For example, it would matter if in the future the canvas element will be more and more used and optimized by the browsers and it would also matter if for the time being the &lt; img > is much faster.</p> <p>Since we are considering developing an universal html5 application, working on desktops and also on mobile devices, performance and speed are a very important factor. However, the tests comparing canvas and &lt; img > were targeting mostly javascript browser games. In this case, the animation is not that important as the memory consumption and overall performance.</p> <p>Are there any resources/studies regarding this particular aspect?</p>
7,067,802
0
<p>(EDIT: CKoenig has a nice answer.)</p> <p>Hm, I didn't immediately see a way to do this either.</p> <p>Here's a non-type-safe solution that might provide some crazy inspiration for others. </p> <pre><code>open System.Collections.Generic module Dict = type Dictionary&lt;'K, 'V&gt; with member this.Difference&lt;'K2, 'T when 'K2 : equality&gt;(that:Dictionary&lt;'K2, 'T&gt;) = let dict = Dictionary&lt;'K2,'V&gt;() for KeyValue(k, v) in this do if not (that.ContainsKey(k |&gt; box |&gt; unbox)) then dict.Add(k |&gt; box |&gt; unbox, v) dict open Dict let d1 = Dictionary() d1.Add(1, "foo") d1.Add(2, "bar") let d2 = Dictionary() d2.Add(1, "cheese") let show (d:Dictionary&lt;_,_&gt;) = for (KeyValue(k,v)) in d do printfn "%A: %A" k v d1.Difference(d2) |&gt; show let d3 = Dictionary() d3.Add(1, 42) d1.Difference(d3) |&gt; show let d4 = Dictionary() d4.Add("uh-oh", 42) d1.Difference(d4) |&gt; show // blows up at runtime </code></pre> <p>Overall it seems like there may be no way to unify the types <code>K</code> and <code>K2</code> without also forcing them to have the same equality constraint though...</p> <p>(EDIT: seems like calling into .NET which is equality-constraint-agnostic is a good way to create a dictionary in the absence of the extra constraint.)</p>
22,417,084
0
<p>If you actually add a tip, it works fine</p> <pre><code>$(".well").attr("title", "This is a tooltip"); </code></pre> <p><a href="http://jsfiddle.net/78PVu/1/" rel="nofollow"><strong>FIDDLE</strong></a></p>
32,437,204
0
<p>I hope you access your fields by pair of get/set methods. Just make null-checking logic inside getter:</p> <pre><code>public Second getRelated(){ if( second == null ) return defaultValue; } </code></pre> <p>Please also see this answer <a href="http://stackoverflow.com/a/757330/149818">http://stackoverflow.com/a/757330/149818</a></p>
32,728,760
0
Removing blue block of active hyperlink? <p>On a mobile device, when a hyperlink is clicked, a blue box appears for a brief second. It doesn't matter if the hyperlink is text or an image, it still appears. Is there a way to turn this off? </p> <p>I don't want to turn it off on all items. I just have some hyperlinks embedded in none rectangular images and i think it looks ugly.</p> <p>Thanks</p>
6,578,373
0
sleep in emacs lisp <h2>script A</h2> <pre><code> (insert (current-time-string)) (sleep-for 5) (insert (current-time-string)) </code></pre> <p><code>M-x eval-buffer</code>, two time strings are inserted with 5 secs apart</p> <h2>script B</h2> <p>some comint code (that add hook, and start process)</p> <pre><code> (sleep-for 60) ;delay a bit for process to finish (insert "ZZZ") </code></pre> <p><code>M-x eval-buffer</code>, "ZZZ" is inserted right away, without any time delay</p> <p>what might have happened? btw, it's Emacs 23.2 on Win XP</p>
26,551,335
0
<p>Assuming this data is in some kind of enumerable object you can do:</p> <pre><code>arrays, hashes = data.group_by(&amp;:class).values_at(Array, Hash) </code></pre> <p>However it feels wrong. Most likely you rather need to wrap each hash within its own array (so you can later to double iteration). If this is the case:</p> <pre><code>data.map! {|array_or_hash| Array.wrap(array_or_hash)} </code></pre>
9,777,543
0
<p>You mixing things. You either do this:</p> <pre><code>private void sumBtn_Click(object sender, EventArgs e) { int counter; int loopAnswer = 0; int number1 = int.Parse(number1Txtbox.Text); for (counter = 1; counter &lt;= 10; counter++) { loopAnswer += number1; //same as loopAnswer = loopAnswer + number1; } equalsBox.Text = loopAnswer.ToString(); } </code></pre> <p>or this:</p> <pre><code>private void sumBtn_Click(object sender, EventArgs e) { int counter = 1; int loopAnswer = 0; int number1 = int.Parse(number1Txtbox.Text); do { loopAnswer += number1; //same as loopAnswer = loopAnswer + number1; counter++; } while (counter &lt;= 10); equalsBox.Text = loopAnswer.ToString(); } </code></pre> <p>Also, the final answer (<code>equalsBox.Text = loopAnswer.ToString();</code>) should be out of the loop.</p>
35,151,361
0
<p>I think in your <code>django-shop/shop/money/__init__.py</code> rather than </p> <pre><code>from money_maker import MoneyMaker, AbstractMoney </code></pre> <p>you should either:</p> <pre><code> import .money_maker import MoneyMaker, AbstractMoney </code></pre> <p>or</p> <pre><code> import shop.money.money_maker import MoneyMaker, AbstractMoney </code></pre>
39,308,795
0
<p>TF-IDF as far as I understand is a feature. TF is term frequency i.e. frequency of occurence in a document. IDF is inverse document frequncy i.e frequency of documents in which the term occurs. </p> <p>Here, the model is using the TF-IDF info in the training corpus to estimate the new documents. For a very simple example, Say a document with word bad has pretty high term frequency of word bad in training set will sentiment label as negative. So, any new document containing bad will be more likely to be negative. </p> <p>For the accuracy you can manaually select training corpus which contains mostly used negative or positive words. This will boost the accuracy. </p>
25,774,307
0
<p>This code will not do what you want.</p> <p>While loop have to stop before popup. But as you popup outside of your loop after popup vi will be stopped. </p> <p>Insert the popup to your loop, put there case and put the popup inside the case. Connect time has elapsed Boolean to your case conditional terminal. Make sure you run the VI using arrow not continuous run option.</p>
31,214,674
0
<h2>1st method</h2> <p>If those parts are hardcoded you could simply change your links adding <code>../</code> before :</p> <p><code>path/to/my/assets/style.css</code></p> <p>would become</p> <p><code>../path/to/my/assets/style.css</code></p> <hr> <h2>2nd method</h2> <p>You could use <code>.htaccess</code> as Marc suggested (assuming your assets folder is <code>assets</code> :</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^course/assets/(.*) assets/$1 </code></pre> <p>Or using a redirection</p> <pre><code>RedirectMatch 303 /courses/assets(.*) /assets/$1 </code></pre> <blockquote> <p>Note 303 See Other response code which seems more appropriate <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4" rel="nofollow">http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4</a></p> </blockquote>
28,311,304
0
<p>I think you need to have a DatetimeIndex (rather than a MultiIndex):</p> <pre><code>In [11]: df1 = df.reset_index('status') In [12]: df1 Out[12]: status TUFNWGTP TELFS t070101 t070102 t070103 t070104 TUDIARYDATE 2003-01-03 emp 8155462.672158 2 0 0 0 0 2003-01-04 emp 1735322.527819 1 0 0 0 0 2003-01-04 emp 3830527.482672 2 60 0 0 0 2003-01-02 unemp 6622022.995205 4 0 0 0 0 2003-01-09 emp 3068387.344956 1 0 0 0 0 </code></pre> <p>then do a groupby with a monthly TimeGrouper <em>and</em> the status column:</p> <pre><code>In [13]: df1.groupby([pd.TimeGrouper('M'), 'status']).sum() Out[13]: TUFNWGTP TELFS t070101 t070102 t070103 t070104 TUDIARYDATE status 2003-01-31 emp 16789700.027605 6 60 0 0 0 unemp 6622022.995205 4 0 0 0 0 </code></pre>
38,850,163
0
SASS/SCSS Background-image loop with nth-child <p>I'm creating a portfolio section of my static website and I'd like a neat way of assigning background-image url:s without adding any classnames (image image-1, image image-2 etc.) or style tags in HTML, <strong>but rather use only scss with nth-child, if possible</strong>...</p> <p>Because the image divs are nested I have some problems assigning background-images using nth-child. I've created a JSFiddle to reproduce the problem (<strong>the image divs are nested inside rows</strong>).</p> <p>My image files are named like in the fiddle (image-1.jpg, image-2.jpg etc.).</p> <p>The fiddle -> <a href="https://jsfiddle.net/szmvfo4o/" rel="nofollow">https://jsfiddle.net/szmvfo4o/</a></p> <p>The loop:</p> <pre><code>@for $i from 1 through 3 { .row:nth-child(#{$i}) { .image:first-child { background-image: url(image-#{$i}.jpg); } .image:last-child { background-image: url(image-#{$i+1}.jpg); } } } </code></pre> <p>Full SCSS:</p> <pre><code>.item { float: left; width: 50%; height: 120px; padding: 10px; box-sizing: border-box; } .inner { width: 100%; height: 100%; } .image { width: 100%; height: 100%; background-size: cover; background-color: #fff; //background-image: url(https://source.unsplash.com/-sQ4FsomXEs/800x600); background-image: url(image-1.jpg); } @for $i from 1 through 3 { .row:nth-child(#{$i}) { .image:first-child { background-image: url(image-#{$i}.jpg); } .image:last-child { background-image: url(image-#{$i+1}.jpg); } } } </code></pre> <p>HTML:</p> <pre><code>&lt;div class="row"&gt; &lt;div class="item"&gt; &lt;div class="inner"&gt; &lt;div class="image"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="item"&gt; &lt;div class="inner"&gt; &lt;div class="image"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="item"&gt; &lt;div class="inner"&gt; &lt;div class="image"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="item"&gt; &lt;div class="inner"&gt; &lt;div class="image"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="item"&gt; &lt;div class="inner"&gt; &lt;div class="image"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="item"&gt; &lt;div class="inner"&gt; &lt;div class="image"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
13,495,137
0
<p>Here's one way using <code>GNU awk</code>:</p> <pre><code>awk -F "[()]" 'FNR==NR { a[$(NF-1)]++; next } !(gensub(/(.*),.*/,"\\1","g",$(NF-1)) in a)' File1 File2 </code></pre> <p>Results:</p> <pre><code>INSERT INTO Queue (course,student,registrationDate) VALUES ('BKE974','3421728825','1368144500'); INSERT INTO Queue (course,student,registrationDate) VALUES ('DQY359','7421758823','1375874278'); </code></pre>
21,785,969
0
<p>I see, you want the "unique" combinations of children, regardless of order.</p> <p>The following gets parents that are equivalent:</p> <pre><code>select m1.Parent as Parent1, m2.Parent as Parent2 from (select m.*, count(*) over (partition by Parent) as NumKids from #m m ) m1 join (select m.*, count(*) over (partition by Parent) as NumKids from #m m ) m2 on m1.ChildID = m2.ChildID group by m1.Parent, m2.Parent having count(*) = max(m1.NumKids) and max(m1.NumKids) = max(m2.NumKids); </code></pre> <p>We can now get what you want using this </p> <pre><code>with parents as ( select m1.Parent as Parent1, m2.Parent as Parent2 from (select m.*, count(*) over (partition by Parent) as NumKids from #m m ) m1 join (select m.*, count(*) over (partition by Parent) as NumKids from #m m ) m2 on m1.ChildID = m2.ChildID group by m1.Parent, m2.Parent having count(*) = max(m1.NumKids) and max(m1.NumKids) = max(m2.NumKids) ) select distinct m.* from (select min(Parent2) as theParent from parents group by Parent1 ) p join #m m on p.theParent = m.Parent; </code></pre> <p>If you want a new id instead of the old one, use:</p> <pre><code>select dense_rank() over (partition by m.Parent) as NewId, m.ChildID </code></pre> <p>in the <code>select</code>.</p>
5,957,868
0
<p>The docs on the repo were updated three days ago, changing the reference from 'socket.io' to 'socket.io-node', so it appears things are in flux.</p> <p>To get the functionality you need, you might check out eventedsocket at <a href="https://github.com/torgeir/eventedsocket" rel="nofollow">https://github.com/torgeir/eventedsocket</a> (npm install eventedsocket)</p> <p>From the README.md:</p> <p>Eventedsocket adds event like behavior to your socket.io connection, allowing for events to be sent from client(s) to server or server to client(s). Your custom events along with the desired data are communicated as json over whatever protocol socket.io might choose.</p>
17,047,305
0
<p>Each time you click, you call this function.</p> <pre><code>function tableClick(event){ $('#table').click(function(event){ alert(event.target.id); }); } </code></pre> <p>This part:</p> <pre><code>$('#table').click(function(event){ </code></pre> <p>attaches a click handler to the table. <strong>Every time you click</strong> you attach a new click handler to the table.</p>
3,951,226
0
<p>How about adding a '?2' to the tag?</p> <p><code>&lt;script src="a.js?2"&gt;&lt;/script&gt;</code></p> <p>The server should return the same file with or without the '?2', but the browser should see it as a different file and redownload. You can just change this query string whenever the file is changed.</p> <p>adapted from: <a href="http://blog.httpwatch.com/2007/12/10/two-simple-rules-for-http-caching/">http://blog.httpwatch.com/2007/12/10/two-simple-rules-for-http-caching/</a></p>
23,910,864
0
Building Angular App and embed on another page you didn't write <p>It is possible to build a JavaScript library, use JQuery and then embed it on another page. <a href="http://dublintech.blogspot.ie/2012/12/a-javascript-quiz.html" rel="nofollow">For example</a>...</p> <p>You can import the library...</p> <pre><code>&lt;link href="http://dublintech.github.com/JavaScript_Examples/jsquiz/css/jquiz.css" rel="stylesheet" type="text/css"&gt; &lt;script src="http://dublintech.github.com/JavaScript_Examples/jsquiz/js/jQuiz.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>You can then invoked a function from the library and even pass it a dom element </p> <pre><code>quizModule(quiz_questions, $('#intro')); </code></pre> <p>The library then can manipulate your dom element and hence your page.</p> <p>I was just wondering is possible to do something similar with AngularJS? </p> <p>So I could write a library / application in AngularJS and somebody could embed that in their page without using an iFrame?</p> <p>Thanks</p>
11,118,180
0
Use uasort to sort elements in an array <p>I have the following array</p> <pre><code>$array = array( 'note' =&gt; array('test', 'test1', 'test2', 'test3', 'test4'), 'year' =&gt; array('2011','2010', '2012', '2009', '2010'), 'type' =&gt; array('journal', 'conference', 'conference', 'conference','conference'), ); </code></pre> <p>And I would like to sort the elements using <code>uasort()</code> and array <code>year</code>.</p> <p>I did:</p> <pre><code>function cmp($a, $b) { if($a['year'] == $b['year']) return 0; return ($a['year'] &lt; $b['year']) ? -1 : 1; } uasort($array,'cmp'); print_r($array); </code></pre> <p>But the output is incorrect:</p> <pre><code>Array ( [type] =&gt; Array ( [0] =&gt; journal [1] =&gt; conference [2] =&gt; conference [3] =&gt; conference [4] =&gt; conference ) [year] =&gt; Array ( [0] =&gt; 2011 [1] =&gt; 2010 [2] =&gt; 2012 [3] =&gt; 2009 [4] =&gt; 2010 ) [note] =&gt; Array ( [0] =&gt; test [1] =&gt; test1 [2] =&gt; test2 [3] =&gt; test3 [4] =&gt; test4 ) ) </code></pre> <p>Desired output:</p> <pre><code>Array ( [type] =&gt; Array ( [0] =&gt; conference [1] =&gt; journal [2] =&gt; conference [3] =&gt; conference [4] =&gt; conference ) [year] =&gt; Array ( [0] =&gt; 2012 [1] =&gt; 2011 [2] =&gt; 2010 [3] =&gt; 2010 [4] =&gt; 2009 ) [note] =&gt; Array ( [0] =&gt; test2 [1] =&gt; test [2] =&gt; test1 [3] =&gt; test4 [4] =&gt; test3 ) ) </code></pre>
13,562,355
0
Predefined subject and body in EmailComposer <p>Is there any way to predefine body and subject of email in emailcomposer ios phonegap plugin? So far i found some group in google groups </p> <pre><code>window.plugins.emailComposer.showEmailComposer("My Subject","My Plain Text Body", "[email protected],[email protected]", "[email protected],[email protected]", "[email protected],[email protected]",false); </code></pre> <p>but i'm not sure how to connect that to my html page. I tried </p> <pre><code>cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]); </code></pre> <p>in my js file, but that shows emailcomposer page, which is unacceptable. How do i make user enter only email or recipient?</p> <p>UPD: I didnt look into emailcomposer.js, there is array [args], where i can define everything i need, but i'm not sure how to do that Tried this way, but that didnt help</p> <pre><code>var args = [toRecipients="[email protected]"]; </code></pre>
11,173,578
0
insert into data base by javascript <p>i have this code for get rss from other site </p> <pre><code>gfeedfetcher.prototype._displayresult=function(feeds){ var rssoutput=(this.itemcontainer=="&lt;li&gt;")? "&lt;ul&gt;\n" : "" gfeedfetcher._sortarray(feeds, this.sortstring) for (var i=0; i&lt;feeds.length; i++){ var itemtitle="&lt;a href=\"" + feeds[i].link + "\" target=\"" + this.linktarget + "\" class=\"titlefield\"&gt;" + feeds[i].title + "&lt;/a&gt;" var itemlabel=/label/i.test(this.showoptions)? '&lt;span class="labelfield"&gt;['+this.feeds[i].ddlabel+']&lt;/span&gt;' : " " var itemdate=gfeedfetcher._formatdate(feeds[i].publishedDate, this.showoptions) var itemdescription=/description/i.test(this.showoptions)? "&lt;br /&gt;"+feeds[i].content : /snippet/i.test(this.showoptions)? "&lt;br /&gt;"+feeds[i].contentSnippet : "" rssoutput+=this.itemcontainer + itemtitle + " " + itemlabel + " " + itemdate + "\n" + itemdescription + this.itemcontainer.replace("&lt;", "&lt;/") + "\n\n" } rssoutput+=(this.itemcontainer=="&lt;li&gt;")? "&lt;/ul&gt;" : "" this.feedcontainer.innerHTML=rssoutput } </code></pre> <p>then i need to insert title and linke of the new on table on data base this cod by javascript</p>
17,484,075
0
Change Fill property of Path control inside ListBox <p>I have a small question, I've created a <code>ListBox</code> that only contains 2 items. Each item is a <code>Path</code> control that has a <code>Fill</code> attribute set to Black.</p> <p>Now, what I'm trying to do is, change the colour of this Fill attribute when you select one of the items in the listbox... I would think this should be done with a <code>Style</code>. But when doing so, the style contains a <code>ContentPresenter</code> that maps to the Path and this ContentPresenter has no <code>Fill</code> attribute to change through the <code>IsSelected</code> trigger!</p> <p>So in other words, how can I still use a Style that maps the Fill attribute?</p> <p>My current XAML code of the <code>Window</code> in the <code>WPF</code> project:</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="XAMLPathStyleProblem.MainWindow" x:Name="Window" Title="MainWindow" Width="640" Height="480"&gt; &lt;Window.Resources&gt; &lt;Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="Background" Value="Transparent"/&gt; &lt;Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt; &lt;Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/&gt; &lt;Setter Property="Padding" Value="2,0,0,0"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListBoxItem}"&gt; &lt;Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"&gt; &lt;ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsSelected" Value="true"&gt; &lt;Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/&gt; &lt;/Trigger&gt; &lt;MultiTrigger&gt; &lt;MultiTrigger.Conditions&gt; &lt;Condition Property="IsSelected" Value="true"/&gt; &lt;Condition Property="Selector.IsSelectionActive" Value="false"/&gt; &lt;/MultiTrigger.Conditions&gt; &lt;Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/&gt; &lt;/MultiTrigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; &lt;Grid x:Name="LayoutRoot"&gt; &lt;ListBox x:Name="ImageBar" ItemContainerStyle="{DynamicResource ListBoxItemStyle}"&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;StackPanel Orientation="Horizontal" VerticalAlignment="Top" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBoxItem&gt; &lt;Path Data="M15.992466,14.680105C20.892824,14.680104 23.97299,17.360288 28.013305,17.360288 31.943504,17.360288 34.333683,14.680104 39.994102,14.680105 44.274425,14.680104 48.804641,17.000391 52.034961,21.0308 41.454162,26.831151 43.174373,41.942682 53.865043,45.983101 52.394974,49.24342 51.694851,50.703518 49.794819,53.583672 47.154625,57.614079 43.424389,62.624561 38.803959,62.664604 34.703705,62.704647 33.643696,59.994431 28.073246,60.024464 22.50292,60.054249 21.342806,62.714657 17.23254,62.674614 12.622241,62.634571 9.0819604,58.104115 6.441766,54.083717 -0.95864094,42.822647 -1.7287129,29.611443 2.8315349,22.590761 6.0717456,17.600301 11.19209,14.680104 15.992466,14.680105z M38.751411,0C39.321331,3.8093758 37.761547,7.538764 35.701835,10.178331 33.502144,12.997869 29.702673,15.197509 26.033186,15.077528 25.373277,11.438125 27.093038,7.6887398 29.172746,5.1591539 31.462427,2.3696117 35.39188,0.23996067 38.751411,0z" Fill="Black" /&gt; &lt;/ListBoxItem&gt; &lt;ListBoxItem&gt; &lt;Path Data="M32.127438,4.0459317E-05C34.679321,-0.0059787218,51.370113,0.63573532,60.553993,18.050023L60.522991,18.050023 60.543671,18.086075C61.200066,19.24132 68.004066,31.93957 59.575981,47.967091 59.575981,47.967091 51.176838,64.148377 30.558096,63.870453L29.65756,63.847004 29.649204,63.861397C29.644096,63.870198,29.641504,63.874661,29.641504,63.874661L29.638971,63.874695 29.681444,63.800747C30.804413,61.84562,39.865662,46.068413,42.345753,41.710415L42.378082,41.653572 42.392643,41.638874 42.472183,41.501145 42.692501,41.246766C44.087284,39.55642,45.09919,37.538369,45.595421,35.325478L45.613995,35.233231 45.681602,34.931549C45.857914,34.084336,45.977459,33.046578,45.939392,31.839535L45.927822,31.607016 45.927765,31.604247 45.927345,31.597495 45.913135,31.311926 45.901112,31.172703 45.89138,31.015126 45.867527,30.783802 45.865814,30.76396 45.8638,30.747662 45.831325,30.432713C45.783504,30.046782,45.720222,29.665644,45.64212,29.289938L45.605244,29.129017 45.579826,29.001641C45.3101,27.769034 44.871658,26.423209 44.200989,24.977549 43.870582,24.491171 43.539108,24.000555 43.182049,23.514327L42.899601,23.140976 60.287002,18.042616C60.287002,18.042616,39.292564,18.022913,34.351002,18.039915L34.393581,18.050023 34.172077,18.050023C33.849613,18.050023,33.54248,18.050023,33.252323,18.050023L33.158501,18.050023 32.880497,18.023783C32.497307,17.992794 32.109821,17.977 31.718649,17.977 31.350422,17.977 30.985464,17.990992 30.624279,18.018473L30.292705,18.050023 30.278829,18.050023C30.225145,18.050023 30.197481,18.050023 30.197481,18.050023 30.197481,18.050023 30.175093,18.049284 30.131918,18.049599 29.747402,18.052403 27.714258,18.138693 25.166611,19.573328L25.156681,19.579142 25.090729,19.612418C22.198151,21.138638,19.8955,23.632718,18.613605,26.663617L18.496868,26.959704 5.5749997,14.177C5.5749997,14.177,15.021078,30.765849,17.85829,35.692574L17.988001,35.917668 18.035503,36.093228C19.728666,42.05547 25.213291,46.422997 31.718649,46.422997 32.332252,46.422997 32.936783,46.384125 33.529907,46.308712L33.816097,46.268658 29.596954,63.874993 29.542429,63.874833C28.213777,63.865578 13.814976,63.407895 4.1510181,48.093563 4.1510176,48.093563 -5.6624084,32.728032 4.8882693,15.012328L5.3907794,14.192161 5.3934535,14.187385C5.6228327,13.780242 13.109029,0.74591898 31.796461,0.0057129142 31.796461,0.0057133239 31.911178,0.00055203911 32.127438,4.0459317E-05z" Fill="Black" /&gt; &lt;/ListBoxItem&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre>
20,939,963
0
Clean / SEO friendly urls for e107 system version 1.0.4 <p>I have searched all over the net and this site too ( trust me on that :( ) but couldn't find a simpler solution instead of manual <code>.htaccess</code> rewrite for every single url.</p> <p>So ... Is there a plugin or easier way, to rewrite <strong>all</strong> e107 systems urls as SEO friendly ones?</p> <p>I am using v1.0.4 ( since the 2.0 is still in <em>alpha</em> stage ).</p> <p>I just hate see them as</p> <p><img src="https://i.stack.imgur.com/wKxF8.png" alt="enter image description here"></p> <p>instead of just <code>/news/</code> or</p> <p><img src="https://i.stack.imgur.com/6CtiO.png" alt="enter image description here"></p> <p>instead of just <code>/forum/</code> etc.</p>
36,192,839
0
MYSQL - ON DUPLICATE KEY does not update <p>I having been having the worst luck with updating and inserting into a database. My insert into a database works perfectly, i just cannot update.</p> <p>I have tired two seperate queries one for update the other insert, but updating never works. I am now using the ON DUPLICATE KEY trigger and once again the information just adds a record each time instead of updating. Where am i going wrong? I have been working on this for a day and half now and can't seem to get anywhere. newbee problems!</p> <pre><code> &lt;?php $Cust_ID = $_SESSION["CustomerID"]; if (isset($_POST['Update'])) { $c_fname = $_POST['fname']; $c_lname = $_POST['lname']; $c_email = $_POST['email']; $c_phone = $_POST['phone']; // Save $_POST to $_SESSION //query $insert_det = "INSERT INTO Cus_acc_details(CUS_Fname,CUS_Lname,Cus_Email,CUS_Phone) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE CUS_Fname = '$c_fname', Cus_Lname = '$c_lname'"; $stmt = mysqli_prepare($dbc, $insert_det); //new // $stmt = mysqli_prepare($dbc, $insert_c); //debugging //$stmt = mysqli_prepare($dbc, $insert_c) or die(mysqli_error($dbc)); mysqli_stmt_bind_param($stmt, 'sssi', $c_fname, $c_lname, $c_email, $c_phone); /* execute query */ $r = mysqli_stmt_execute($stmt); // if inserted echo the following messges if ($r) { echo "&lt;script&gt; alert('registration sucessful')&lt;/script&gt;"; } } else { echo "&lt;b&gt;Oops! Your passwords do not &lt;/b&gt;"; } ?&gt; </code></pre> <p>HTML</p> <pre><code>&lt;section class="container"&gt; &lt;form id="myform " class="Form" method="post" action="Cus_Account.php?c_id=&lt;?php echo $c_id ?&gt;" accept-charset="utf-8"&gt; &lt;!-- &lt;div id="first"&gt;--&gt; &lt;input type="text" id="fname" name="fname" value="&lt;?php echo $_SESSION['fname']; ?&gt;" required&gt; &lt;input type="text" id="lname" name="lname" value="&lt;?php echo $_SESSION['lname']; ?&gt;" required&gt; &lt;input type="text" id="email" name="email" value="&lt;?php echo $_SESSION['Cus_Email']; ?&gt;" required&gt; &lt;input type="number" id="phone" name="phone" value="&lt;?php echo $_SESSION['phone']; ?&gt;" required&gt; &lt;input type="submit" name="Update" value="Update"&gt; &lt;br&gt; &lt;/form&gt; </code></pre> <p>both the Customer_id and Cus-_email field's are set as unique on the bd, however, records keep inserting into the db. any help would be appreciated.</p> <p>SHOW CREATE</p> <pre><code>CREATE TABLE `Cus_acc_details` ( `CustomerID` tinyint(11) NOT NULL AUTO_INCREMENT, `AcctId` varchar(100) NOT NULL, `CUS_Fname` varchar(45) DEFAULT NULL, `Cus_Lname` varchar(45) DEFAULT NULL, `CUS_Phone` varchar(45) NOT NULL, `Cus_Email` varchar(200) NOT NULL, PRIMARY KEY (`CustomerID`), UNIQUE KEY `CustomerID` (`CustomerID`), UNIQUE KEY `CustomerID_2` (`CustomerID`,`Cus_Email`) ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=outfit </code></pre>
13,681,489
0
<p><a href="https://developer.chrome.com/extensions/content_scripts.html#execution-environment" rel="nofollow">Execution environment</a> of <a href="https://developer.chrome.com/extensions/content_scripts.html" rel="nofollow">Content Scripts</a> ensure content scripts can communicate among themselves</p> <p><strong>Ex:</strong></p> <pre><code>"content_scripts": [ { "matches": ["&lt;all_urls&gt;"], "js": ["myscript.js","myscript1.js"] } ] } </code></pre> <p>A <a href="https://developer.chrome.com/extensions/content_scripts.html#host-page-communication" rel="nofollow">Individual DOM Environment</a> where content scripts <code>["myscript.js","myscript1.js"]</code> injected ensures <code>myscript1.js</code> have access to all contents <em>(Functions,Variables)</em> of <code>myscript.js</code>, but this stops from two <a href="https://developer.chrome.com/extensions/content_scripts.html#host-page-communication" rel="nofollow">Individual DOM Environment</a>'s being communicating.</p> <p>Having said that, What Limitation\requirement you see in <a href="https://developer.chrome.com/extensions/content_scripts.html" rel="nofollow">Content Scripts</a> which calls for requirement where <strong><a href="https://developer.chrome.com/extensions/messaging.html" rel="nofollow">message passing</a></strong> needs <a href="https://developer.chrome.com/extensions/background_pages.html" rel="nofollow">background pages</a> to access <a href="https://developer.chrome.com/extensions/content_scripts.html#host-page-communication" rel="nofollow">DOM of injected pages</a>?</p> <p>Please Elaborate</p>
33,058,299
0
Stop Dialog from showing after orientation changes <p>I have a custom Dialog class in which I instantiate the dialog like this</p> <pre><code>dg = new Dialog(con); dg.requestWindowFeature(Window.FEATURE_NO_TITLE); Window window = dg.getWindow(); window.setBackgroundDrawableResource(android.R.color.transparent); dg.setContentView(R.layout.listview_dialog_layout); //set views etc.. dg.show(); </code></pre> <p>When an orientation change occurs in the activity that the dialog is shown the activity data changes are lost but the dialog still stays open. I would like the dialog to be dismissed at orientation changes just like it happens with the default Dialog created through an AlertDialog.Builder. How can I do that?</p> <p>I prefer a solution that is implemented in the custom Dialog class instead of going to every activity and type dialog.dismiss(); at activity pause or stop</p>
13,576,512
0
<pre><code>SELECT a.STATE , COALESCE(b.count, 0) AS Count FROM ( SELECT 'done' AS STATE UNION SELECT 'open' AS STATE UNION SELECT 'pending' AS STATE UNION SELECT 'draft' AS STATE UNION SELECT 'cancel' AS STATE ) a LEFT JOIN ( SELECT STATE , count(*) AS count FROM crm_lead GROUP BY STATE ) b ON a.STATE = b.STATE </code></pre>
35,048,717
0
<p>When runnning from noGUI option, the script do not have access to mdb object. You may want to try running the script after including the following line:</p> <pre><code> from abaqus import * </code></pre> <p>By including the above line, abaqus imports all modules and will gain access to mdb object. </p>
34,090,237
0
<p>SIP response codes are splitted in 6 classes</p> <ul> <li><p><code>1xx</code>: <code>Provisional</code> — request received, continuing to process the request; Provisional responses, also known as informational responses, indicate that the server contacted is performing some further action and does not yet have a definitive response. A server sends a 1xx response if it expects to take more than 200 ms to obtain a final response. Note that 1xx responses are not transmitted reliably. They never cause the client to send an ACK. Provisional (1xx) responses MAY contain message bodies, including session descriptions.</p></li> <li><p><code>2xx</code>: <code>Success</code> — the action was successfully received, understood, and accepted;</p></li> <li><p><code>3xx</code>: <code>Redirection</code> — further action needs to be taken in order to complete the request;</p></li> <li><p><code>4xx</code>: <code>Client Error</code> — the request contains bad syntax or cannot be fulfilled at this server;</p></li> <li><p><code>5xx</code>: <code>Server Error</code> — the server failed to fulfill an apparently valid request;</p></li> <li><p><code>6xx</code>: <code>Global Failure</code> — the request cannot be fulfilled at any server.</p> <p>Here you can find <a href="http://www.pjsip.org/pjsip/docs/html/group__PJSIP__MSG__LINE.htm" rel="nofollow">PJSIP struct which holds these codes</a> and <a href="https://en.wikipedia.org/wiki/List_of_SIP_response_codes" rel="nofollow">SIP codes description</a></p></li> </ul>
29,177,457
0
<pre><code>select g.person_id from @person_groups g inner join @tempGroupList l on g.group_id = l.group_id group by g.person_id having count(distinct g.group_id) = (select count(*) from @tempGroupList); </code></pre> <p>To explain slightly. The <code>inner join</code> restricts us to just the groups in question. The <code>group by</code> allows us to calculate the number of different (distinct) groups each person is in. The <code>having</code> filters down to the people in the right number of distinct groups.</p> <p>If a person can only appear once in each group (i.e. <code>group_id, person_id</code> is a unique combination in <code>@person_groups</code>) then you don't need the <code>distinct</code>.</p>
36,587,596
0
Spark ML, Spark NLP, Other ML or NLP Libraries - Getting the Root Keyword from Synonyms <p>I have used Word2Vec to get the synonyms for a root keyword, but am now on the lookout for the reverse. That is, given a string (however large or small) that contains a bunch of synonyms for multiple root keywords, how do I gather the root keywords and their synonyms from the string, after discarding words that don't relate to any root keyword?</p> <p>Example: A string containing these words (and many more) ...</p> <pre><code>pupstar puppystar bitchstar curstar doggystar houndstar mongrelstar muttstar poochstar straystar tykestar bowwowstar fidostar flea bagstar man's best friendstar tail-wagger bobcatstar cheetahstar cougarstar jaguarstar kittenstar kittystar leopardstar lionstar lynxstar mouserstar ocelotstar pantherstar pumastar pussstar pussystar tabbystar tigerstar tomstar tomcatstar grimalkinstar malkin </code></pre> <p>should give me ...</p> <pre><code>dog: (...,...,...) cat: (...,...,...) </code></pre> <p>Thanks in advance for your response.</p> <p>Naga Vijayapuram</p>
10,254,421
0
<p>Most likely Dependency. Associations are normally used to capture some relationship that has meaningful semantics in a domain. So, for example, Secretary 'works for' Manager. Your example is different: you're not capturing meaningful relationships among instances. Therefore Dependency is probably most appropriate.</p> <p>More importantly though: what are you trying to illustrate? Remember to use UML like any other tool - make it work for you. So, for example, it's fine to show a binary association if (a) it helps you and/or (b) it helps you communicate with other team members. The fact that it doesn't comply with the intended UML usage doesn't matter - as long as you find it useful.</p> <p>hth.</p>
8,039,305
0
Can't get Map/Reduce to work with MongoDB <p>I've got this code:</p> <pre><code>// construct map and reduce functions $map = new MongoCode(" function() { ". "var key = {date: this.timestamp.getFullYear()+this.timestamp.getMonth()+this.timestamp.getDate()};". "emit(key, {count: 1}); }" ); $reduce = new MongoCode(" function(k, vals) { ". "var sum = 0;". "for (var i in vals) {". "sum += vals[i];". "}". "return sum;". "}" ); $dates = $db-&gt;command(array( "mapreduce" =&gt; "items", "map" =&gt; $map, "reduce" =&gt; $reduce, //"query" =&gt; array("type" =&gt; "sale"), "out" =&gt; array("merge" =&gt; "distinct_dates") ) ); </code></pre> <p>But get this error when testing: </p> <blockquote> <p>Array ( [assertion] => map invoke failed: JS Error: TypeError: this.timestamp.getFullYear is not a function nofile_b:0 [assertionCode] => 9014 [errmsg] => db assertion failure [ok] => 0 ) Cron run finished.</p> </blockquote> <p>Each object in the collection has a timestamp, from which I want to extract a date (Ymd), and put each distinct date in a new collection.</p>
104,890
0
Dealing with the rate of change in software development <p>I am primarily a .NET developer, and in that sphere alone there are at any given time probably close to a dozen fascinating emerging technologies, some of them real game-changers, that I would love to delve into. </p> <p>Sadly, this appears to be beyond the limits of human capacity. </p> <p>I read an article by Rocky Lhotka (.NET legend, inventor of CSLA, etc) where he mentioned, almost in passing, that last year he felt very terribly overwheled by the rate of change. He made it sound like maybe it wasn't possible to stay on the bleeding edge anymore, that maybe he wasn't going to try so hard because it was futile. </p> <p>It was a surprise to me that true geniuses like Lhotka (who are probably expected to devote a great deal of their time to playing with the latest technology and should be able to pick things up quickly) also feel the burn!</p> <p>So, how do you guys deal with this? Do you just chalk it up to the fact that development is vast, and it's more important to be able to find things quickly than to learn it all? Or do you have a continuing education strategy that actually allows you to stay close to the cutting edge?</p>
13,216,641
0
prolog expanding predicate to iterate for multiple results, combining / resolving result sets <p>I have a predicate "lookupOptions" which returns one by one some lists (Menus).</p> <p>I'm trying to get it to satisfy the case of multiple inputs. I can return a single set of options as follows, by reading the head of the "list_places" list. </p> <pre><code>find_options(Restaurant,Town,Menu) :- lookupOptions(Restaurant,H,Menu), list_places(Town,[H|T]) </code></pre> <p>But, I'm not able to get it to iterate.</p> <p>I have tried a lot of things, these were my best efforts so far.</p> <p>a) standard enough iteration, but it wont resolve ...</p> <pre><code>doStuff(X,[],_). doStuff(Restaurant,[H|T],_):- lookupOptions(Resturant,H,_), doStuff(Restaurant,T,_). find_options(Restaurant,Town,Menu) :- doStuff(Restaurant,[H|T],Menu), list_places(Town,[H|T]). </code></pre> <p>b) expanding the goal predicate ...</p> <pre><code>find_options(_,Town,[H|T],_) find_options(Restaurant,Town,Menu) :- find_options(Restaurant,Town,[],Menu). find_options(Restaurant,Town,X,Menu) :- list_places(Town,X). find_options(Restaurant,Town,[H|T],Menu) :- lookupOptions(Restaurant,[H],Menu), find_options(Restaurant,Town,T,Menu). </code></pre> <p>Would either of these work ? if the pattern was written correctly. Or if there was an appropriate cut put in place?</p> <p>Any help most appreciated ... </p>
22,857,488
0
<p>I manage to do it but I'm not satisfied please if someone know a better way to do this explain it. In app.js :</p> <pre><code>io.sockets.on('connection', function(socket) { var form = require('./controlers/form'); form.init(); var form_copy = _.extend({},form); socket.set( socket.id, form_copy, function() { console.log("form setted"); socket.on('next', function(data) { console.log("next"); socket.get( socket.id,function(error,form_socket){ //I will handle the error ty Tim console.log("form getted"+error); console.log(form_socket); socket.emit('next', form_socket.next()); }); }); }); }); </code></pre> <p>@Tim Brown : in my case socket.set alone is not working because it's passing a reference so I end up dealing with the same issue. </p> <p>My workaround is to make a copy of the form object before passing it to socket.set. But as I said I'm not satisfied even thow it's working. Maybe It's the best way tell me what you think in the comments.</p>
1,023,882
0
Linux: How to debug a SIGSEGV? How do I trace the error source? <p>My firefox started crashing since today. I haven't changed anything on the system or on firefox config.</p> <p>I use<br> <strong><code>strace -ff -o dumpfile.txt firefox</code></strong><br> to trace the problem. It's not a big help.</p> <p>I see the segfault, in two of the generated process dumps, but how I can <strong>trace</strong> them to their cause?</p> <p>After running for 10 seconds and crashing, 22MB of data is generated by strace.</p> <p>This is a snippet of the output, where you can see actual SIGSEGV in the middle.:</p> <pre> read(19, "\372", 1) = 1 gettimeofday({1245590019, 542231}, NULL) = 0 read(3, "\6\0[Qmy\26\0\3\1\0\0Y\0\200\2\0\0\0\0\323\3A\0\323\3(\0\20\0\1\0", 4096) = 32 read(3, 0xf5c55058, 4096) = -1 EAGAIN (Resource temporarily unavailable) gettimeofday({1245590019, 542813}, NULL) = 0 poll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN}, {fd=8, events=POLLIN|POLLPRI}, {fd=12, events=POLLIN|POLLPRI}, {fd=13, events=POLLIN|POLLPRI}, {fd=14, events=POL read(3, 0xf5c55058, 4096) = -1 EAGAIN (Resource temporarily unavailable) gettimeofday({1245590019, 543161}, NULL) = 0 gettimeofday({1245590019, 546672}, NULL) = 0 gettimeofday({1245590019, 546761}, NULL) = 0 read(3, 0xf5c55058, 4096) = -1 EAGAIN (Resource temporarily unavailable) gettimeofday({1245590019, 546936}, NULL) = 0 poll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN}, {fd=8, events=POLLIN|POLLPRI}, {fd=12, events=POLLIN|POLLPRI}, {fd=13, events=POLLIN|POLLPRI}, {fd=14, events=POL poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}]) writev(3, [{"5\30\4\0006\21\200\2\266\n\200\2\17\0]\3\230\4\5\0007\21\200\0026\21\200\2\317\0\0\0"..., 1624}, {NULL, 0}, {"", 0}], 3) = 1624 poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}]) read(3, "\1\30\224Q\17\17\0\0\0\0\0\0\0\0\0\0000\235\273\0\0\0\0\0o\264Q\0\0\0\0\0"..., 4096) = 4096 read(3, "\375\240f\0\376\242j\0\377\261\200\0\271a+\0\271a+\0\377\261\200\0\376\252w\0\376\250s\0"..., 11356) = 11356 read(3, 0xf5c55058, 4096) = -1 EAGAIN (Resource temporarily unavailable) poll([{fd=3, events=POLLIN|POLLOUT}], 1, 4294967295) = 1 ([{fd=3, revents=POLLOUT}]) writev(3, [{"\230\32\7\0\1\21\200\2?\21\200\2\377\377\377\377\377\377\377\377\0\0\0\0\17\0\1\0015\10\4\0"..., 956}, {NULL, 0}, {"", 0}], 3) = 956 poll([{fd=3, events=POLLIN}], 1, 4294967295) = 1 ([{fd=3, revents=POLLIN}]) read(3, "\1\30\256Q\17\17\0\0\0\0\0\0\0\0\0\0000\235\273\0\0\0\0\0o\264Q\0\0\0\0\0"..., 4096) = 4096 read(3, "\375\240f\0\376\242j\0\377\261\200\0\271a+\0\271a+\0\377\261\200\0\376\252w\0\376\250s\0"..., 11356) = 11356 read(3, 0xf5c55058, 4096) = -1 EAGAIN (Resource temporarily unavailable) --- SIGSEGV (Segmentation fault) @ 0 (0) --- unlink("/home/userrrr/.mozilla/firefox/mvbnkitl.default/lock") = 0 rt_sigaction(SIGSEGV, {SIG_DFL, ~[HUP INT QUIT ABRT BUS FPE KILL PIPE CHLD CONT TTOU URG XCPU WINCH RT_1 RT_2 RT_3 RT_4 RT_8 RT_11 RT_14 RT_17 RT_22], SA_NOCLDSTOP}, rt_sigprocmask(SIG_BLOCK, ~[ILL ABRT BUS FPE SEGV RTMIN RT_1], ~[KILL STOP RTMIN RT_1], 8) = 0 open("/home/userrrr/.mozilla/firefox/mvbnkitl.default/minidumps/56b30367-5ee2-0495-32646b7f-59dc87e9.dmp", O_WRONLY|O_CREAT|O_EXCL, 0600) = 63 clone(child_stack=0xf5bfffe4, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_UNTRACED) = 18929 waitpid(18929, NULL, __WALL) = 18929 open("/proc/18913/task", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 64 fstat64(64, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 getdents64(64, /* 12 entries */, 1024) = 368 ptrace(PTRACE_DETACH, 18913, 0, SIG_0) = -1 ESRCH (No such process) close(64) = 0 ftruncate(63, 91256) = 0 close(63) = 0 rt_sigprocmask(SIG_SETMASK, ~[KILL STOP RTMIN RT_1], ~[KILL STOP RTMIN RT_1], 8) = 0 time(NULL) = 1245590020 open("/home/userrrr/.mozilla/firefox/Crash Reports/LastCrash", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 63 write(63, "1245590020", 10) = 10 </pre>
7,865,724
0
How would I use regex to obtain a piece of a link? <p>Current code:</p> <pre><code>public static void WhoIsOnline(string worldName, WhoIsOnlineReceived callback) { string url = "http://www.tibia.com/community/?subtopic=worlds&amp;world=" + worldName; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.BeginGetResponse(delegate(IAsyncResult ar) { string html = GetHTML(ar); MatchCollection matches = Regex.Matches(html, @"&lt;TD WIDTH=70%&gt;&lt;[^&lt;]*&gt;([^&lt;]*)&lt;/A&gt;&lt;/TD&gt;&lt;TD WIDTH=10%&gt;([^&lt;]*)&lt;/TD&gt;&lt;TD WIDTH=20%&gt;([^&lt;]*)&lt;/TD&gt;&lt;/TR&gt;"); List&lt;CharOnline&gt; chars = new List&lt;CharOnline&gt;(matches.Count); CharOnline co; for(int i = 0; i &lt; matches.Count; i++) { co = new CharOnline(); co.Name = Prepare(matches[i].Groups[1].Value); co.Level = int.Parse(matches[i].Groups[2].Value); co.Vocation = Prepare(matches[i].Groups[3].Value); chars.Add(co); } callback(chars); }, request); } </code></pre> <p>I was using this to scrape the online list, but they have changed their layout and I'm not sure how to change the regex to get the same information.</p> <p><a href="http://www.tibia.com/community/?subtopic=worlds&amp;world=Libera" rel="nofollow">http://www.tibia.com/community/?subtopic=worlds&amp;world=Libera</a></p> <p>The link I am trying to use above.</p>
10,895,183
0
marshal and unmarshal with CXF <p>in my server when a client attempt to access to my webservice i get this error</p> <pre> Caused by: javax.xml.bind.JAXBException: hibernate.SBaraque is not known to this context at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:619) at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:145) ... 42 more </pre> <p>this error show when my client try to call this methode :</p> <pre class="lang-java prettyprint-override"><code>@WebResult(name="listes") public List findByPropery(@WebParam(name="arg1") String arg1, @WebParam(name="Value1") Object Value1); </code></pre> <p>which call the DAO class</p> <pre class="lang-java prettyprint-override"><code>public List findByPropery(String arg1, Object Value1) { // TODO Auto-generated method stub System.out.println("findByPropery DAO IN"); return getSession().createQuery("from SBaraque where "+arg1+" = ?").setParameter(0, Value1).list(); } </code></pre> <p>this is my interface :</p> <pre class="lang-java prettyprint-override"><code>@WebService public interface InterfaceService { public void save(@WebParam(name="object") Object obj); public void modify(@WebParam(name="object") Object obj); public void delete(@WebParam(name="object") Object obj); @WebResult(name="listes") public List findAll(); @WebResult(name="object") public Object findById (@WebParam(name="id") Integer id); @WebResult(name="listes") public List findByListPropery(@WebParam(name="arg1") String arg1, @WebParam(name="Value1") Object Value1, @WebParam(name="arg2") String arg2, @WebParam(name="Value2") Object Value2); @WebResult(name="listes") public List findByPropery(@WebParam(name="arg1") String arg1, @WebParam(name="Value1") Object Value1); @WebResult(name="listes") public List findBySQLRequest(@WebParam(name="request") String request); @WebResult(name="listes") public List findByHQLRequest(@WebParam(name="request") String request); } </code></pre>
15,256,366
0
<p>I think the problem arises because your data file has 5 columns and your <code>names</code> list has 6 elements. To verify, check the first few values in the <code>id</code> column- these will all be set to <code>6</code> if I am right. The First few items in the <code>exp</code> column will have the value <code>3</code>.</p> <p>To fix this, read your input file like so:</p> <pre><code>rs =pd.read_csv('rs.txt', header="infer", sep="\t", names=['exp','fov','cycle', 'color', 'values'], index_col=2 </code></pre> <p>Pandas will automatically insert row identifiers.</p>
25,187,737
0
Trying to implement an android spinner. but when I touch it, the dropdown menu doesn't open. nothing happens. why? <p>I was trying to implement an android spinner, a button, if I click should open a dropdown menu showing three things: "bluetooth, speak, headphones" but all i see now is the button, (no text), and when I click on it, nothing happens. what am i missing?</p> <p>here is my code: in the xml i have:</p> <blockquote> <pre><code> &lt;RelativeLayout android:id="@+id/audio_routing" android:layout_width="40dp" android:layout_height="40dp" android:padding="10dp" &gt; &lt;Spinner android:id="@+id/audio_routing_spinner" android:layout_width="20dp" android:layout_height="40dp" android:contentDescription="@string/audio_routing_desc" android:scaleType="fitXY" android:src="@drawable/bluetooth" /&gt; &lt;/RelativeLayout&gt; </code></pre> </blockquote> <p>in the strings file i have:</p> <blockquote> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; ... &lt;string name="audio_routing_desc"&gt;Audio Routing Button&lt;/string&gt; &lt;!-- Audio Routing Drop Down List --&gt; &lt;string-array name="audio_routing_array"&gt; &lt;item&gt;Bluetooth&lt;/item&gt; &lt;item&gt;Headphones&lt;/item&gt; &lt;item&gt;Speaker&lt;/item&gt; &lt;/string-array&gt; </code></pre> </blockquote> <p>in my java file i have:</p> <blockquote> <pre><code> void audio_routing() { kcLogger.info("audio_routing", "audio_routing function is called"); Spinner spinner = (Spinner) mKCSWindowView.findViewById(R.id.audio_routing_spinner); ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(service,R.array.audio_routing_array,android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) { // TODO Auto-generated method stub kcLogger.info("audio_routing", "onItemSelected"); } @Override public void onNothingSelected(AdapterView&lt;?&gt; parent) { // TODO Auto-generated method stub kcLogger.info("audio_routing", "onNothingSelected"); } }); } </code></pre> </blockquote>
6,725,684
0
<p>You have not specified how much rows should be added to the textarea but I hope this answers your question. This code will work only if you have already set the default number of rows of your textarea in HTML, through the <code>rows</code> attribute.</p> <pre><code>$(function () { var rowsAdded = false; $("#myTextarea").keyup(function () { var textarea = $(this); if (textarea.val().length &gt; 52 &amp;&amp; !rowsAdded) { textarea.attr('rows', parseInt(textarea.attr('rows')) + rowsToAdd); // replace rowsToAdd with the number of rows to add to the textarea rowsAdded = true; } }); }); </code></pre>
8,783,868
0
<p>The ZBar scanner just gives you back a value, and you can do whatever you choose with it. See the following example, which pushes a WebViewController when a barcode is scanned. You could modify it to check which barcode is scanned specifically, and load the right web view accordingly.</p> <pre><code>- (void) readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms fromImage: (UIImage*) img { // do something useful with results for(ZBarSymbol *sym in syms) { NSString *data = sym.data; WebViewController *wv = [[WebViewController alloc] initWithNibNameAndURL:@"WebView" bundle:[NSBundle mainBundle] url:[NSString stringWithFormat:@"http://www.companyname.com?scan=%@", data]]; [self.navigationController pushViewController:wv animated:YES]; break; } } </code></pre> <p>Note that WebViewController is a ViewController which I created a custom initialization for so I could pass in a URL, and load it in the UIWebView once it's pushed to the Navigation Controller.</p> <p>Hope that helps.</p>
12,088,941
0
Abandon Session Without Clearing All <p><strong>Overview :</strong> I created a system that have Customer area and Admin area. Both areas have different log-in page. A user can be logged in as <em>User A</em> in Admin area at the same time logged in as <em>User B</em> in Customer area.</p> <p>When a user log-out from either Customer or Admin area, <code>Session.Abandon()</code> is called and it removes session in both Customer and Admin area <strong>which I don't want to happen</strong></p> <p><strong>Question :</strong> Can I abandon session on log-out without affecting other area's session ? (i.e : When I log out from Customer area, I should stay logged-in in Admin area)</p> <p><strong>Update :</strong> I know <code>Session.Clear()</code> can be a workaround for this, but I'm afraid of the security risks it might impose. </p>
10,609,174
0
<p><a href="http://railscasts.com/episodes/29-group-by-month" rel="nofollow">http://railscasts.com/episodes/29-group-by-month</a></p> <pre><code>NewsFeed.where("user_id is not in (?)",[user_ids]).group_by { |t| t.created_at.beginning_of_month } =&gt; each {|month,feed| ...} NewsFeed.select("*,MONTH(created_at) as month").where("user_id is not in (?)",[user_ids]).group("month") =&gt; ... </code></pre>
7,073,300
0
<p>Try using the following attribute</p> <pre><code>[ServiceKnownType(typeof(List&lt;string&gt;))] </code></pre> <p>If that doesn't work, perhaps try using <code>IList&lt;T&gt;</code> if that is possible in your situation</p>
933,104
0
Web service calls and proxy authentication in the real world <p>We are developing an app that consists of a web server that hosts a web service (amongst other things) and a client that will be communicating with that web service. Both the client app and the server are expected to be used within a corporate firewall. This application will be packaged up and deployed to organizations across the world—so it needs to be flexible enough to work in multiple types of environments.</p> <p>My question revolves around web service authentication and what is appropriate for real world scenarios. I know some companies have proxy servers that require a separate authentication. How often is this a requirement across organizations? When does the proxy server force the user to authenticate (can you access internal sites without authenticating.. is the authentication for only external sites)?</p> <p>Reason I ask these questions, is I’m not sure what kind of capability we should build into our client application for authentication to the web service. By default, we are taking the current user credentials and passing that up to the server. Do you think this is sufficient? In a case where a company will require some form of alternate authentication for internal access, this will not work. My question revolves around this last case—how often does it happen? Why would a company force alternate credentials for internal access?</p> <p>Thanks!</p>
10,670,201
0
<p>I just Find a solution to walk-through this problem. i take a instant screenshot and show it. Thanks to Radu Motisan for his tutorial. the solution use JNI instead of other way using external Library.</p> <p>Here is the link : <a href="http://www.pocketmagic.net/?p=1473" rel="nofollow">http://www.pocketmagic.net/?p=1473</a></p>
28,175,581
0
How to compile dependencies using cmake? <p>Given that I have the following file structure,</p> <pre><code>my_project CMakeLists.txt /include ...headers /src ...source files /vendor /third-party-project1 CMakeLists.txt /third-party-project2 CMakeLists.txt </code></pre> <p>How do I use the third party projects by compiling them according to their CMakeLists.txt files from my own CMake file? I specifically need their include dirs, and potentially any libs they have.</p> <p>Furthermore, how could I use FIND_PACKAGE to test if the third party projects are installed in the system, and if they don't compile and link against the included ones?</p>
11,781,931
0
<p>As mentioned in the comments of the <code>laxbreak</code> answer, <strong><code>laxcomma</code></strong> option should actually be used for this particular situation (it has been implemented in the meantime). See <a href="http://jshint.com/docs/options/">http://jshint.com/docs/options/</a> for details.</p>
4,814,196
0
Relative Layout Programmatically <p>I have a relative layout which consists a <code>Button</code> a <code>EditText</code></p> <p>At the time of page loading I am initializing the relative layout like this </p> <pre><code>RelativeLayout bottomLayout; bottomLayout = (RelativeLayout) findViewById(R.id.s_r_l_bottom); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) bottomLayout .getLayoutParams(); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, -1); bottomLayout.setLayoutParams(layoutParams ); </code></pre> <p>As a result my relative layout was at the bottom of the screen. Now what I am trying that I also have <code>Button</code> on the top the screen .</p> <p>By pressing the button I want that the relative layout will be on the center of the screen</p> <p>For that I have used the following code on button click(The code is executing.I have tested that).But it did not help me.</p> <pre><code>RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) bottomLayout.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, -1); bottomLayout.setLayoutParams(layoutParams); </code></pre> <p>Can you please help me out to fix this?</p>
34,069,082
0
<p>You can develop qpython project as other python projects with your pc or MC, and upload the project into your mobile's /sdcard/com.hipipal.qpyplus/projects/ then run it in qpython.</p> <p>The qpython project should contain the main.py which is used for the project first launch script.</p> <p>Besides adb (android develop tool), you can use the qpython's FTP service ( You could find it in setting page ) or other FTP app to upload the project into your mobile.</p> <p>GOOD NEWS: In the newest qpython(1.2.2), it contains a qedit4web.py which allow you develop from browser and edit and run code from your mobile.</p>
20,076,302
0
Where should I host php file for ajax call? <p>So I have a very simple request. I am trying to make a call using jQuery to a php file so that the file's response will be put into a "div". I know there are other posts but for some reason none of them seem to be working for me.</p> <p>Here is my code:</p> <p><strong>gettable.php</strong></p> <pre><code>&lt;?php echo "&lt;p&gt;Great-Success&lt;/p&gt;"; ?&gt; </code></pre> <p><strong>sequencingfile.html</strong></p> <pre><code>jQuery("#tableHolder").load("/path/to/php-file/gettable.php", function(response, status, xhr) { alert(response); alert(status); alert(xhr); if (status == "error") { console.log(msg + xhr.status + " " + xhr.statusText); } }); </code></pre> <p><strong>Notes</strong></p> <ul> <li><p>The contents of the div changes to this:</p> <p>Great-Success</p> <p>"; ?></p></li> <li><p>The html code is run after you click a button</p></li> <li>The div which I am trying to load the echo from the php call has id "tableHolder".</li> <li>I am running this on the firefox, it doesn't work on chrome at all.</li> <li>The response is the actual contents of the php file itself.</li> <li>The status is "success".</li> <li><p>The xhr is "[object Object]"</p></li> <li><p>Eventually I am trying to call the php file to query from a mysql database to create a table(if you know of a better and more efficient way of doing this please let me know), but for now all I want is the echo of the php call to come back and be put into the div as it should.</p></li> <li>The file is set locally</li> <li>The computer is linux</li> <li>That's all the detail I can think of, please let me know if you need any more details</li> </ul> <p><strong>EDIT</strong></p> <p>Alright I have set up an apache server and changed the link to <code>http://127.0.0.1/gettable.php</code> and it still doesn't work. When I type that url into firefox or chrome it works, but not when I run the html file. What am I doing wrong?</p>
24,682,002
0
Internet Explorer 8 producing strange CSS bug on :hover <p>I'm working on website development, styling a breadcrumb trail with CSS at the moment. However, I came across this strange bug in Internet Explorer 8, and I can't figure out why it's happening. To illustrate, here are some images:</p> <p>This is what one of the breadcrumbs is supposed to look like when hovered over: <a href="http://i.imgur.com/Lrr5Qo0.png" rel="nofollow">http://i.imgur.com/Lrr5Qo0.png</a> (image taken in Chrome)</p> <p>In Internet Explorer, this is what it looks like when hovering: <a href="http://i.imgur.com/V5dzdcX.png" rel="nofollow">http://i.imgur.com/V5dzdcX.png</a></p> <p>It displays fine before hovering, but as soon as the mouse goes over it, it goes nuts.</p> <p>I've gone through the CSS code, and the only attributes related to :hover are color, background, overflow, and text-decoration. There is nothing to do with margin, padding, height, etc.</p> <p>What could possible be causing this?</p> <p>Relevant HTML:</p> <pre><code>&lt;div class="headtitle pull-left"&gt; &lt;h1 id="pageTitle" class="ms-core-pageTitle"&gt; CX Team &lt;/h1&gt; &lt;ul class="s4-breadcrumb"&gt; &lt;li class="s4-breadcrumbRootNode"&gt; &lt;span class="s4-breadcrumb-arrowcont"&gt; &lt;img src="/_layouts/images/nodearrow.png" alt="" style="border-width:0px;display:inline-block;padding-top:4px;" /&gt; &lt;/span&gt; &lt;a class="s4-breadcrumbRootNode" href="/sites/cc/Pages/index.aspx"&gt;Connect&lt;/a&gt; &lt;ul class="s4-breadcrumbRootNode"&gt; &lt;li class="s4-breadcrumbNode"&gt; &lt;span class="s4-breadcrumb-arrowcont"&gt; &lt;img src="/_layouts/images/nodearrow.png" alt="" style="border-width:0px;display:inline-block;padding-top:4px;" /&gt; &lt;/span&gt; &lt;a class="s4-breadcrumbNode" href="/sites/cc/residential/Pages/index0709-9951.aspx"&gt;Residential&lt;/a&gt; &lt;ul class="s4-breadcrumbNode"&gt; &lt;li class="s4-breadcrumbNode"&gt; &lt;span class="s4-breadcrumb-arrowcont"&gt; &lt;img src="/_layouts/images/nodearrow.png" alt="" style="border-width:0px;display:inline-block;padding-top:4px;" /&gt; &lt;/span&gt; &lt;a class="s4-breadcrumbNode" href="/sites/cc/residential/customerexperience/Pages/default.aspx"&gt;Customer Experience&lt;/a&gt; &lt;ul class="s4-breadcrumbNode"&gt; &lt;li class="s4-breadcrumbCurrentNode"&gt; &lt;span class="s4-breadcrumb-arrowcont"&gt; &lt;img src="/_layouts/images/nodearrow.png" alt="" style="border-width:0px;display:inline-block;padding-top:4px;" /&gt; &lt;/span&gt; &lt;a class="s4-breadcrumbCurrentNode" href="/sites/cc/residential/customerexperience/Pages/CX-Team.aspx"&gt;CX Team&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I unfortunately don't have control over this; it is created dynamically by Sharepoint (which I am forced to use).</p> <p>CSS: </p> <pre><code>.s4-breadcrumb a:hover { overflow:auto\9; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF9900', endColorstr='#FF6600'); background-image:-moz-linear-gradient(top,#F90,#F60); background-image:-webkit-gradient(linear,0 0,0 100%,from(#F90),to(#F60)); background-image:-o-linear-gradient(top,#F90,#F60); background-image:linear-gradient(to bottom,#F90,#F60); } .v4master .s4-breadcrumbNode a, .v4master .s4-breadcrumbCurrentNode a, .v4master .s4-breadcrumbRootNode a, .v4master .s4-breadcrumbNode a:hover, .v4master .s4-breadcrumbCurrentNode a:hover, .v4master .s4-breadcrumbRootNode a:hover { color:white !important; } ul.s4-breadcrumb, ul.s4-breadcrumb ul { line-height:normal; } ul.s4-breadcrumb a { line-height:40px; } ul.s4-breadcrumb, ul.s4-breadcrumb ul { margin-bottom:0; } ul.s4-breadcrumb .s4-breadcrumb-arrowcont { margin-bottom:14px; } ul.s4-breadcrumb, ul.s4-breadcrumb ul { margin-left:0; } ul.s4-breadcrumb, ul.s4-breadcrumb ul { margin-right:0; } ul.s4-breadcrumb, ul.s4-breadcrumb ul { margin-top:0; } ul.s4-breadcrumb .s4-breadcrumb-arrowcont { margin-top:10px; } .s4-breadcrumb a { padding-left:5px; } .headtitle &gt; ul.s4-breadcrumb { padding-left:10px; } .headtitle &gt; ul.s4-breadcrumb { padding-left:0\9; } .s4-breadcrumb { padding-left:15px; } .s4-breadcrumb a { padding-right:5px; } .s4-breadcrumb { padding-right:15px; } .s4-breadcrumb a:hover { text-decoration:none; } </code></pre>
14,016,373
0
<p>Although @Sam's suggestions will work fine in most scenarios, I actually prefer using the supplied <code>AdapterView</code> in <code>onItemClick(...)</code> for this:</p> <pre><code>public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Person person = (Person) parent.getItemAtPosition(position); // ... } </code></pre> <p>I consider this to be a slightly more fool-proof approach, as the <code>AdapterView</code> will take into account any header views that may potentially be added using <a href="http://developer.android.com/reference/android/widget/ListView.html#addHeaderView%28android.view.View,%20java.lang.Object,%20boolean%29"><code>ListView.addHeaderView(...)</code></a>. </p> <p>For example, if your <code>ListView</code> contains one header, tapping on the first item supplied by the adapter will result in the <code>position</code> variable having a value of <code>1</code> (rather than <code>0</code>, which is the default case for no headers), since the header occupies position <code>0</code>. Hence, it's very easy to mistakenly retrieve the wrong data for a position and introduce an <code>ArrayIndexOutOfBoundsException</code> for the last list item. By retrieving the item from the <code>AdapterView</code>, the position is automatically correctly offset. You can of course manually correct it too, but why not use the tools provided? :)</p> <p>Just FYI and FWIW.</p>
38,025,841
0
Trying to append a row to a Google Spreadsheet in PHP <p>I'm using Google's Client API via Composer (<a href="https://packagist.org/packages/google/apiclient" rel="nofollow">https://packagist.org/packages/google/apiclient</a>) and I have successfully authenticated and received an access token.</p> <p>I am trying to add a row to a Google sheet in my drive, but I can't find any relevant documentation that specifically addresses PHP.</p> <p>Here's what I've got so far:</p> <pre><code>$service = new Google_Service_Sheets($a4e-&gt;google); // my authenticated Google client object $spreadsheetId = "11I1xNv8cHzBGE7uuZtB9fQzbgrz4z7lIaEADfta60nc"; $range = "Sheet1!A1:E"; $valueRange= new Google_Service_Sheets_ValueRange(); $service-&gt;spreadsheets_values-&gt;update($spreadsheetId,$range,$valueRange); </code></pre> <p>This returns the following error:</p> <pre><code>Fatal error: Uncaught exception 'Google_Service_Exception' with message '{ "error": { "code": 400, "message": "Invalid valueInputOption: INPUT_VALUE_OPTION_UNSPECIFIED", "errors": [ { "message": "Invalid valueInputOption: INPUT_VALUE_OPTION_UNSPECIFIED", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } ' in /usr/share/nginx/vendor/google/apiclient/src/Google/Http/REST.php </code></pre> <p>I'm stuck as to the format of the "<code>Google_Service_Sheets_ValueRange()</code>" object, and also how to append a row to the end of the sheet, rather than having to specify a particular range.</p> <p>I would greatly appreciate any help with this issue.</p>
4,246,948
0
<p>Who controls the data model for the output of the sensors? If it's not you, do they know what they are doing? If they create new and inconsistent models every time they invent a new sensor, you are pretty much up the creek.</p> <p>If you can influence or control the evolution of the schemas for CSV files, try to come up with a top level data architecture. In the bad old days before there were databases, files made up of records often had, as the first field of each record, a "record type". CSV files could be organized the same way. The first field of every record could indicate what type of record you are dealing with. When you get an unknown type, put it in the "bad input file" until you can maintain your software. </p> <p>If that isn't dynamic enough for you, you may have to consider artificial intelligence, or looking for a different job.</p>
34,593,324
0
<p>At first sight, you could do something like that by inserting a <code>&lt;tbody&gt;</code> (more information here: <a href="http://stackoverflow.com/questions/12979205/angular-js-ng-repeat-across-multiple-trs">Angular.js ng-repeat across multiple tr&#39;s</a>)</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var myAppModule = angular.module('myApp', []).controller('MyController', MyController); function MyController() { // http://stackoverflow.com/questions/1345939/how-do-i-count-a-javascript-objects-attributes this.objectCount = function(obj) { return Object.keys(obj).length; } this.data = { "10": {}, "12": { "20": { "value": 1, "id": 1, }, "100": { "value": 12, "id": 1, }, "200": { "value": 120, "id": 10, } }, "14": { "100": { "value": 14, "id": 2, } }, "16": {}, "18": {}, "20": { "100": { "value": 23, "id": 1, }, "150": { "value": 56, "id": 3, } }, "22": {}, "24": {} }; }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>table, th, td { border: 1px solid black; } table { border-collapse: collapse; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"&gt;&lt;/script&gt; &lt;div ng-app="myApp" ng-controller="MyController as ctrl"&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;type&lt;/th&gt; &lt;th&gt;module&lt;/th&gt; &lt;th&gt;value&lt;/th&gt; &lt;th&gt;id&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody ng-repeat="(row1, value1) in ctrl.data" ng-switch="ctrl.objectCount(value1) === 0"&gt; &lt;tr ng-switch-when="true"&gt; &lt;td&gt;{{row1}}&lt;/td&gt; &lt;td colspan="3"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr ng-switch-when="false" ng-repeat="(row2, value2) in value1"&gt; &lt;td ng-if="$index === 0" rowspan="{{ctrl.objectCount(value1)}}"&gt; {{row1}} &lt;/td&gt; &lt;td&gt;{{row2}}&lt;/td&gt; &lt;td&gt;{{value2.value}}&lt;/td&gt; &lt;td&gt;{{value2.id}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>If you need something more refined with merging of rows and columns, you should think to build a more oriented view objects, so that the template is simpler, and your business logic is in JavaScript.</p>
4,860,511
0
<p>exec() could have been disabled by the server admin. In this scenario a call to exec would print an E_NOTICE and a E_WARNING. So if you disabled warning printing you can only see the E_NOTICE and potentially miss the more interesting warning saying "exec has been disabled for security reason".</p> <p>You can add this line to your code</p> <pre><code>error_reporting(E_ALL); </code></pre> <p>so that you can have a more verbose execution.</p>
37,362,575
0
<p>The answer to this is quite simple.</p> <pre><code>Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int line1 = 0; while (true) { String input = scanner.nextLine(); if (input.length &gt; 0) { try { line1 = Integer.parseInt(input); break; } catch (NumberFormatException e) { System.out.println("Input not an integer, try again."); } } else { // User entered nothing. Break loop to stop it from never ending. break; } } String line2 = Scanner.nextLine(); } </code></pre> <p>This will store an integer from the scanner, and forcefully make sure it is an integer, and then store a string afterwards. If you do not correctly enter an integer, it will request another.</p> <p>If you need to later split the string for every whitespace, use:</p> <pre><code>String[] array = line2.split(" "); </code></pre> <p>You cannot split an Integer.</p> <p>If both inputs need to be combined into a single string, then you can then use:</p> <pre><code>String completeString = line1 + " " + line2; </code></pre> <p>And again, you can split this by using:</p> <pre><code>String[] array = completeString.split(" "); </code></pre> <p>So if the user entered 55, and "Hello", you would end up with the following after splitting:</p> <pre><code>["55", "Hello"] </code></pre>
27,112,569
0
X-Editable and Bootstrap datatables <p>I've tried with no success to implement x-editable in bootstrap datatables, the reason being when i update an element from x editable, the datatable fails to recognize those changes.. i've tried updating the table, destroying it, hidden tags, but the main problem seems to be that the datatables fails to recognize any change after the initialization.. I add the rows via button click, when they get to the table, i run .editable on those elements. they become editable but the sorting and search of the datatables doesnt work..</p> <p>Can anyone help me?</p>
5,845,887
0
How do I use \renewcommand to get BACK my greek letters? <p>I'm a LaTeX newbie, but I've been doing my homework, and now I have a question that I can't seem to find the answer to. I create the definition of an equation, let's just say it's this one:</p> <pre><code>The potential is characterized by a length $\sigma$ and an energy $\epsilon$. </code></pre> <p>In reality, this equation is more complex, which is why I wanted to try a shortcut. If my equation were this simplistic, I wouldn't try my substitution technique. I use the \renewcommand to save me some time:<BR></p> <pre><code>\renewcommand{\sigma}{1} </code></pre> <p>And this works fabulously and will replace all instances of sigma with 1. Unfortunately though, since \sigma has a global scope, I need to reset it. I tried a couple different ways:<BR> Attempt 1: -deadlock due to circular reference?</p> <pre><code>\newcommand{\holdsigma}{\sigma} \renewcommand{\sigma}{1} The potential is characterized by a length $\sigma$ and an energy $\epsilon$. \renewcommand{\sigma}{\holdsigma} </code></pre> <p>I would think to reset the command, it should look something like this:</p> <pre><code>\renewcommand{\sigma}{\greek{\sigma}} </code></pre> <p>but that obviously hasn't worked out for me.<BR><BR> Any idea about how the greek letters are originally defined in the language?</p>
28,720,323
0
Multiple images appear on hover <p>I have been searching the net for a solution to my problem. I am trying to load five images beside each other when the user hovers over an element on my webpage. So far I can make an image appear on hover however what I really need is to make 5 images appear on hover in a queued fashion?</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() { $(".Invisible").hide() $(".image1").hover( function () { $('.Invisible').stop().fadeTo("slow", 1.0); }, function () { $('.Invisible').stop().fadeOut("slow"); } ); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div id="workbox1" class="container"&gt; &lt;div class="image1"&gt;&lt;img alt="" src="http://placehold.it/300x300" style="width:100%" height="120%"/&gt;&lt;/div&gt; &lt;div class="Invisible"&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
22,977,316
0
<p>The configuration looks fine.</p> <p>However, the line:</p> <pre><code>string content = File.ReadAllText(logFileFullPath); </code></pre> <p>is throwing an exception so you are only writing one log entry per test. When the log file is opened it is locked so you won't be able to read it using File.ReadAllText.</p> <p>You can read through the lock using something like:</p> <pre><code>string fileContents = null; using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var sr = new StreamReader(fs)) { fileContents = sr.ReadToEnd(); } </code></pre>
52,477
0
<p>All of .net is available in the .net SDK, so in theory you will not need Visual Studio at all.</p> <p>Now, there are some things that Express will not do. For example, the Database Designer is not very comprehensive and adding different remote databases is not or only very hardly possible. Still, in code you can connect to everything.</p> <p>There is also no Remote Debugger, no support for creating Setup Files (well, that does not apply to ASP.net anyway), no real Publish Web Site Feature (although that can be <a href="http://blogs.msdn.com/b/jamesche/archive/2007/09/27/automating-aspnet-compiler-in-visual-web-developer.aspx" rel="nofollow noreferrer">added manually</a> as it's just a Frontend for a SDK tool), no integrated Unit testing (and Microsoft <a href="http://weblogs.asp.net/nunitaddin/archive/2007/05/30/microsoft-vs-testdriven-net-express.aspx" rel="nofollow noreferrer">loves to threaten people</a> who add it), etc.</p> <p>For a full comparison, see here:</p> <p><a href="http://msdn.microsoft.com/en-us/vstudio/products/cc149003.aspx" rel="nofollow noreferrer">Visual Studio 2008 Editions</a></p> <p>But as said: Functionality of .net is all in the SDK, Visual Studio is just making it a bit easier to work with.</p>
19,635,753
0
RestKit mapping for specific entity <p>I have used common RKObjectManager used for different entity mapping as the following below cod but when i try to make mapping for specific entity couldn't because i have two entity with same keyPath this the problem how i can figured.</p> <pre><code> // Search mapping ... RKEntityMapping *searchEntityMapping = [RKEntityMapping mappingForEntityForName:NSStringFromClass([ABB class]) inManagedObjectStore: aBBManager.managedObjectStore]; [searchInfoEntityMapping addAttributeMappingsFromDictionary:@{ @"count" : @"count", @"total_count" : @"totalCount", }]; // Search Advanced mapping ... RKEntityMapping *searchAdvEntityMapping = [RKEntityMapping mappingForEntityForName:NSStringFromClass([ABB class]) inManagedObjectStore: aBBManager.managedObjectStore]; [searchAdvEntityMapping addAttributeMappingsFromDictionary:@{ @"count" : @"count", @"data" : @"dataCount", }]; // Search Descriptor RKResponseDescriptor *aBBResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:searchEntityMapping pathPattern:nil keyPath:@"locations" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; // Search Adv Descriptor RKResponseDescriptor *aBB2ResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:searchAdvEntityMapping pathPattern:nil keyPath:@"locations" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; </code></pre>
8,312,801
0
Use an ASP.NET or ActiveX component in Java Spring with Tomcat <p>I would like to ask if I can use the ASP.NET or ActiveX version of <a href="http://www.textcontrol.com/en_US/" rel="nofollow" title="Text Control">Text Control</a> in a .jsp web page supported by Java Spring and a Tomcat webserver. I'm aware of the sw EZ JCom, but I can't afford it. Is there something cheaper? Thank you</p>
6,553,763
0
<p>The problem is that @flits is nil, presumably because your all_flits method is returning nil.</p> <p>However, I'd recommend not putting that logic in the view, breaking up a tag like that. You have several options to make it cleaner:</p> <hr> <p>Option 1: Use the CSS pseudo-class <code>first-child</code> like so:</p> <pre><code> li:first-child { ... } </code></pre> <p>This has the advantage of not requiring any back-end logic or special markup. The only downside is that it has spotty older browser support, e.g. IE6.</p> <hr> <p>Option 2: Use the Rails tag helpers.</p> <pre><code>&lt;%= content_tag :li, :class =&gt; @flits.first==flit?"first":"" %&gt; </code></pre> <hr> <p>Option 3: Tuck it away in a helper method</p> <pre><code>&lt;%= li_for_flit %&gt; </code></pre> <p>Then in the helper:</p> <pre><code>def li_for_flit #spit out your tag here end </code></pre>
1,344,361
0
<p>A lot of new programmers are still working at a very low level of abstraction, learning the trade. That's something everyone has to go through. It takes a while to "move up the stack" so to speak.</p> <p>Once programmers realise that they spend most of the time solving the same problems as someone else already did, and the goal is to realise "business value", then they can really appreciate the value a good library brings.</p>
28,345,452
0
<p>Use <a href="https://nssm.cc/" rel="nofollow">Non-Sucking Service Manager</a> to install logstash as a windows service. Services can be started at boot and run without an active user login.</p>
7,387,540
0
<pre><code>RewriteCond %{HTTP_HOST} !^admin\.example.com$ [OR] RewriteCond %{HTTP_HOST} !^login\.example.com$ [OR] RewriteCond %{HTTP_HOST} !^logout\.example.com$ RewriteCond %{HTTP_HOST} -(.{5})\.example.com RewriteRule (.*) http://example.com/something/maybesomethingelse/-%1 </code></pre> <p>I did not test it but I think it works!let me know if not!</p>
33,870,111
0
Select2 not selecting first item as default <p>I am populating a drop down list in an ASP.Net page using this code </p> <pre><code>var xhttp xhttp = new XMLHttpRequest(); xhttp.open("GET", "../XMLHttp/XMLHttp_GetRDRegions.aspx?RDDivision=" + encodeURIComponent(document.getElementById('ddlRDDivisions').value), false); xhttp.send(); document.getElementById('ddlRDRegions').options.length = 0; document.getElementById('ddlRDCentres').options.length = 0; document.getElementById('ddlRMNames').options.length = 0; var ddlRDRegions = document.getElementById('ddlRDRegions'); var element = document.createElement('option'); element.text = '--- Please Select an item ---' element.value = '0' ddlRDRegions.options.add(element); </code></pre> <p>When not using Select the new element I am adding is the first selected item in the list, however when applying the Select2 in the javascript too like this. </p> <pre><code>$('select').select2(); </code></pre> <p>the element is at the top of the list but is not the selected element. </p> <p>I have tried creating an attribute like this </p> <pre><code>var att = document.createAttribute("selected"); att.value = "selected"; element.setAttribute(att) </code></pre> <p>which throws an error and this </p> <pre><code>$(element).attr("selected", "selected") </code></pre> <p>which does nothing. </p> <p>Any and all help on where I am going wrong would be very much appreciated. </p>
18,937,561
0
<p>Add <code>padding-left: 0</code> to your <code>ul</code> style declaration.</p> <pre><code>#pricing_plan1 ul, #pricing_plan2 ul, #pricing_plan3 ul { list-style: none; font-family: "Helvetica Neue"; border: 1px solid #d9dee1; padding-left: 0px; } </code></pre> <p><code>&lt;ul&gt;</code> has default left padding, and that's the reason of your code output.</p> <p>Check <a href="http://jsfiddle.net/R456T/" rel="nofollow"><strong>jsFiddle demo</strong></a>. Both lists have <code>list-style</code> set to <code>none</code>, but only the second one has additional <code>left-padding: 0</code>. As you can see, the first one has exactly the same problem you're trying to solve.</p>
505,196
0
<p>The recommended solution to change the options appears to be corerct however it still generates ALTER TABLE SET (LOCK_ESCALATION = TABLE) on my database (I even put in compatibility mode 90)</p>
21,680,567
0
javascript reset on close <p>I am not an expert on javascript, and I am currently trying to breakdown a previous programmer's code.</p> <p>He has a window called ADD ACCOUNT that opens up, and you can either make your selections via dropdown selects or by dragging and dropping another account directly onto the window.</p> <p>What I want to do is when the user changes their mind, and they close the window, it should automatically reset all the filters. The user is not actually hitting the reset button. They are just closing the window.</p> <p>Right now, if they close it and open it back up, the previous selection they made are still there. </p> <p>I've been looking through the code, and I found this:</p> <pre><code> var AddAccountWindow = new Ext.Window({ title: 'Add Account', closable:true, closeAction:'hide', y:5, width: 735, height:editPnlHeight-25, plain:true, layout: 'fit', stateful:false, items: AddAcountForm }); </code></pre> <p>Is there anyway I can add a reset feature that will automatically fire when they close the window with the code I provided above?</p> <p>Or do I have to create another function that will fire on close?</p>
5,386,220
0
<p>After a long tracing into the code and data, I found the obstacle which somehow bugging me out. There was a change in a master data which now has longger character (varchar). In my procedure it was put into a smaller size of varchar, let say 10 character. While new string its about 15. Here goes the error <strong>...or string truncation....</strong>. But anyway thanks of your attention to my problem and thanks for the clues you wrote, it save me somehow, give me the idea to trace it up.</p> <p>Thx a bunch,</p>
34,423,309
0
<blockquote> <p>1) Which operator should I better use in customer projects? ^ or ~ ?</p> </blockquote> <p>Prefer caret <code>^</code> over tilde <code>~</code> operator.</p> <blockquote> <p>2+3) What does it mean, when I specify: <code>"behat/behat": "~1.3"</code> </p> </blockquote> <p><code>~1.3</code> is equivalent to <code>&gt;=1.3 &lt;2.0.0</code>.</p> <p>In brief: </p> <p><strong><code>~</code> sets a minimum version and allows last version digits to go up, while keeping BC safety</strong>.</p> <p>In detail:</p> <ul> <li>it will fetch a version starting with the lowest version of the <code>1.3</code> series as lower boundary, probably <code>1.3.0</code></li> <li>it will proceed with <code>1.3.*</code>, <code>1.4.*</code> and so on (all versions)</li> <li>but it will remain below the upper version boundary of version <code>2.0.0</code></li> </ul> <p>The switch of an major version (here from <code>1.*.*</code> to <code>2.*.*</code>) indicates a possibly break in backward compatibility (see semantic versioning standard). The package manager will avoid to fetch breaking changes to keep your set of software dependencies working.</p> <blockquote> <p>Are there any other special cases, where I need to be careful when specifying the version number?</p> </blockquote> <p>There are special cases, for instance fetching "dev-master" and development dependencies with stability dev and other "special cases. </p> <p>But the question is too broad to provide a good answer. Ask again, when you run into trouble with "special cases".</p>
27,223,288
0
<p>I did following code :</p> <pre><code>&lt;script src="${resource(dir: 'js', file: 'jquery.zclip.js')}"&gt;&lt;/script&gt; &lt;script src="${resource(dir: 'js', file: 'jquery.zclip.min.js')}"&gt;&lt;/script&gt; &lt;script&gt; function copyToClipboard(){ $("#copyLink").zclip({ path: "/js/ZeroClipboard.swf", copy: $("#genCampUrl").val(), afterCopy:function(){ alert('copied'); } }); } &lt;/script&gt; &lt;a id="copyLink" onclick="copyToClipboard();"&gt;Copy this url&lt;/a&gt; </code></pre> <p>On localhost it doesn't work. As the movie needs to be uploaded somewhere. But on server, it works. </p>
13,713,341
0
<p>You do not see the message from circle because circle is part of the group and thus, only one of the event "dragstart" can be recognized either on the group or the circle, when you try to move circle the event is recognized for the group as circle is part of the group. You can probably add a check inside the function associated with "dragstart" for group to check if the object selected is "circle" and show your message.</p>
27,458,513
0
<p>The HTML5 spec, <a href="http://www.w3.org/TR/html5/syntax.html#attribute-name-state" rel="nofollow"><strong>Section 8.2.4.35 - 'Attribute name state'</strong></a> says:</p> <blockquote> <p>When the user agent leaves the attribute name state (and before emitting the tag token, if appropriate), the complete attribute's name must be compared to the other attributes on the same token; if there is already an attribute on the token with the exact same name, then this is a parse error and the new attribute must be removed from the token.</p> </blockquote> <p>So, to answer your question, it's invalid HTML.</p>
2,478,661
0
<p>Your question is answered in section 7.9.6 of the C# specification:</p> <blockquote> <p>If an operand of a type parameter type T is compared to null, and the runtime type of T is a value type, the result of the comparison is false.</p> </blockquote>
34,295,014
0
Show/hide subpanels dynamically in Ext JS <p>I have created a view (a panel) with 3 subpanels ... When the view loads , I want a function to run in viewController and based on its outcome , I want subpanel 1 to be visible(subpanel2 to be invisible) or subpanel2 to be visible(subpanel1 to be invisible)</p> <p>How can I accomplish this ?</p>
29,146,275
0
<p>You'll need the client-side library to connect to the server. You can fetch it at your domain.com/socket.io/socket.io.js and cache it locally. From there you can access global io and then connect with: </p> <pre><code>var socket = io.connect(); </code></pre> <p>It may be even better to copy the library into your application and have a background service that fetches the newest version every x days/weeks.</p>
3,136,263
0
<blockquote> <p>I was wondering whether it is possible to use Maven2 to automatically configure a Glassfish 2.1 with JNDI Resources, Datasources and Mail-Sessions for my integration tests.</p> </blockquote> <p>I'm not sure Cargo does provide anything to configure Mail-Sessions. And anyway, from what I can see in <a href="http://cargo.codehaus.org/DataSource+and+Resource+Support" rel="nofollow noreferrer">DataSource+and+Resource+Support</a>, there is no support at all for GlassFish. I'd simply configure the installed container against which you run your integration tests.</p> <blockquote> <p>Also I wonder whether it is possible to create some sort of benchmarks that might then be tracked using continuum or Hudson.</p> </blockquote> <p>You could run <a href="http://jakarta.apache.org/jmeter/" rel="nofollow noreferrer">JMeter</a> performance tests. Hudson has a <a href="http://wiki.hudson-ci.org/display/HUDSON/Performance+Plugin" rel="nofollow noreferrer">Performance Plugin</a> allowing to generate a trend graphic report from the results. Also maybe have a look at <a href="http://jchav.blogspot.com/" rel="nofollow noreferrer">JChav</a> (seems dormant though).</p>
34,033,844
0
<p>As a general rule, pass-by-value for basic types (int, char, etc.), and pass-by-pointer (or better, pass-by-reference) for big data as <code>struct</code>. </p> <p>Thinking of a <code>struct</code> with 1000 data members, and the cost to copy that gigantic data to a function. It'd be much quicker to pass-by-pointer or pass-by-reference in that case.</p>
40,394,385
1
PyQt5: open main window and close dialog <p>I have a login dialog and a main window. When I login, "success" must close the login dialog and open the main window. Now when I login, the main window is open, but login dialog does not close. But if I try to close it, but both the dialog and the window close. I want keep the window open, and close the login dialog.</p> <p><em>loginDialogStartup.py</em>:</p> <pre><code>class LoginDialogStartup(Ui_Dialog): def __init__(self, dialog): Ui_Dialog.__init__(self) self.setupUi(dialog) self.loginbtn.clicked.connect(self.doLogin) self.cancelbtn.clicked.connect(self.closeEvent) def closeEvent(self, event): print("Closing") self.destory() def doLogin(self): username = self.usernameinput.text() password = self.passwordinput.text() if validLogin(username, password): self.window = QtWidgets.QMainWindow() MainWindowStartup(self.window) self.window.show() self.loginbtn.clicked.connect(self, Qt.SIGNAL('triggered()'), self.closeEvent) else: self.statuplabel.setText("NO") if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) dialog = QtWidgets.QDialog() prog = LoginDialogStartup(dialog) dialog.show() sys.exit(app.exec_()) </code></pre> <p><em>MainWindowStartup.py</em>:</p> <pre><code>class MainWindowStartup(Ui_MainWindow): def __init__(self, window): Ui_MainWindow.__init__(self) self.setupUi(window) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) window = QtWidgets.QMainWindow() prog = MainWindowStartup(window) window.show() app.exec_() </code></pre>
27,229,265
1
How to set a transparent background color and do antialising for kivy images? <p>I whant to use an image with transparent background. The common kivy "Image" class offers the loading of a file into an image. But I found no way to set a transparent background color and set antialising.</p>