pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
19,186,457
0
<p>I agree this is a bad idea, but here is another possible solution;</p> <pre><code>data big; cust_id = 1; retain var1-var20000 0; run; data temp/view=temp; set big(keep=cust_id var1-var10000); run; proc export data=temp outfile='c:\temp\file1.csv' dbms=csv replace; run; data temp/view=temp; set big(keep=cust_id var10001-var20000); run; proc export data=temp outfile='c:\temp\file2.csv' dbms=csv replace; run; </code></pre> <p>To control the variables written, just change the view definition however you need. You originally asked about creating five CSVs, this creates two.</p> <p>You have to use a view because <code>PROC EXPORT</code> does not respect KEEP or DROP data set options. I don't think using a macro to do something like this is a good idea unless you are very sure you know what you are doing AND you need to run it multiple times with different scenarios.</p>
14,966,855
0
<p>As far as I know, you need to attach an article to a category to view it.</p> <p>You can assign the article to a category. After that open an article from that category and replace the text after the last "/" in url with the alias of your article.</p> <p>You can also assign the article to a category that is linked to a menu item. that way you will be able to see the article link in the menu. </p> <p>You may later remove the article from the category.</p>
39,885,290
0
<p>Here is a simple example of how to copy values from an input to another html tag:</p> <pre><code>&lt;input id="myInput" type="text" value="waffles" /&gt; &lt;button type="button" onclick="$('#copiedValue').html($('#myInput').val())"&gt;Copy value&lt;/button&gt; &lt;span id="copiedValue"&gt;&lt;/span&gt; </code></pre> <p>The jQuery is all in <code>onclick</code> which pulls the value from the input using <code>$('#myInput').val()</code> and supplies that value as an argument to replace the html contents of the span <code>$('#copiedValue').html(...)</code>.</p> <p>Here is a jsfiddle with the working code: <a href="https://jsfiddle.net/njacwybg/" rel="nofollow">https://jsfiddle.net/njacwybg/</a></p>
4,632,709
0
<p>As said, a reference to a pointer to Class.</p> <ul> <li>you pass a <code>Class *</code> to the function</li> <li>the function may change the pointer to a different one</li> </ul> <p>This is a rather uncommon interface, <strong>you need more details</strong> to know what pointers are expected, and what you have to do with them.</p> <p>Two examples:</p> <p><strong>Iteration</strong> </p> <pre><code>bool GetNext(Classs *&amp; class) { if (class == 0) { class = someList.GetFirstObject(); return true; } class = somePool.GetObjectAbove(class); // get next return class != 0; } // Use for oterating through items: Class * value = 0; while (GetNext(value)) Handle(value); </code></pre> <p><strong>Something completely different</strong></p> <pre><code>void function (Class *&amp; obj) { if (IsFullMoon()) { delete obj; obj = new Class(GetMoonPos()); } } </code></pre> <p>In that case, the pointer you pass must be new-allocated, and the pointer you receive you need to pass either to <code>function</code> again, or be <code>delete</code>'d by you.</p>
2,692,829
0
HTTP Response 412 - can you include content? <p>I am building a RESTful data store and leveraging Conditional GET and PUT. During a conditional PUT the client can include the Etag from a previous GET on the resource and if the current representation doesn't match the server will return the HTTP status code of 412 (Precondition Failed). Note this is an Atom based server/protocol.</p> <p>My question is, when I return the 412 status can I also include the new representation of the resource or must the user issue a new GET? The HTTP spec doesn't seem to say yes or no and neither does the Atom spec (although their example shows an empty entity body on the response). It seems pretty wasteful not to return the new representation and make the client specifically GET it. Thoughts?</p>
14,098,868
0
<pre><code>&lt;script type="text/javascript"&gt; {literal} $(function(){ $( "#ds" ).datepicker({ dateFormat: "dd-mm-yy" }); }); {/literal} &lt;/script&gt; </code></pre> <p>correction:</p>
35,047,148
0
When runtime modifications are written to Edits log file in Name Node, is the Edits Log file getting updated on RAM or Local Disk <p>When run-time modifications are written to Edits log file in Name Node, is the Edits Log file getting updated on RAM or Local Disk</p>
4,510,418
0
<pre><code>String urldisplay="http://www.google.com/";//sample url Log.d("url_dispaly",urldisplay); try{ InputStream in = new java.net.URL(urldisplay).openStream(); Bitmap mIcon11 = BitmapFactory.decodeStream(new SanInputStream(in)); } catch(Exception e){} </code></pre> <p>Create class name SanInputStream</p> <pre><code>public class SanInputStream extends FilterInputStream { public SanInputStream(InputStream in) { super(in); } public long skip(long n) throws IOException { long m = 0L; while (m &lt; n) { long _m = in.skip(n-m); if (_m == 0L) break; m += _m; } return m; } } </code></pre>
10,762,744
0
<p>Why make it so complex? Just declare the width and leave it at that:</p> <pre><code>#resulttbl{ width:100%; } </code></pre> <p>If for some reason that doesn't work, try using <code>!important</code>. If that does work then another rule is taking a higher precedence then the current rule.</p> <pre><code>#resulttbl{ width:100% !important; } </code></pre> <p><strong>update</strong></p> <p>cHao is correct. My answer is really just good advice at this point.</p>
39,799,979
0
<p>A very similar answer to @Suever, using a loop and logical matrix rather than cells</p> <pre><code>a = [3 3 5 5 20 20 20 4 4 4 2 2 2 10 10 10 6 6 1 1 1]; vals = unique(a); %find unique values vals = vals(randperm(length(vals))); %shuffle vals matrix aout = []; %initialize output matrix for ii = 1:length(vals) aout = [aout a(a==(vals(ii)))]; %add correct number of each value end </code></pre>
26,620,087
0
'pathos' provides a fork of python's 'multiprocessing', where 'pathos.multiprocessing' can send a much broader range of the built-in python types across a parallel 'map' and 'pipe' (similar to python's 'map' and 'apply'). 'pathos' also provides a unified interface for parallelism across processors, threads, sockets (using a fork of 'parallelpython'), and across 'ssh'.
21,841,153
0
<pre><code>from itertools import chain def shuffle(list1, list2): if len(list1)==len(list2): return list(chain(*zip(list1,list2))) # if the lists are of equal length, chaining the zip will be faster else: a = [] while any([list1,list2]): for lst in (list1,list2): try: a.append(lst.pop(0)) except IndexError: pass return a # otherwise, so long as there's items in both list1 and list2, pop the # first index of each (ignoring IndexError since one might be empty) # in turn and append that to a, returning the value when both lists are # empty. </code></pre> <p>This is not the recursive solution you were looking for, but an explicit one is generally faster and easier to read and debug anyway. @DSM pointed out that this is likely a homework question, so I apologize for misreading. I'll go ahead and leave this up in case it's enlightening to anyone.</p>
23,569,592
0
Lint does not find an Activity from a Library <p>I have a library project (in ADT) containing an Activity.</p> <p>This library is used by a project that uses this Activity.</p> <p>All this works perfectly well. The Activity is declared in the main project's manifest, it compiles, it runs, it does everything I need.</p> <p>All the compilation, library linking, lint checking happens in stock ADT without the help of anything else. (no maven, no ant, no makefile)</p> <p>However, when I run lint on the project, it complains that</p> <blockquote> <p>Class referenced in the manifest, com.test.library.LibraryActivity, was not found in the project or the libraries</p> </blockquote> <p>Which is incorrect, since it compiles and run.</p> <p>I have cleaned, removed the lint markers, deleted the lint.xml file, restarted ADT, still the same issue.</p> <p>I would like to have a proper full lint check before releasing. Any idea?</p> <h2>Edit</h2> <p>I have been doing more testing, and apparently command line <code>lint MyProject</code> works, tests library correctly</p>
20,947,917
0
Missing architecture x86_64 for MediaLibsDemo <p>I am using the following library for connecting to the Red5 server. <a href="https://github.com/slavavdovichenko/MediaLibDemos" rel="nofollow">https://github.com/slavavdovichenko/MediaLibDemos</a>. It gives me the following error. How can I add the missing architecture to the following file? or some other solution?</p> <pre><code>on implementing it, I am getting the following error. ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libavutil.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libavutil.a (2 slices) ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libavdevice.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libavdevice.a (2 slices) ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libswscale.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libswscale.a (2 slices) ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libavformat.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libavformat.a (2 slices) ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libavcodec.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libavcodec.a (2 slices) ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libavfilter.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libavfilter.a (2 slices) ld: warning: ignoring file /var/root/Documents/RTMP/RTMP/lib/MediaLibiOS/MediaLibiOS.a, missing required architecture x86_64 in file /var/root/Documents/RTMP/RTMP/lib/MediaLibiOS/MediaLibiOS.a (3 slices) ld: warning: ignoring file /private/var/root/Documents/RTMP/RTMP/lib/libav- v9.1965/lib/libavresample.a, missing required architecture x86_64 in file /private/var/root/Documents/RTMP/RTMP/lib/libav-v9.1965/lib/libavresample.a (2 slices) ld: warning: ignoring file /var/root/Documents/RTMP/RTMP/lib/CommLibiOS/CommLibiOS.a, missing required architecture x86_64 in file/var/root/Documents/RTMP/RTMP/lib/CommLibiOS/CommLibiOS.a (4 slices) Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_BroadcastStreamClient", referenced from: objc-class-ref in ViewController.o "_OBJC_CLASS_$_RTMPClient", referenced from: objc-class-ref in ViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) </code></pre>
31,630,353
0
<p>how i fix it? my subdomain not is randomically have where the replace for $1 ? cheers</p> <p>RewriteCond %{HTTP_HOST} ^(.<em>).domain.com RewriteRule ^(.</em>)$ <a href="http://domain.com/folder/%1/" rel="nofollow">http://domain.com/folder/%1/</a>$1 [R=301,L]</p>
12,924,058
0
<p>One complexity of MIDI files is <a href="http://dogsbodynet.com/fileformats/midi.html#RUNSTATUS" rel="nofollow">Running Status</a>. If there's sequence of messages of the same type and channel (eg all controllers or all notes) then MIDI can save a number of bytes by omitting the status byte. If this didn't use running status then the bytes you would see are:</p> <pre><code>00 B0 79 00 - controller 121: controller reset 00 B0 5B 00 - controller 91: reverb 00 B0 40 00 - controller 64: sustain 00 B0 07 64 - controller 7: volume 00 B0 0A 10 - controller 10: pan 00 90 3E 47 - note message </code></pre> <p>Because all the controller messages are contiguous and are for the same channel, the status byte can be omitted. As soon as there's a change of message type, the status byte has to be added again.</p> <p>If you're trying to make sense of MIDI files then I would recommend using a separate tool such as <a href="https://github.com/vishnubob/python-midi" rel="nofollow">Python-MIDI</a> or <a href="http://www.gnmidi.com/" rel="nofollow">GNMidi</a> as a sanity checker whenever there's a MIDI event you can't make sense of. These can show it as text so you can mimic what it's doing.</p> <p>EDIT: Another gotcha to be aware of is that any MIDI messages that take a length or duration parameter (eg the time in PPQN between events in a MIDI file, or the length of sysex messages or meta events) uses a variable length, so don't assume all the length fields are always a fixed length.</p> <p>Disclaimer: I wrote the MIDI export code in Sibelius 6...</p>
28,116,016
0
<p>So my solution is following:</p> <ol> <li>I created an instance.</li> <li>Install the required services on that instance.</li> <li>Created the image from the disk using the steps mentioned on this <a href="https://cloud.google.com/compute/docs/images#create_an_image_from_a_root_persistent_disk" rel="nofollow">link</a>.</li> <li>With that Image created a new template.</li> </ol> <p>The <a href="https://cloud.google.com/compute/docs/startupscript" rel="nofollow">startup scripts</a> will run on instance boots up or restarts. So the only way I found to run it once is the same which you have tired i.e deleting them from metadata. In my setup when using startup scripts I don't reboot the instances I rather delete them and create a new ones if required.</p>
38,041,813
0
cassandra error after yum update <p>Running CentOS 7.2, I did a yum update, and now I get errors when running cassandra. </p> <pre><code>[idf@node1 conf]$ grep -e 'tracetype_query_ttl' -e 'roles_validity_in_ms' -e 'enable_user_defined_functions' -e 'windows_timer_interval' -e 'enable_user_defined_functions' -e 'roles_validity_in_ms' -e 'role_manager' -e 'batch_size_fail_threshold_in_kb' -e 'tracetype_repair_ttl' cassandra.yaml [idf@node1 conf]$ [idf@node1 ~]$ sudo cassandra -v 2.1.14 </code></pre> <p>The command line shows this. As far as I remember, I did not change the <code>.yaml</code> file. In any event, I reverted to an earlier very similar version that I know was working and I still get the same error. When I search for these variables they aren't even in the <code>.yaml</code> file?</p> <pre><code>[idf@node1 ~]$ sudo cassandra [sudo] password for idf: [idf@node1 ~]$ CompilerOracle: inline org/apache/cassandra/db/AbstractNativeCell.compareTo (Lorg/apache/cassandra/db/composites/Composite;)I CompilerOracle: inline org/apache/cassandra/db/composites/AbstractSimpleCellNameType.compareUnsigned (Lorg/apache/cassandra/db/composites/Composite;Lorg/apache/cassandra/db/composites/Composite;)I CompilerOracle: inline org/apache/cassandra/io/util/Memory.checkBounds (JJ)V CompilerOracle: inline org/apache/cassandra/io/util/SafeMemory.checkBounds (JJ)V CompilerOracle: inline org/apache/cassandra/utils/ByteBufferUtil.compare (Ljava/nio/ByteBuffer;[B)I CompilerOracle: inline org/apache/cassandra/utils/ByteBufferUtil.compare ([BLjava/nio/ByteBuffer;)I CompilerOracle: inline org/apache/cassandra/utils/ByteBufferUtil.compareUnsigned (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I CompilerOracle: inline org/apache/cassandra/utils/FastByteOperations$UnsafeOperations.compareTo (Ljava/lang/Object;JILjava/lang/Object;JI)I CompilerOracle: inline org/apache/cassandra/utils/FastByteOperations$UnsafeOperations.compareTo (Ljava/lang/Object;JILjava/nio/ByteBuffer;)I CompilerOracle: inline org/apache/cassandra/utils/FastByteOperations$UnsafeOperations.compareTo (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I INFO 19:42:06 Hostname: INFO 19:42:06 Loading settings from file:/home/idf/cassandra.yaml INFO 19:42:06 Node configuration:[authenticator=AllowAllAuthenticator; authorizer=AllowAllAuthorizer; auto_snapshot=true; batch_size_fail_threshold_in_kb=50; batch_size_warn_threshold_in_kb=5; batchlog_replay_throttle_in_kb=1024; cas_contention_timeout_in_ms=1000; client_encryption_options=&lt;REDACTED&gt;; cluster_name=Test Cluster; column_index_size_in_kb=64; commit_failure_policy=stop; commitlog_directory=/var/lib/cassandra/commitlog; commitlog_segment_size_in_mb=32; commitlog_sync=periodic; commitlog_sync_period_in_ms=10000; compaction_large_partition_warning_threshold_mb=100; compaction_throughput_mb_per_sec=16; concurrent_counter_writes=32; concurrent_reads=32; concurrent_writes=32; counter_cache_save_period=7200; counter_cache_size_in_mb=null; counter_write_request_timeout_in_ms=5000; cross_node_timeout=false; data_file_directories=[/var/lib/cassandra/data]; disk_failure_policy=stop; dynamic_snitch_badness_threshold=0.1; dynamic_snitch_reset_interval_in_ms=600000; dynamic_snitch_update_interval_in_ms=100; enable_user_defined_functions=false; endpoint_snitch=SimpleSnitch; hinted_handoff_enabled=true; hinted_handoff_throttle_in_kb=1024; incremental_backups=false; index_summary_capacity_in_mb=null; index_summary_resize_interval_in_minutes=60; inter_dc_tcp_nodelay=false; internode_compression=all; key_cache_save_period=14400; key_cache_size_in_mb=null; listen_address=10.0.0.60; max_hint_window_in_ms=10800000; max_hints_delivery_threads=2; memtable_allocation_type=heap_buffers; native_transport_port=9042; num_tokens=256; partitioner=org.apache.cassandra.dht.Murmur3Partitioner; permissions_validity_in_ms=2000; range_request_timeout_in_ms=10000; read_request_timeout_in_ms=5000; request_scheduler=org.apache.cassandra.scheduler.NoScheduler; request_timeout_in_ms=10000; role_manager=CassandraRoleManager; roles_validity_in_ms=2000; row_cache_save_period=0; row_cache_size_in_mb=0; rpc_address=10.0.0.60; rpc_keepalive=true; rpc_port=9160; rpc_server_type=sync; saved_caches_directory=/var/lib/cassandra/saved_caches; seed_provider=[{class_name=org.apache.cassandra.locator.SimpleSeedProvider, parameters=[{seeds=127.0.0.1}]}]; server_encryption_options=&lt;REDACTED&gt;; snapshot_before_compaction=false; ssl_storage_port=7001; sstable_preemptive_open_interval_in_mb=50; start_native_transport=true; start_rpc=false; storage_port=7000; thrift_framed_transport_size_in_mb=15; tombstone_failure_threshold=100000; tombstone_warn_threshold=1000; tracetype_query_ttl=86400; tracetype_repair_ttl=604800; trickle_fsync=false; trickle_fsync_interval_in_kb=10240; truncate_request_timeout_in_ms=60000; unlogged_batch_across_partitions_warn_threshold=10; windows_timer_interval=1; write_request_timeout_in_ms=2000] ERROR 19:42:06 Fatal configuration error org.apache.cassandra.exceptions.ConfigurationException: Invalid yaml. Please remove properties [tracetype_query_ttl, roles_validity_in_ms, enable_user_defined_functions, windows_timer_interval, role_manager, batch_size_fail_threshold_in_kb, tracetype_repair_ttl] from your cassandra.yaml at org.apache.cassandra.config.YamlConfigurationLoader$MissingPropertiesChecker.check(YamlConfigurationLoader.java:162) ~[apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:115) ~[apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.config.YamlConfigurationLoader.loadConfig(YamlConfigurationLoader.java:84) ~[apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.config.DatabaseDescriptor.loadConfig(DatabaseDescriptor.java:161) ~[apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.config.DatabaseDescriptor.&lt;clinit&gt;(DatabaseDescriptor.java:136) ~[apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:168) [apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:564) [apache-cassandra-2.1.14.jar:2.1.14] at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:653) [apache-cassandra-2.1.14.jar:2.1.14] Invalid yaml. Please remove properties [tracetype_query_ttl, roles_validity_in_ms, enable_user_defined_functions, windows_timer_interval, role_manager, batch_size_fail_threshold_in_kb, tracetype_repair_ttl] from your cassandra.yaml Fatal configuration error; unable to start. See log for stacktrace. </code></pre>
17,664,302
0
comparing float values in C program gets stuck <p>I am working on an assignment for an embedded software course, but I'm having the strangest problem.</p> <p>Using the code below:</p> <pre><code>void decidePotato(float held) { printf("Deciding Potato, held for %f seconds \n", held); if (held &gt;= 1.99) { printf("Held for more than 1.99s \n", held); returnPotato(); } printf("I evaluated the if statement above \n"); } </code></pre> <p>I get the following output:</p> <pre><code>Deciding Potato, held for 0.010000 seconds </code></pre> <p>I dont even see the "I evaluated the if statement above" message, so the program somehow got stuck evaluating that if statement. And it remains stuck until I reprogram the board How is that even possible?</p>
32,776,328
0
<p>That's because the <code>i</code> in your projection is referencing the original item in <code>oldUserEntities</code>, then <code>i.RowKey</code> is modifying the original data.</p> <p>Try this instead (assuming your entity is named <code>UserEntity</code>):</p> <pre><code>var oldUserEntities = userEntities.ToList(); var newUserEntities = userEntities.Select(i =&gt; new UserEntity { RowKey = dict[i.RowKey], // rest of desired properties ... }).ToList(); </code></pre>
23,008,635
0
How to correctly expose images uploaded by web application? <p>In my Spring MVC web application I have a web form to upload images. These images are stored in a server folder outside web application (say <code>C:\\images</code>).</p> <p>Now I need to load these images in another page, but I don't want to expose the folder as public. I think I need to map the path via a servlet or something similar...</p> <p>Can you help me? Is there some easy way using Spring framework?</p>
18,559,895
0
<p>If the file has been staged (it looks like yours was), a snapshot will exist is Git's database. We can get it back!</p> <p>Git stores snapshots internally in the <code>.git/objects/</code> direction in your repository. Each object is stored in a file named for its hash, split into directories by the first 2 characters. Snapshots will exist here until they are either packed into files in <code>.git/objects/pack/</code> (which won't happen to a snapshot that was never part of a commit) or garbage collected (which will eventually happen to your missing file). The hard part will be figuring out which object it is.</p> <p>To find the object, run</p> <pre><code>ls -lRt .git/object </code></pre> <p>to get a list of all objects sorted by last modified time. Here's what my hypothetical repository looks like:</p> <pre><code>$ ls -lRt .git/object .git/objects/22: total 4 -r--r--r-- 1 peter peter 17 Sep 1 11:18 3b7836fb19fdf64ba2d3cd6173c6a283141f78 .git/objects/f7: total 4 -r--r--r-- 1 peter peter 17 Sep 1 11:09 0f10e4db19068f79bc43844b49f3eece45c4e8 .git/objects/54: total 4 -r--r--r-- 1 peter peter 51 Sep 1 11:08 3b9bebdc6bd5c4b22136034a95dd097a57d3dd .git/objects/e8: total 4 -r--r--r-- 1 peter peter 134 Sep 1 11:08 e8417380c89509ec1e5b67c15469547a4489c2 .git/objects/e6: total 4 -r--r--r-- 1 peter peter 15 Sep 1 11:08 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 </code></pre> <p>Run</p> <pre><code>git cat-file -p &lt;hash&gt; </code></pre> <p>on candidate objects until you find the one you're missing. Remember to add the 2 characters from the directory name to the hash. In my case, if I'm interested in the file from 11:09</p> <pre><code>git cat-file -p f70f10 </code></pre> <p>Happy hunting.</p>
34,817,389
0
<p><code>mysqli_query()</code> can only execute 1 query, if you want to execute multiple queries, you need:</p> <pre><code>if (mysqli_multi_query($conn, $sql)) { </code></pre>
25,337,758
0
<p>Add this line in <code>form2</code> constructor:</p> <pre><code>public Form2() { InitializeComponenet(); picturebox.Image = Image.FromFile(@"D:\img.jpg"); //added } </code></pre>
4,179,716
0
jQuery - Event for when an attribute of a node changes <p>I have a webpage with an external javascript library, and my own extra code. The external library can't be change. It manipulates dom elements, adds new ones, changes attributes (e.g. <code>src</code> on some <code>&lt;img&gt;</code> nodes, etc.). I am using jQuery. Is there any event handler that is fired when the value of an attribute changes of a node?</p> <p>i.e. is there anyway I can detect (in jQuery) when the <code>src</code> of an <code>&lt;img&gt;</code> is changed (by someone else?)</p>
23,304,328
0
<p>Since this specific issue seems to be resolved but it hasn't been addressed in an answer, I'll make the general remark that when trying to debug an error that pops up in the jQuery/jQuery UI/etc files, it's usually not actually an error IN THAT FILE, it's an error in your usage of it that isn't actually breaking until it gets down into jQuery. So you really want to just figure out "what Javascript that I wrote was being run right before that broke?", and start there.</p>
30,051,602
0
How to display reports in dashboard ms dynamic crm 2015 <p>I have tried webresource and iframe way to display reports in dasboard but screen is blank in 2015 crm.Please find the blog links which i used to display reports:</p> <p><a href="https://reportingondashboard.codeplex.com/SourceControl/latest#ReportControl.html" rel="nofollow">https://reportingondashboard.codeplex.com/SourceControl/latest#ReportControl.html</a></p> <p><a href="http://weblogs.asp.net/pabloperalta/how-to-display-a-report-in-a-dashboard-in-dynamics-crm-2011" rel="nofollow">http://weblogs.asp.net/pabloperalta/how-to-display-a-report-in-a-dashboard-in-dynamics-crm-2011</a></p> <p>I am not able to get it.Please let me know how to display reports in dashboards 2015 ms crm</p>
35,961,223
0
<p>Use the <code>file()</code> function in PHP to split each line of the file into an array then set each element of the array equal to it's respective variable. For example:</p> <pre><code>$lines = file('user1.txt'); $firstname = $lines[0]; $lname = $lines[1]; $age = $lines[2]; $gender = $lines[3]; </code></pre>
19,550,324
0
<p>!true -> false</p> <p>!!true -> true</p> <p>!!!true -> false</p>
34,086,082
0
<p>for time:</p> <pre><code>pattern = ("(\d{2}:\d{2}:\d{2},\d{3}?.*)") </code></pre>
30,944,846
0
<p>Something is missing from your question. Your input string cannot have spaces and your output of a double containing spaces is not possible.</p> <pre><code>double result = Convert.ToDouble("555 555 584", CultureInfo.InvariantCulture); </code></pre> <p>Results in:</p> <p>An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll</p> <p>Additional information: Input string was not in a correct format.</p> <p>Try this:</p> <pre><code>string value = Box.Text.Replace(" ", ""); double result = Convert.ToDouble(value, CultureInfo.InvariantCulture); </code></pre>
4,942,483
0
logcat indicate error? <p>hi now i am create simple andengine application...now my logcat indicate error....what mistake i made for my application.....</p> <pre><code> 02-09 13:05:01.560: ERROR/AndEngine(280): Failed loading Bitmap in AssetTextureSource.AssetPath: ggg 02-09 13:05:01.560: ERROR/AndEngine(280): java.io.FileNotFoundException: ggg 02-09 13:05:01.560: ERROR/AndEngine(280): at android.content.res .AssetManager.openAsset(Native Method) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.content.res .AssetManager.open(AssetManager.java:313) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.content.res .AssetManager.open(AssetManager.java:287) 02-09 13:05:01.560: ERROR/AndEngine(280): at org.anddev.andengine.opengl .texture.source.AssetTextureSource.&lt;init&gt;(AssetTextureSource.java:46) 02-09 13:05:01.560: ERROR/AndEngine(280): at org.anddev .andengine.opengl.texture.region.TextureRegionFactory .createFromAsset(TextureRegionFactory.java:66) 02-09 13:05:01.560: ERROR/AndEngine(280): at org.anddev .andengine.examples.minimal .AndEngineMinimalExample.onLoadResources(AndEngineMinimalExample.java:59) 02-09 13:05:01.560: ERROR/AndEngine(280): at org.anddev.andengine.ui.activity .BaseGameActivity.doResume(BaseGameActivity.java:158) 02-09 13:05:01.560: ERROR/AndEngine(280): at org.anddev.andengine.ui.activity .BaseGameActivity.onWindowFocusChanged(BaseGameActivity.java:83) 02-09 13:05:01.560: ERROR/AndEngine(280): at com.android.internal.policy.impl .PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:1981) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.view.View .dispatchWindowFocusChanged(View.java:3788) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.view.ViewGroup . dispatchWindowFocusChanged(ViewGroup.java:658) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.view.ViewRoot .handleMessage(ViewRoot.java:1921) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.os.Handler .dispatchMessage(Handler.java:99) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.os.Looper .loop(Looper.java:123) 02-09 13:05:01.560: ERROR/AndEngine(280): at android.app.ActivityThread .main(ActivityThread.java:4627) 02-09 13:05:01.560: ERROR/AndEngine(280): at java.lang.reflect.Method .invokeNative(Native Method) 02-09 13:05:01.560: ERROR/AndEngine(280): at java.lang.reflect.Method .invoke(Method.java:521) 02-09 13:05:01.560: ERROR/AndEngine(280): at com.android.internal.os .ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 02-09 13:05:01.560: ERROR/AndEngine(280): at com.android.internal.os .ZygoteInit.main(ZygoteInit.java:626) 02-09 13:05:01.560: ERROR/AndEngine(280): at dalvik.system .NativeStart.main(Native Method) 02-09 13:05:02.330: ERROR/AndEngine(280): Failed loading Bitmap in AssetTextureSource. AssetPath: ggg 02-09 13:05:02.330: ERROR/AndEngine(280): java.io.FileNotFoundException: ggg 02-09 13:05:02.330: ERROR/AndEngine(280): at android.content.res.AssetManager.openAsset(Native Method) 02-09 13:05:02.330: ERROR/AndEngine(280): at android.content.res .AssetManager.open(AssetManager.java:313) </code></pre>
10,705,624
0
TeamCity building MSP files <p>For background: I've got quite a nice TeamCity setup; containing a ci build and a release build which uses WiX to build my installers and patch all the version numbers. When I do a new release build, I'd like to automatically create MSP patches against a previous set of installers. I'm thinking either tagged RTM in TeamCity, or as a list of version numbers.</p> <p>The approach I'm leaning towards is creating a separate config and getting the msi artifacts of all the previous builds that fit the criteria (tag or version number). Tag would seem a lot neater, but I can't see anything in the documentation about how you use it?</p> <p>I've got a script to build the MSP patch, but it relies on a PCP file which needs to be edited in ORCA to describe the patch. </p> <ol> <li>In terms of editing the PCP, is there anything else I can use other than the ORCA to edit? I've been looking at moving to the WiX method here: <a href="http://wix.sourceforge.net/manual-wix3/patch_building.htm" rel="nofollow">http://wix.sourceforge.net/manual-wix3/patch_building.htm</a> which looks promising.</li> <li>Does anyone know if you can access artifacts in TeamCity by Tag in the same or another build?</li> <li>Does anyone have any other insights into automatically building/chaining MSP patch files in TeamCity?</li> </ol>
26,600,737
0
<p>Once buyer login to their paypal account during checkout, the buyer will be able to see their email and shipping address as shown in the image for PayPal Payment Standard buttons such as buynow, addto cart.</p> <p>If you are using Express checkout Integration, you can use <a href="https://developer.paypal.com/docs/classic/api/merchant/GetExpressCheckoutDetails_API_Operation_NVP/" rel="nofollow noreferrer">GetExpressCheckoutDetails</a> API to retrieve the buyer information and display in the order summary page on your website(not in paypal checkout page). <img src="https://i.stack.imgur.com/XsKkt.jpg" alt="enter image description here"></p>
4,251,945
0
Symfony Actions Namespacing, or a better way? <p>In Rails, you can organize controllers into folders and keep your structure nice with namespacing. I'm looking for a similar organizational structure in Symfony 1.4.</p> <p>I was thinking of organizing multiple actions.class.php files in an actions folder, but all I came across was using independent action files, one for each action... like this:</p> <pre><code># fooAction.class.php class fooAction extends sfActions { public function executeFoo() { echo 'foo!'; } } </code></pre> <p>But I'd have to develop a whole new routing system in order to fit multiple actions into that file, which is... silly.</p> <p>Really I'm just looking to make Symfony into Rails, (again, silly, but I'm stuck with Symfony for this project) so I'm wondering if there's a better way....?</p> <p>Thanks.</p>
13,002,233
0
<p>You were close.</p> <pre><code>a.menuLink:link { color: green; } </code></pre> <p>Was what you intended to achieve. But try this:</p> <pre><code>a.menuLink { color: green; } </code></pre> <p>Would mean a <em><code>a</code> with a classname of <code>menuLink</code></em>, the <code>:link</code> is redundant. </p> <hr> <pre><code>.menuLink a:link </code></pre> <p>Would mean <em><code>a</code> <strong>inside</strong> of an element with a classname of <code>menuLink</code></em>. </p>
13,425,602
0
<p>Here's what I would do with what you've given</p> <pre><code>$('span.[class^="cell_"]').each(function(i,v){ // loop through each span with class that starts with cell_ var num = +$(v).attr('class').split('_')[1]; // get the number from the class $(v).css('left',(num * 10) + 'px') // use it to get the px }); </code></pre>
24,214,469
0
<p>What's happening is the Dependency Property is getting Registered multiple times under the same name and owner. Dependency Properties are intended to have a single owner, and should be statically instanced. If you don't statically instance them, an attempt will be made to register them for each instance of the control.</p> <p><strong>Make your DependencyProperty declaration static. Change it from:</strong></p> <pre><code> public DependencyProperty SomeStringValueProperty = DependencyProperty.Register("SomeStringValue", typeof(string), typeof(ExampleUserControl)); </code></pre> <p><strong>To:</strong></p> <pre><code>public static DependencyProperty SomeStringValueProperty = DependencyProperty.Register("SomeStringValue", typeof(string), typeof(ExampleUserControl)); </code></pre>
22,328,355
0
Unity3D: Trying to make a custom Sleep/Wait function in C# <p>All this started yesterday when I use that code for make a snippet:</p> <pre><code>void Start() { print("Starting " + Time.time); StartCoroutine(WaitAndPrint(2.0F)); print("Before WaitAndPrint Finishes " + Time.time); } IEnumerator WaitAndPrint(float waitTime) { yield return new WaitForSeconds(waitTime); print("WaitAndPrint " + Time.time); } </code></pre> <p>From: <a href="http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.StartCoroutine.html" rel="nofollow">http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.StartCoroutine.html</a></p> <p>The problem is that I want to set a static variable from a class of that type:</p> <pre><code>class example { private static int _var; public static int Variable { get { return _var; } set { _var = value; } } } </code></pre> <p>Which is the problem? The problem is that If put that variable in a parameter of a function this "temporal parameter" will be destroyed at the end of the function... So, I seached a little bit, and I remebered that:</p> <pre><code>class OutExample { static void Method(out int i) { i = 44; } static void Main() { int value; Method(out value); // value is now 44 } } </code></pre> <p>From: <a href="http://msdn.microsoft.com/es-es/library/ms228503.aspx" rel="nofollow">http://msdn.microsoft.com/es-es/library/ms228503.aspx</a></p> <p>But, (there's always a "but"), <a href="http://stackoverflow.com/questions/999020/why-iterator-methods-cant-take-either-ref-or-out-parameters">Iterators cannot have ref or out</a>... so I decide to create my own wait function because Unity doesn't have Sleep function...</p> <p>So there's my code:</p> <pre><code> Debug.Log("Showing text with 1 second of delay."); float time = Time.time; while(true) { if(t &lt; 1) { t += Time.deltaTime; } else { break; } } Debug.Log("Text showed with "+(Time.time-time).ToString()+" seconds of delay."); </code></pre> <p>What is the problem with that code? The problem is that It's very brute code, becuase It can produce memory leak, bugs and of course, the palayzation of the app...</p> <p>So, what do you recomend me to do?</p>
2,841,484
0
How can a <label> completely fill its parent <td>? <p>Here is the relevant code (doesn't work):</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;testing td checkboxes&lt;/title&gt; &lt;style type="text/css"&gt; td { border: 1px solid #000; } label { border: 1px solid #f00; width: 100%; height: 100% } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Some column title&lt;/td&gt; &lt;td&gt;Another column title&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Value 1&lt;br&gt;(a bit more info)&lt;/td&gt; &lt;td&gt;&lt;label&gt;&lt;input type="checkbox" /&gt; &amp;nbsp;&lt;/label&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Value 2&lt;/td&gt; &lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The reason is that I want a click anywhere in the table cell to check/uncheck the checkbox.</p> <p>edits: By the way, no javascript solutions please, for accessibility reasons. I tried using display: block; but that only works for the width, not for the height</p>
36,716,181
0
Getting Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) null value <p>This is onConnected method :</p> <pre><code>try { mGoogleApiClient.connect(); Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this); if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); googlePlusProfilrInfo(currentPerson); isGooglePlusClicked = false; } else { Toast.makeText(getApplicationContext(), "No Personal info mention", Toast.LENGTH_LONG).show(); } } </code></pre> <p>BuildGooglePlus API in oncreate</p> <pre><code>mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API,Plus.PlusOptions.builder().build()) .addScope(Plus.SCOPE_PLUS_PROFILE) .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); </code></pre> <p>onClick </p> <pre><code>public void onClick(View v) { if(Utils.isConnectedToInternet(LoginActivity.this)){ switch (v.getId()) { case R.id.img_login_google_plus: signInWithGplus(); isGooglePlusClicked = true; Log.i(TAG, "onClick isGooglePlusClicked value=" + isGooglePlusClicked); if (!mGoogleApiClient.isConnecting()) { resolveSignInError(); } else { Toast.makeText( this, "Google sign-in not available for now. Please try again later.", Toast.LENGTH_SHORT).show(); Log.i(TAG, "else case"); } break; private void signInWithGplus() { if (!mGoogleApiClient.isConnecting()) { isGooglePlusClicked = true; resolveSignInError(); } } public void SignOutFromGPlus() { if(mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); mGoogleApiClient.connect(); } } @Override public void onConnectionSuspended(int cause) { // The connection to Google Play services was lost for some reason. // We call connect() to attempt to re-establish the connection or get a // ConnectionResult that we can attempt to resolve. mGoogleApiClient.connect(); } @Override public void onConnectionFailed(ConnectionResult result) { if (!result.hasResolution()) { GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show(); return; } if (!mIntentInProgress) { // Store the ConnectionResult for later usage mConnectionResult = result; if (gServicesSignInProg == STATE_SIGN_IN) { // The user has already clicked 'sign-in' so we attempt to // resolve all // errors until the user is signed in, or they cancel. resolveSignInError(); } } } private void resolveSignInError() { if (mConnectionResult.hasResolution()) { try { mIntentInProgress = true; mConnectionResult.startResolutionForResult(this, RC_SIGN_IN); } catch (IntentSender.SendIntentException e) { mIntentInProgress = false; mGoogleApiClient.connect(); } } } @Override public void onConnected(Bundle connectionHint) { // Reaching onConnected means we consider the user signed in. // Update the user interface to reflect that the user is signed in. // Retrieve some profile information to personalize our app for the // user. try { mGoogleApiClient.connect(); Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this); if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); googlePlusProfilrInfo(currentPerson); isGooglePlusClicked = false; } else { Toast.makeText(getApplicationContext(), "No Personal info mention", Toast.LENGTH_LONG).show(); } } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>Getting continuously null person value... Please solve this...</p>
37,273,355
0
<p>try this code: write this code in your manifest</p> <pre><code> &lt;activity android:name="Activity1" android:theme="@style/AppTheme1" /&gt; </code></pre> <p>for another activity</p> <pre><code>&lt;activity android:name="Activity2" android:theme="@style/AppTheme2" /&gt; </code></pre>
6,530,963
0
Do I need to use authentication check for public methods? <p>In object-oriented PHP application, do I need to use <code>authentication</code> check in almost every <code>public</code> method in my application for security?</p> <p>I'm worried about this vulnerability: <a href="http://cwe.mitre.org/top25/#CWE-306" rel="nofollow">CWE-306: Missing Authentication for Critical Function</a></p> <p><strong>How anyone could call my public methods, even if I use <code>static</code> keyword?</strong></p> <hr> <p>What are the requirements for this attack to succeed?</p> <p>Like some another vulnerability - Like allowing PHP file uploads to my system?</p>
5,910,090
0
<pre><code> int[] a1, a2, a3; a1 = new int[3]; a2 = new int[1]; a3 = new int[1]; bool equalLength = (a1.Length == (a2.Length &amp; a3.Length)); </code></pre>
29,316,538
0
Is f(++i, ++i) undefined? <p>I seem to recall that in C++11, they made some changes to the sequencing behaviour and that now i++ and ++i have different sequencing requirements.</p> <p>Is <code>f(++i, ++i)</code> still undefined behaviour? What is the difference between <code>f(i++, i++)</code> and <code>f(++i, ++i)</code>?</p>
28,951,867
0
<p>Your code is a bit messy but a quick fix will be to add: </p> <p><code>this.props.enter(this.refs.inputEl.getDOMNode().value);</code> </p> <p>where your <code>console.log()</code> is. I will edit my answer with the full explanation once I'm on my laptop</p>
37,345,852
0
<p>Check your main method:</p> <pre><code>public static void main(String[] args) throws Exception { new Test().searchBetweenDates(startDate, endDate); searchBetweenDates(startDate, endDate); </code></pre> <p>the parenthesis is missing. It should be:</p> <pre><code>public static void main(String[] args) throws Exception { new Test().searchBetweenDates(startDate, endDate); searchBetweenDates(startDate, endDate); } </code></pre>
9,838,299
0
<p>How to debug a Rails application:</p> <ol> <li>Place a breakpoint somewhere in the app code</li> <li><a href="http://www.jetbrains.com/ruby/webhelp/running-and-debugging-2.html" rel="nofollow">Create Rails Server Run/Debug configuration</a> (or use the existing one if the project was created in RubyMine)</li> <li>Click on the <strong>Debug</strong> button in the toolbar</li> <li>Rails server starts in debug mode</li> <li>Browser with the app opens (or you open it manually if such option was disabled)</li> <li>Navigate to the page that will trigger breakpoint</li> <li>Observe the stack frame, locals, etc in the RubyMine Debugger pannel.</li> </ol>
12,436,436
0
<p>The answers so far are all right, but i think you should do it differently for future use. Maybe your count will extend, so just search for the first occurence of "." and then cut the string there.</p> <pre><code>text = text.substring(text.indexOf(".")+1); </code></pre>
15,973,808
0
<p>You're sending something called "books.xls", and correctly signalling that it's an Excel spreadsheet... but it isn't. You've completely missed the step of actually creating an Excel spreadsheet containing your data (which is probably 80% of the work here).</p> <p>Try searching the web for how to create an excel spreadsheet in Python.</p>
36,501,884
0
<p>I need to do something like that, but When I try to execute this code it stops with an error</p> <pre><code>Run-time Error 91 : Object variable or With block variable not set. </code></pre> <p>And the error is in those lines:</p> <pre><code>iTotalWords = wordHilite.getNumText iTotalWords = PDFJScriptObj.getPageNumWords(Nthpage) </code></pre>
20,976,898
0
<p>Firstly, the k-means clustering algorithm doesn't necessarily produce an optimal result, thus that's already a fairly significant indicator that it might have different results from different starting points.</p> <p>It really comes down to the fact that each cluster uses the points in its own cluster to determine where it should move to - if all the clusters find their way to the centre of their respective points, the algorithm will terminate, and there can be multiple ways this can happen.</p> <p>Consider this example: (4 points indicated by <code>.</code> and 2 clusters indicated by <code>x</code>)</p> <pre><code>. . . x . x x versus . . . x . </code></pre> <p>Both the left and the right side have converged, but they're clearly different (the one on the right is clearly worse).</p> <p>To find the best one you can pick the result that minimizes the sum of square distances from the centres to each of the points classified under it (this is, after all, <a href="http://en.wikipedia.org/wiki/K-means_algorithm#Description" rel="nofollow">the goal of k-means clustering</a>).</p>
40,451,054
0
Can't install HTK on linux <p>I wan't to use ALIZE for speaker recognition and after the instalation there is one of the steps: <em>feature extraction using SPRO or HTK</em> So I downloaded zip file of HTK and using terminal I configured everything, but when entering <strong>make all</strong> I'm getting this error:</p> <pre><code>/usr/bin/ld: cannot find -lX11 collect2: error: ld returned 1 exit status Makefile:56: recipe for target 'HSLab' failed make[1]: *** [HSLab] Error 1 make[1]: Leaving directory '/home/username/Downloads/htk/HTKTools' Makefile:108: recipe for target 'htktools' failed make: *** [htktools] Error 1 </code></pre> <p>what does it mean and how to fix this? I'm looking for answer for hours and can't find anything...</p> <p>I'm using HTK 3.4.1 stable version and LInux ubuntu 16.10</p>
19,230,907
0
How to override erb with liquid? <p>I've added a theming directory to my app as described <a href="http://stackoverflow.com/a/6082751/628859">here</a>, using <code>prepend_view_path</code>. It works as expected. I can now add a view structure in my app under <code>app/themes/my_theme/views</code></p> <p>Now, I want to be able to override <code>erb</code> templates by dropping in a <code> .liquid</code> file, which will render right off the controller action.</p> <p>For example, I want to override <code>app/views/pages/home.html.erb</code>:</p> <pre><code>&lt;h1&gt;&lt;%= t 'it_works' %&gt;&lt;/h1&gt; </code></pre> <p>...with <code>app/themes/my_theme/views/pages/home.liquid</code></p> <pre><code>&lt;h1&gt;It works with {{ "liquid" }}&lt;/h1&gt; </code></pre> <p>I don't want to have to specify an array of view paths (upkeep would be awful), but just add <code>.liquid</code> as a layer to the templating engine. Maybe, however, have a blacklist of protected views that cannot be overridden (such as <code>app/views/admin/*</code>)</p>
2,118,469
0
<p>Use ViewState between postbacks otherwise value of property will be lost.</p> <pre><code>public string UrlForRedirecting { get { object urlForRedirecting = ViewState["UrlForRedirecting"]; if (urlForRedirecting != null) { return urlForRedirecting as string; } return string.Empty; } set { ViewState["UrlForRedirecting"] = value; } } </code></pre>
29,405,880
0
mySQL group by 3 columns <p>I have a query here that group by 3 columns and count the total rows</p> <pre><code>SELECT count(*) FROM ( SELECT date,bankName FROM table GROUP BY date,bankName,referenceNo ) a; </code></pre> <p>Basically, this query is used for pagination. I have two queries before this one.</p> <p>I have 166,000 rows of data now and this query taking 1.23 seconds to return the result which is not nice to use when the data grows. What should I do?</p>
30,891,392
0
WPF: how to change my chart to get only one value instead of 2 <p>This is my <code>chart</code>:</p> <pre><code>&lt;Grid&gt; &lt;chartingToolkit:Chart Name="lineChart" Margin="16,90,30,483" Background="Transparent"&gt; &lt;chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True" Margin="0,-37,0,37" &gt; &lt;chartingToolkit:LineSeries.Template&gt; &lt;ControlTemplate TargetType="chartingToolkit:LineSeries"&gt; &lt;Canvas x:Name="PlotArea"&gt; &lt;Polyline x:Name="polyline" Points="{TemplateBinding Points}" Stroke="Yellow" Style="{TemplateBinding PolylineStyle}" /&gt; &lt;/Canvas&gt; &lt;/ControlTemplate&gt; &lt;/chartingToolkit:LineSeries.Template&gt; &lt;/chartingToolkit:LineSeries&gt; &lt;/chartingToolkit:Chart&gt; &lt;/Grid&gt; </code></pre> <p>Currently i am using this <code>list</code> to populate my <code>chart</code>:</p> <pre><code>ObservableCollection&lt;KeyValuePair&lt;int, int&gt;&gt; points </code></pre> <p>But after change my model i have only 1 <code>value</code> that i want to add - <code>double</code> so i try to remove from my <code>chart</code> the <code>DependentValuePath="Value"</code> or <code>IndependentValuePath="Key"</code> but this likely not the way to do that.</p>
5,919,530
1
What is the pythonic way to calculate dot product? <p>I have two lists, one is named as A, another is named as B. Each element in A is a triple, and each element in B is just an number. I would like to calculate the result defined as :</p> <p>result = A[0][0] * B[0] + A[1][0] * B[1] + ... + A[n-1][0] * B[n-1]</p> <p>I know the logic is easy but how to write in pythonic way?</p> <p>Thanks!</p>
15,185,421
0
Using the Result arg in SuperObject <p>i'm using this superobject unit in one of my project as an rpc protocol, and inside a remote called procedure (signature has a var Result arg) i want to know how to use that arg...</p> <p>isn't there a documentation ? thanks.</p> <pre><code>program test_rpc; {$IFDEF FPC} {$MODE OBJFPC}{$H+} {$ELSE} {$APPTYPE CONSOLE} {$ENDIF} uses SysUtils, superobject; procedure controler_method1(const This, Params: ISuperObject; var Result: ISuperObject); var i: Integer; begin write('action called with params '); writeln(Params.AsString); try // How do i use Result arg to return a value ? as if it were a function returning string Result except exit; end; end; var s: ISuperObject; begin s := TSuperObject.Create; s.M['controler.action1'] := @controler_method1; try s['controler.action1("HHAHAH")']; finally s := nil; writeln('Press enter ...'); readln; end; end. </code></pre>
20,195,544
0
Scala: how to understand the flatMap method of Try? <p>The flatMap method of the Success is implemented like this:</p> <pre><code> def flatMap[U](f: T =&gt; Try[U]): Try[U] = try f(value) catch { case NonFatal(e) =&gt; Failure(e) } </code></pre> <p>I kinda understand what this method is doing, it helps us to avoid writing a lot of catching code.</p> <p>But in what sense is it similar to the regular flatMap? </p> <p>A regular flatMap takes a sequence of sequences, and put all the elements into one big "flat" sequence.</p> <p>But the flatMap method of Try is not really flattening anything.</p> <p>So, how to understand the flatMap method of Try?</p>
12,677,532
0
Datatable custom sort function on a given column <p>I am using jquery datatables and I need to sort data by the first column which contains checkboxes by displaying checked boxes first </p> <pre><code>oTable = $('#userTable', context).dataTable( { "sAjaxSource":'/ajax/getdata/', "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { "dataType": 'json', "type": "POST", "url": sSource, "data": params, "success" : function(data) { fnCallback(data); fnSortBySelected(); } }); } }); var fnSortBySelected = function() { var oSettings = oTable.fnSettings(); var i = 0; $('td:first-child input[type=checkbox]',oTable).sort(function(a, b) { if(a.checked) oTable.fnUpdate( oSettings.aoData[i]._aData, i, 0); else oTable.fnUpdate( oSettings.aoData[i+1]._aData, i, 0); i++; }); } </code></pre> <hr> <p>thanks for your time , this is what i tried so far :</p> <pre><code> oTable = $('#userTable', context).dataTable({ "sAjaxSource":'/ajax/getdata/', "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { "dataType": 'json', "type": "POST", "url": sSource, "data": params, "success" : function(data){ fnCallback(data); fnSortBySelected(); } } ); } }); var fnSortBySelected = function() { var oSettings = oTable.fnSettings(); var i = 0; $('td:first-child input[type=checkbox]',oTable).sort(function(a, b){ if(a.checked) oTable.fnUpdate( oSettings.aoData[i]._aData, i, 0); else oTable.fnUpdate( oSettings.aoData[i+1]._aData, i, 0); i++; } ); } </code></pre>
36,001,963
0
<p>Partitionkey and Rowkey are just two properties of entitis in Azure table. Rowkey is the "primary key" within one partition. Within one PartitionKey, you can only have unique RowKeys. If you use multiple partitions, the same RowKey can be reused in every partition. PartitionKey + RowKey form the unique identifier(Primary key) for an entity. </p> <p>In your table, the partitionkey and rowkey are just assigned with a random string. I'm not sure whether you designed this table or somebody else, but these two properties can be assigned with other values through <a href="https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-tables/" rel="nofollow">Azure Storage .NET client libary</a> and <a href="https://msdn.microsoft.com/en-us/library/azure/dd179433.aspx" rel="nofollow">Rest API</a>. As the example below, you can design the rowkey and partitionkey, and assign whatever valid value you want, here lastname for Partitionkey and firstname for rowkey:</p> <pre><code>public class CustomerEntity : TableEntity { public CustomerEntity(string lastName, string firstName) { this.PartitionKey = lastName; this.RowKey = firstName; } public CustomerEntity() { } public string Email { get; set; } public string PhoneNumber { get; set; } </code></pre> <p>}</p> <p>It’s better to think about both properties and your partitioning strategy. Don’t just assign them a guid or a random string as it does matter for performance. I recommend you go through <a href="https://msdn.microsoft.com/en-us/library/hh508997.aspx" rel="nofollow">Designing a Scalable Partitioning Strategy for Azure Table Storage</a>, the most commom used is Range Partitions, but you can choose whatever you want.</p> <p>This is a great blog help you understand how partitionkey and rowkey work <a href="http://blog.maartenballiauw.be/post/2012/10/08/What-PartitionKey-and-RowKey-are-for-in-Windows-Azure-Table-Storage.aspx" rel="nofollow">http://blog.maartenballiauw.be/post/2012/10/08/What-PartitionKey-and-RowKey-are-for-in-Windows-Azure-Table-Storage.aspx</a></p>
16,875,368
0
<p>This is a good use case for <em>promises</em>. </p> <p>They work like this (example using jQuery promises, but there are other APIs for promises if you don't want to use jQuery):</p> <pre><code>function doCallToGoogle() { var defer = $.Deferred(); callToGoogleServicesThatTakesLong({callback: function(data) { defer.resolve(data); }}); return defer.promise(); } /* ... */ var responsePromise = doCallToGoogle(); /* later in your code, when you need to wait for the result */ responsePromise.done(function (data) { /* do something with the response */ }); </code></pre> <p>The good thing is that you can chain promises:</p> <pre><code>var newPathPromise = previousPathPromise.then( function (previousPath) { /* build new path */ }); </code></pre> <p>Take a look to: </p> <ul> <li><a href="http://documentup.com/kriskowal/q/" rel="nofollow">http://documentup.com/kriskowal/q/</a></li> <li><a href="http://api.jquery.com/promise/" rel="nofollow">http://api.jquery.com/promise/</a></li> </ul> <p>To summarize promises are an object abstraction over the use of callbacks, that are very useful for control flow (chaining, waiting for all the callbacks, avoid lots of callback nesting).</p>
1,340,401
0
<p>You can't with most SSH clients. You can work around it with by using SSH API's, like <a href="http://www.lag.net/paramiko/" rel="nofollow noreferrer">Paramiko</a> for Python. Be careful not to overrule all security policies.</p>
18,041,981
0
<p>Well the error is quite logical</p> <pre><code>if command == "iam": self.name = content msg = self.name + "has joined" elif command == "msg": msg = self.name + ": " + content print msg </code></pre> <p>In the first if clause you assign a value to self.name which may either rely on assumption that self.name exists somewhere, or on assumption that it is new and needs to be declared, but in elif you seem to assume with certainty that self.name already exists, it turns out it doesn't so you get an error.</p> <p>I guess your safest option consists of simply adding self.name at the beginning of dataReceived method:</p> <pre><code>def dataReceived(self, data): self.name = "" </code></pre> <p>this will get rid of the error. As an alternative you could also add self.name to init method of IphoneChat.If you need self.name in other functions not only in dataReceived then adding init with self.name is the way to go, but from your code it seems you only need it in datareceived so just add it there. Adding self.name in init would look like this:</p> <pre><code>class IphoneChat(Protocol): def __init__(self): self.name = "" </code></pre> <p>or you can also simply do </p> <pre><code>class IphoneChat(Protocol): name = "" </code></pre> <p>and then go on with name instead of self.name. </p>
6,713,460
0
<p>To avoid string processing, lambdas are a good solution as in the answer by Johannes Schaub. If your compiler doesn't support lambdas yet then you could do it like this with no C++0x features and no macroes:</p> <pre><code>doTrace(LEVEL_INFO, some_props) &lt;&lt; "Value of i is " &lt;&lt; i; </code></pre> <p>doTrace would return a temporary object with a virtual operator&lt;&lt;. If no tracing is to be performed, then return an object whose operator&lt;&lt; does nothing. Otherwise return an object whose operator&lt;&lt; does what you want. The destructor of the temporary object can signal that the string being outputted is done. Now destructors shouldn't throw, so if the final processing of the trace event can throw an exception, then you may need to include an end-of-event overload of operator&lt;&lt;</p> <p>This solution causes several virtual function calls even when no tracing is done, so it is less efficient than "if(tracing) ...". That should only really matter in performance critical loops where you probably want to avoid doing tracing anyway. In any case you could revert to checking tracing with an if in those cases or when the logic for doing the tracing is more complicated than comfortably fits in a sequence of &lt;&lt;'s.</p>
29,016,131
0
SVG: Why <p> element is not displaying in <foreignobject> <p>I'm attempting to put a <code>&lt;p&gt;</code> element inside a <code>&lt;foreignobject&gt;</code> inside an <code>&lt;svg&gt;</code> node in chrome but I am not seeing the text. I have inspected the element and the DOM model shows the structure I expect. I created this <a href="http://jsfiddle.net/ujzL8yyr/" rel="nofollow">jsfiddle</a> by copying from the DOM model and lo and behold it works exactly as I desire in the fiddle.</p> <p>After scratching my head for a bit I started looking at the properties in the two tabs (both in Chrome) and the only 2 things at this point that jump out me are that when I hover over the <code>&lt;foreignobject&gt;</code> or <code>&lt;p&gt;</code> element in the fiddle, it shows a grey box the area where it's displayed. When I do this in the real application, it does the same for the <code>&lt;foreignobject&gt;</code> but I see nothing for the <code>&lt;p&gt;</code> element. The second difference is that in the fiddle, the <code>&lt;p&gt;</code> element shows a height and a width of 54px and 100px (respectively) but in the actual application they both are reported to be 'auto'.</p> <p>As an experiment, I attempted to set the height and width explicitly in the CSS for 'p' but chrome just shows this as an 'invalid property'.</p> <p>Assuming this is the problem, I'm a little lost as to how to control a property that I'm not allowed to specify. Can someone help with some advice on how to debug this further? There's clearly something about what I am doing that is causing this but I'm not sure where to look next.</p> <p>EDIT:</p> <p>I don't know why I didn't notice this before but I see a difference that may help explain this. The fiddle shows the properties for the <code>&lt;p&gt;</code> element as:</p> <ul> <li>p.description</li> <li>HTMLParagraphElement</li> <li>HTMLElement</li> <li>Node</li> <li>EventTarget</li> <li>Object</li> </ul> <p>The application shows these properties:</p> <ul> <li>p</li> <li>SVGElement</li> <li>Element</li> <li>Node</li> <li>EventTarget</li> <li>Object</li> </ul> <p>I assume this has something to do with how d3 is adding the <code>&lt;p&gt;</code> element. I will try to create a fiddle that creates the elements with d3.</p>
35,480,331
0
How run async method multiple times in separate threads? <p>I am newbie in using of await/async and windows phone 8.1 programming. I need to run async method simulateously in more than one thread. May be four, because my phone has four cores. But i cannot figure it out :-(</p> <p>This is example of my async method.</p> <pre><code>public async Task GetFilesAsyncExample(StorageFolder root) { IReadOnlyList&lt;StorageFolder&gt; folders = await root.GetFoldersAsync(); //DO SOME WORK WITH FOLDERS// } </code></pre> <p>Four threads can be ensured by using of a semaphore object, but how i can run it in simulatously running threads?</p> <p><strong>EDIT:</strong> This is my code which explores folder structure and log metadata about files into database. I want to speed up execution of this code by calling method "async LogFilesFromFolderToDB(StorageFolder folder)" simulateously in separate thread for each folder.</p> <pre><code> Stack&lt;StorageFolder&gt; foldersStack = new Stack&lt;StorageFolder&gt;(); foldersStack.Push(root); while (foldersStack.Count &gt; 0) { StorageFolder currentFolder = foldersStack.Pop(); await LogFilesFromFolderToDB(null, currentFolder);// Every call of this method can be done in a separate thread. IReadOnlyList&lt;StorageFolder&gt; folders = await currentFolder.GetFoldersAsync(); for (int i = 0; i &lt; folders.Count; i++) foldersStack.Push(folders[i]); } </code></pre> <p>Method: async LogFilesFromFolderToDB(StorageFolder folder) looks like:</p> <pre><code> async Task LogFilesFromFolderToDB(StorageFolder folder) { IReadOnlyList&lt;StorageFile&gt; files = await folder.GetFilesAsync(); //SOME ANOTHER CODE// } </code></pre>
7,100,174
0
<p>You'll need to subclass <code>UITableViewCell</code> and override <code>-layoutSubviews</code>. When the cell's editing bit is set to YES, <code>-layoutSubviews</code> will automatically be invoked. Any changes made within <code>-layoutSubviews</code> are automatically animated.</p> <p>Consider this example</p> <pre><code>- (void)layoutSubviews { [super layoutSubviews]; CGFloat xPosition = 20.0f; // Default text position if (self.editing) xPosition = 40.0f; CGRect textLabelFrame = self.textLabel.frame; textLabelFrame.origin.x = xPosition; self.textLabel.frame = textLabelFrame; } </code></pre>
1,794,705
0
<p>Seems like it would make more sense to compute the parameters within if/else or switch logic, store them in variables, and then call the function afterwords with whatever parameters you computed.</p>
30,177,008
0
<p>You should check out the update <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/" rel="nofollow">Hello Analytics API</a> docs. That way you only need to use the <a href="https://github.com/google/google-api-php-client" rel="nofollow">Google APIs Client Library</a> for PHP and not any third party tool.</p>
22,445,670
0
Save and restore elscreen tabs and split frames <p>I have many elscreen tabs(frames?) that are horizontally and vertically split. I'd like to be able to save the current buffers, windows layout in each frame, and the frames themselves.</p> <p>In short, I'd like to be able to close emacs and re-open with relatively the same state as when I closed it.</p> <p>(I think I got the terminology right)</p>
36,693,872
0
How to count households from each postcode in the database <p>I made an er diagram for a business and based on which I need to run a query for counting household from each postcode. </p> <pre><code>SELECT CU.POSTCODE, Count(CU.CUSTOMER_ID) AS HOUSEHOLDS_PER_POSTCODE FROM CUSTOMER AS CU INNER JOIN HOUSEHOLD AS HHD ON CU.CUSTOMER_ID = HHD.CUSTOMER_ID GROUP BY CU.POSTCODE; </code></pre> <p>Is this a good way? </p>
34,643,390
0
<p>You can find the value of the exponent using <code>log10</code>:</p> <pre><code>testVector = [3.5688e+10 3.1110e+10 5.2349e+10]; lowExp = min(floor(log10(testVector))); eVal = 10^lowExp; </code></pre> <p>Result:</p> <pre><code>eVal = 1.0000e+10 </code></pre> <p>Then you'll need to divide your original vector by <code>eVal</code>:</p> <pre><code>newTestV = testVector/eVal newTestV = 3.5688 3.1110 5.2349 </code></pre>
25,168,877
0
<p>The answer may also lie in eval.points. Researching more it looks like you can enter your own points here, so you can potentially enter the points used to build the kde or an entirely new set of points.</p>
5,598,274
0
View drawn under status bar <p>So i managed to load another view when someone presses a button ,but it loads it to high. `i don't know why this happens. The difference is exactly the top bar hight. This is my code: In the delegate i have:</p> <pre><code>- (void)flipToAbout { AboutViewController *aaboutView = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil]; [self setAboutController:aaboutView]; [aaboutView release]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; [homeController.view removeFromSuperview]; [self.window addSubview:[aboutController view]]; [UIView commitAnimations];} </code></pre> <p>In the about view i didn't change anything.Please tell me what is the problemm .Thanks.</p>
36,413,627
0
<p>The issue was the Class assignment that was with the Search Icon. After removing the line <code>class: col-mw-3</code> it ran fine, and in all of the browsers. Also make sure nothing is covering the <code>&lt;a&gt;</code> Tag as well!</p>
11,968,811
0
<p>To go from an DateTime in the "Excel Format" to a C# Date Time you can use the <a href="http://msdn.microsoft.com/en-us/library/system.datetime.fromoadate.aspx">DateTime.FromOADate</a> function.</p> <p>In your example above:</p> <pre><code> DateTime myDate = DateTime.FromOADate(41172); </code></pre> <p>To write it out for display in the desired format, use:</p> <pre><code> myDate.ToString("dd/MM/yyyy"); </code></pre> <p>If you are wondering where the discrepancies in Excel's date handling come from, it's supposed to be on purpose:</p> <blockquote> <p>When Lotus 1-2-3 was first released, the program assumed that the year 1900 was a leap year even though it actually was not a leap year. This made it easier for the program to handle leap years and caused no harm to almost all date calculations in Lotus 1-2-3.</p> <p>When Microsoft Multiplan and Microsoft Excel were released, they also assumed that 1900 was a leap year. This allowed Microsoft Multiplan and Microsoft Excel to use the same serial date system used by Lotus 1-2-3 and provide greater compatibility with Lotus 1-2-3. Treating 1900 as a leap year also made it easier for users to move worksheets from one program to the other.</p> <p>Although it is technically possible to correct this behavior so that current versions of Microsoft Excel do not assume that 1900 is a leap year, the disadvantages of doing so outweigh the advantages.</p> </blockquote> <p>Source: <a href="http://www.ozgrid.com/Excel/ExcelDateandTimes.htm">http://www.ozgrid.com/Excel/ExcelDateandTimes.htm</a></p>
10,187,851
0
What gets send to the server with request factory <p>I have problem to understand what does Request factory send to server. I have a method </p> <pre><code>Request&lt;NodeProxy&gt; persist(NodeProxy node) </code></pre> <p>NodeProxy is an Object from tree like structure (has child nodes and one parent node, all of type NodeProxy). I'v change only one attribute in the node and called persists. </p> <p>The question now is what gets send to the server? In the dock here <a href="https://developers.google.com/web-toolkit/doc/latest/DevGuideRequestFactory" rel="nofollow">https://developers.google.com/web-toolkit/doc/latest/DevGuideRequestFactory</a> there is: <br>"On the client side, RequestFactory keeps track of objects that have been modified and sends only changes to the server, which results in very lightweight network payloads."</p> <p>In the same dock, in the chapter Entity Relationships, there is also this: <br>"RequestFactory automatically sends the whole object graph in a single request." </p> <p>And I'm wondering how should I understand this. </p> <p>My problem: My tree structure can get quete big, lets say 50 nodes. The problem is that for update of one attribute the method </p> <pre><code>public IEntity find(Class&lt;? extends IEntity&gt; clazz, String id) </code></pre> <p>in the class</p> <pre><code>public class BaseEntityLocator extends Locator&lt;IEntity, String&gt; </code></pre> <p>gets called for each object in the graph which is not acceptable. </p> <p>Thank you in advance.</p>
7,013,326
0
Firefox maximize doesn't trigger resize Event <p>I try to catch resize events with jquery and the </p> <pre><code>$(window).resize(function() { } </code></pre> <p>Everything works fine, except when I use the maximize Button in Firefox, the event is not thrown.</p> <p>Is there something wrong here?</p>
1,866,475
0
Table footer view buttons <p>I have some signup form that had email and login text fields as table cells and signup button as button in footer view. That all functioned superb, here is the code</p> <pre><code>frame = CGRectMake(boundsX+85, 100, 150, 60); UIButton *signInButton = [[UIButton alloc] initWithFrame:frame]; [signInButton setImage:[UIImage imageNamed:@"button_signin.png"] forState:UIControlStateNormal]; [signInButton addTarget:self action:@selector(LoginAction) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.hidesBackButton = TRUE; self.tableView.tableFooterView.userInteractionEnabled = YES; self.tableView.tableFooterView = signInButton; self.view.backgroundColor = [UIColor blackColor]; </code></pre> <p>My question is how to add another button next to this one. </p> <p>By using [self.tableView.tableFooterView addSubview:...] buttons are not shown and if I use some other UIView, place buttons there and then say that the footerView is that UIView, I see the buttons, but am unable to press them.</p> <p>I hope that this isn't too confusing and that you understand my problem.</p>
7,207,858
0
php max function to get name of highest value? <p>I have a multi array and I am using the max function to return the highest value, however I'd like it to return the name? How can I do that?</p> <pre><code>$total = array($total_one =&gt; 'Total One', $total_two =&gt; 'Total Two'); echo max(array_keys($total)); </code></pre> <p>Thanks!!</p>
9,577,115
0
NoodleLineNumberView, the numbers are not aligned properly, not sure whats wrong <p>I'm trying to add line numbers using <a href="https://github.com/MrNoodle/NoodleKit" rel="nofollow noreferrer">NoodleLineNumberView</a>. The issue I'm having is that the line numbers dont line up properly with thier line number.I have to type 16 lines, then line 1 gets marked as line 16. If I scroll down past the top of the text I can see the other line numbers there, its just like all over the are shifted up.</p> <p>I subclassed a <code>NSScrollView</code> and added this bit of code. Thats all that should be needed. Is anyone else having this issue, or solved it?</p> <pre><code>- (void)awakeFromNib { self.gutter = [[NoodleLineNumberView alloc] initWithScrollView:self]; [self setVerticalRulerView:self.gutter]; [self setHasHorizontalRuler:NO]; [self setHasVerticalRuler:YES]; [self setRulersVisible:YES]; } </code></pre> <p><img src="https://i.stack.imgur.com/DVuuX.png" alt="Error"></p>
34,375,310
0
how to assign query to GridItem in SearchView? <p>I am trying to create a SearchView that searches for GridItems that each launch a specific second activity. However I cannot figure out the code that will help me with this. I have already set an onQueryTextChangeListener for the SearchView which should allow me to show results manually and whilst typing. Here's what I want to happen:</p> <p>When I type a specific query, let's say "car", I want to show the GridItem (which is just a clickable ImageView) of a car to the user. When I type "Camera", I want to show the user my GridItem with the image of a Camera on it.</p> <p>I also want to display results to the user whilst typing, so when I have only typed "c" yet, I want to show the user both the "car" and "Camera" GridItems. I want to stay in the same activity, so I need some sort of way to delete all GridItems except for the ones with a camera or a car picture on it depending on what the user typed, I don't want to launch a search activity.</p> <p>Now what makes this just a little harder is that I configured my BaseAdapter in a separate class, which means that I have to indirectly mention the GridItems in some way. Here's what I've done so far:</p> <pre><code> @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); final MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (query.equals(R.string.Coconut)){ //here I need some code that will tell the system that I want to show the GridItem with a picture of a coconut on it } return false; } @Override public boolean onQueryTextChange(String newText) { return false; } </code></pre> <p>This is the separate class that initialises the Images in the GridView:</p> <pre><code>class SingleItem{ int image; double nutritional_value; SingleItem(int image, double nutritional_value){ this.image = image; this.nutritional_value = nutritional_value; } } public class objectAdapter extends BaseAdapter { ArrayList&lt;SingleItem&gt; list; Context context; Bundle myBundle; objectAdapter(Context context) { this.context = context; myBundle = new Bundle(); double[][] nutritional_value = { {89, 22.8, 0.3, 1}, {61, 1.5, 0.5, 1.1}, {375, 6.8, 0.6, 1.2}, {767, 0, 9.3, 0}, {580, 9.1, 42, 36.5} }; myBundle.putSerializable("array_array", nutritional_value); int[] image_id = { R.drawable.Bananas, R.drawable.Kiwis, R.drawable.oatmeals, R.drawable.coconuts, R.drawable.dark_chocolate }; for (int i = 0; i &lt; image_id.length; i++) { SingleItem tempSingleItem = new SingleItem(image_id[i], nutritional_value[i][i]); list.add(tempSingleItem); } } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; ViewHolder holder = null; if (row == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.single_item, parent, false); holder= new ViewHolder(row); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } SingleItem temp = list.get(position); holder.myItem.setImageResource(temp.image); holder.myItem.setTag(temp); return row; } @Override public long getItemId(int position) { return position; } class ViewHolder { ImageView myItem; ViewHolder(View v){ myItem = (ImageView) v.findViewById(R.id.imageView2); } } @Override public Object getItem(int position) { return list.get(position); } @Override public int getCount() { return list.size(); } } </code></pre> <p>Thanks in advance!</p> <p>Vidal</p>
24,690,672
0
<p>You can use <a href="https://docs.python.org/3.4/library/functions.html#input" rel="nofollow"><code>input</code></a> to accept a string from the user. As you'll have two co-ordinates to punch in, perhaps call this twice. Once you get the strings, cast the locations to integer via <code>int()</code>.</p> <p>If you want to generate random locations, you can use <a href="https://docs.python.org/3.4/library/random.html#random.randrange" rel="nofollow"><code>random.randrange()</code></a>. The syntax for <code>random.randrange()</code> is like so:</p> <pre><code>num = random.randrange(start, stop) #OR num = random.randrange(start, stop, step) </code></pre> <p>This will randomly generate a number from <code>start</code> to <code>stop</code> excluding <code>stop</code> itself. This is pretty much the same as with <code>range()</code>. The first method assumes a step size of 1, while the second method you can specify an optional third parameter which specifies the step size of your random integer generation. For example, if <code>start = 2</code>, <code>stop = 12</code> and <code>step = 2</code>, this would randomly generate a integer from the set of <code>[2, 4, 6, 8, 10]</code>.</p>
30,462,181
0
Webpack: Module build failed with jade-loader <p>This is likely a config issue, but I'm new to Webpack and haven't been able to figure it out after a few days. I'd appreciate some help! </p> <p><strong>Packages</strong></p> <ul> <li>webpack 1.9.8 </li> <li>jade-loader 0.7.1 </li> <li>jade 1.9.2 </li> </ul> <p><strong>webpack.config.js</strong></p> <pre><code>var webpack = require('webpack'); var path = require('path'); module.exports = { // ... resolve: { extensions: ["", ".webpack.js", ".web.js", ".json", ".js", ".jade" ], root: [ path.join(__dirname, 'src/js'), path.join(__dirname, 'node_modules') ], modulesDirectories: ['node_modules'], }, module: { loaders: [ { test: /\.json$/, loader: "json-loader" }, { test: /modernizr/, loader: "imports?this=&gt;window!exports?window.Modernizr" }, { text: /\.jade$/, loader: "jade-loader" } ] } // ... }; </code></pre> <p>With a completely empty entry file, I get the following error when trying to run webpack.</p> <pre><code>ERROR in ./~/jade/lib/runtime.js Module build failed: Error: unexpected token "indent" at MyParser.Parser.parseExpr (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:252:15) at MyParser.Parser.parse (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:122:25) at parse (/Users/name/project/code/assets/node_modules/jade/lib/index.js:104:21) at Object.exports.compileClientWithDependenciesTracked (/Users/name/project/code/assets/node_modules/jade/lib/index.js:256:16) at Object.exports.compileClient (/Users/name/project/code/assets/node_modules/jade/lib/index.js:289:18) at run (/Users/name/project/code/assets/node_modules/jade-loader/index.js:170:24) at Object.module.exports (/Users/name/project/code/assets/node_modules/jade-loader/index.js:167:2) @ ./entry.js 1:11-85 </code></pre> <p>If I actually require a jade file within entry.js, I get a different error:</p> <pre><code>ERROR in ./entry.js Module build failed: Error: unexpected text ; var at Object.Lexer.fail (/Users/name/project/code/assets/node_modules/jade/lib/lexer.js:871:11) at Object.Lexer.next (/Users/name/project/code/assets/node_modules/jade/lib/lexer.js:930:15) at Object.Lexer.lookahead (/Users/name/project/code/assets/node_modules/jade/lib/lexer.js:113:46) at MyParser.Parser.lookahead (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:102:23) at MyParser.Parser.peek (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:79:17) at MyParser.Parser.tag (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:752:22) at MyParser.Parser.parseTag (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:738:17) at MyParser.Parser.parseExpr (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:211:21) at MyParser.Parser.parse (/Users/name/project/code/assets/node_modules/jade/lib/parser.js:122:25) at parse (/Users/name/project/code/assets/node_modules/jade/lib/index.js:104:21) </code></pre> <p>However, if I comment out the jade loader line in <code>webpack.config.js</code> and require the jade file with the inline syntax <code>require('jade!template.jade')</code> -- everything works okay.</p> <p>Any idea what's up?</p>
35,630,788
0
<p>I will explain how solved this problem. </p> <p>First of all the refresh token process is critical process. In my application and most of applications doing this : If refresh token fails logout current user and warn user to login .(Maybe you can retry refresh token process by 2-3-4 times by depending you)</p> <p>I recreated my refresh token using <code>HttpUrlConnection</code> which simplest connection method. No cache , no retries , only try connection and get answer .</p> <p>So this is my new refresh token process :</p> <p>My refresh method:</p> <pre><code>public boolean refreshToken(String url,String refresh,String cid,String csecret) throws IOException { URL refreshUrl=new URL(url+"token"); HttpURLConnection urlConnection = (HttpURLConnection) refreshUrl.openConnection(); urlConnection.setDoInput(true); urlConnection.setRequestMethod("POST"); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); urlConnection.setUseCaches(false); String urlParameters = "grant_type=refresh_token&amp;client_id="+cid+"&amp;client_secret="+csecret+"&amp;refresh_token="+refresh; // Send post request urlConnection.setDoOutput(true); DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream()); wr.writeBytes(urlParameters); wr.flush(); wr.close(); int responseCode = urlConnection.getResponseCode(); Log.v("refresh http url","Post parameters : " + urlParameters); Log.v("refresh http url","Response Code : " + responseCode); BufferedReader in = new BufferedReader( new InputStreamReader(urlConnection.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // handle response like retrofit, put response to POJO class by using Gson // you can find RefreshTokenResult class in my question Gson gson = new Gson(); RefreshTokenResult refreshTokenResult=gson.fromJson(response.toString(),RefreshTokenResult.class); if(responseCode==200) { //handle new token ... return true; } //cannot refresh Log.v("refreshtoken", "cannot refresh , response code : "+responseCode); return false; } </code></pre> <p>In authenticate method :</p> <pre><code>@Override public Request authenticate(Route route, Response response) throws IOException { String userRefreshToken="your refresh token"; String cid="your client id"; String csecret="your client secret"; String baseUrl="your base url" refreshResult=refreshToken(baseUrl,userRefreshToken,cid,csecret); if (refreshResult) { //refresh is successful String newaccess="your new access"; return response.request().newBuilder() .header("Authorization", newaccess) .build(); } else { //refresh failed , maybe you can logout user return null; } } </code></pre>
38,564,716
0
<p>Maybe this - JOIN instead of subselect:</p> <pre><code>SELECT t1.week_val, CASE t1.week_val WHEN 1 THEN t2.hour_val ELSE t1.hour_val END AS hour_val FROM table_name t1 LEFT JOIN table_name t2 ON t2.week_val = t1.week_val + 1 </code></pre>
6,177,796
0
<p>There are chances that the first solution is faster.</p> <p>A very nice article :</p> <p><a href="http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/" rel="nofollow">http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/</a></p>
41,035,210
0
AnimationDrawable animation on KeyboardView.Key android <p>I want to play animation on a key on custom keyboard. I've created the custom keyboard and everything is working fine, except the animation which is kind of popping up of key. I'm accomplishing it through AnimationDrawable. When <code>animation.start()</code> is called, only the first frame of animation is shown and it stucks there. Below is my simple code for animation. </p> <pre><code>enterKey.icon = ContextCompat.getDrawable(getActivity(), R.drawable.enter_button_animation); AnimationDrawable drawable = (AnimationDrawable) enterKey.icon; drawable.start(); mKeyboardView.invalidateAllKeys(); </code></pre> <p>Now I want to know how can I get the exact view handle of any key or why this animation is not working. <code>KeyboardView.Key.icon</code> is just a drawable. Given is my <code>enter_button_animation.xml</code>:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/selected" android:oneshot="false" &gt; &lt;item android:drawable="@drawable/enter_key_1" android:duration="50" /&gt; &lt;item android:drawable="@drawable/enter_key_2" android:duration="50" /&gt; &lt;item android:drawable="@drawable/enter_key_3" android:duration="50" /&gt; &lt;item android:drawable="@drawable/enter_key_4" android:duration="50" /&gt; &lt;/animation-list&gt; </code></pre> <p>Thanks in advance. </p>
29,093,286
0
<p>You can do something like:</p> <pre><code>$("#grid").kendoGrid({ dataSource: { type: "json", pageSize: 10, serverPaging: true, transport: { read: "http://whatever" } }, selectable: "cell", pageable: true, columns: ["ProductID", "ProductName"], change: function() { var dataItem = this.dataSource.view()[this.select().closest("tr").index()]; alert(dataItem.UnitPrice); } } </code></pre>
21,132,192
0
Outputting file contents as UTF-8 leads to character encoding issues <p>I set my header as follows:</p> <pre><code>header( 'Content-Type: text/html; charset="utf-8"' ); </code></pre> <p>and then output a local file on my server to the browser using the following code-segment:</p> <pre><code>$content = file_get_contents($sPath); $content = mb_convert_encoding($content, 'UTF-8'); echo $content; </code></pre> <p>The files I have on the server are created by lua and thus, the output of the following is <code>FALSE</code> (before conversion):</p> <pre><code>var_dump( mb_detect_encoding($content) ); </code></pre> <p>The files contain some characters like <code>™</code> (<code>&amp;trade;</code>) etc. and these appear as plain square boxes in browsers. I've read the following threads which were suggested as similar questions and none of the variations in my code helped:</p> <ul> <li><a href="http://stackoverflow.com/q/17709888/1190388">PHP File Get Contents &amp; String Encoding</a> (No gzip in my case, the files are plain <code>.txt</code>s)</li> <li><a href="http://stackoverflow.com/q/2236668/1190388">file_get_contents() Breaks Up UTF-8 Characters</a> (Tried first two top-rated solutions, neither worked. The third one isn't applicable for my case)</li> <li><a href="http://stackoverflow.com/q/5600371/1190388">file_get_contents() converts UTF-8 to ISO-8859-1</a> (No stream is there to provide as context)</li> </ul> <p>There seem to be no problems when I simply use the following:</p> <pre><code>header( 'Content-Type: text/html; charset="iso-8859-1"' ); // setting path here $content = file_get_contents($sPath); echo $content; </code></pre>
6,786,715
0
<pre><code>&lt;Button&gt; &lt;Button.Background&gt; &lt;ImageBrush Source="/AlarmClock;component/Images/page_preview.png" /&gt; &lt;/Button.Background&gt; &lt;/Button&gt; </code></pre> <p>just make sure the file is maked as "Resource" in visual studio. Alternatively you can mark it as "Content" and use it like this:</p> <pre><code> &lt;ImageBrush Source="/Images/page_preview.png" /&gt; </code></pre> <p>I don't know if you need to assign the background programatically (because you can do it in markup), but if you do here is what you need to say:</p> <pre><code>viewButton.Background = new ImageBrush { Source = new BitmapImage(new Uri("", UriKind.Relative)) } </code></pre> <p>[FURTHER]</p> <p>in order set margin programmatically:</p> <pre><code>viewButton.Margin = new Thickness(left, top, right, bottom); </code></pre>
12,165,682
1
yield with recursive function in python <p>I am trying to create a generator for permutation purpose.I know there are other ways to do that in python.But this is for somthing else. But I am not able to yield the values .Can you help?</p> <pre><code>def perm(s,p=0,ii=0): l=len(s) s=list(s) if(l==1): print ''.join(s) elif((l-p)==2): yield ''.join(s) yield ''.join([''.join(s[:-2]),s[-1],s[-2]]) #print ''.join(s) #print ''.join([''.join(s[:-2]),s[-1],s[-2]]) else: for i in range(p,l): tmp=s[p] s[p]=s[i] s[i]=tmp perm(s,p+1,ii) </code></pre>
27,428,019
0
Report PHP / MySQL <p>I apologize in advance for my bad English level.</p> <p>I explain my problem ... I try to create a web interface that would handle the number of times that the employees will eat in the canteen ...</p> <p>Everything works fine but I would get a report of the number of times employees. and that I hang. In fact I have a table called "Transactions" and understand the "Transaction ID", "Surname", "Name", "Date_transaction" and "_transaction time"</p> <p>How could I do to get a report in php / mysql? By selecting a specific month?</p> <p>Thank you in advance for your answers.</p> <p>greetings,</p> <p>Ljebool</p>
33,032,934
0
<p>I've noticed this happens with Redshift/Flyway if the schema or table name contains characters in mixed case.</p> <p>Try to configure an all-lower-case metadata table name instead, like <code>test_schema.db_schema_ver</code>, for example.</p>
7,784,436
0
<p>First, your code does not have any effect. Hash table "breaks" the order. The order of elements in hash table depends on the particular hash implementation. </p> <p>There are 2 types of Maps in JDK: HashMap and SortedMap (typically we use its implementation TreeMap). BTW do not use Hashtable: this is old, synchronized and almost obsolete implementation). </p> <p>When you are using HashMap (and Hashtable) the order of keys is unpredictable: it depends on implementation of <code>hashCode()</code> method of class you are using as keys of your map. If you are using TreeMap you can use Comparator to change this logic. </p> <p>If you wish your keys to be extracted in the same order you put them use <code>LinkedHashMap</code>.</p>
30,508,156
0
Multiple multiple linear regression <p>I have 40 SNPs and want to see the effect each individual SNP has on the age of menopause. To do this I need do a multiple linear regression each of the individual SNPs. I want to avoid typing the same command 40 different times (as in the future I'll be doing this with even more SNPs).</p> <p>What I want to do is make a list of the SNPs in a <code>csv</code> file and call this <code>x</code>:</p> <pre><code>x &lt;- read.csv("snps.csv") </code></pre> <p>Then I want to use this list in this command;</p> <pre><code>fit &lt;- lm(a_menopause ~ "snps" + country, data=mydata) </code></pre> <p>Where <code>snps</code> is my list of the SNPs I need to analyse, but needs to be done one SNP at a time. I'd ideally like to print the results to a <code>csv</code> file.</p>
38,134,727
0
How to animate RecyclerView height before items are shown <p>How can I, or should I say when can I animate recyclerView height before items are shown ? I can get the final height in onMeasure but the items always appear too fast and the animation doesn't work.</p> <p>Any idea on how I could get this animation to work ?</p>
20,252,938
0
<p>I am using <code>BackgroundWorker</code> a lot and can tell that <code>RunWorkerCompleted</code> event is <strong>definitely</strong> ran in UI thread. Also, you can pass the <code>DoWork</code> result to according eventArgs field and then, in <code>RunWorkerCompleted</code> take it from eventArgs to perform some UI-dependent operations with it, as mentioned <a href="http://stackoverflow.com/questions/939635/how-to-make-backgroundworker-return-an-object">here</a></p>