pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
11,312,129
0
Getting a Date with "ShortenedMonth/dd" format <p>Is there a way I can get a date by the format "MM/dd" but instead of the month being an <code>int</code>, it is a shortened <code>string</code> like "Jan 30"?</p> <p>Currently I did this with Java by a simple <code>Switch Case</code>, but I want to know if this is already contained in a <code>DateFormat</code> or something similar.</p> <p>Anyway I leave here my current code. I used <code>R.string</code> because my application has multi-language support.</p> <pre><code>public void setShortMonth(){ final Calendar calendar = Calendar.getInstance(); int Month = calendar.get(Calendar.MONTH); String ShortMonth = " "; switch (Month){ case 0: ShortMonth = getString(R.string.Jan); break; case 1: ShortMonth = getString(R.string.Fev); break; case 2: ShortMonth = getString(R.string.Mar); break; case 3: ShortMonth = getString(R.string.Apr); break; case 4: ShortMonth = getString(R.string.May); break; case 5: ShortMonth = getString(R.string.Jun); break; case 6: ShortMonth = getString(R.string.Jul); break; case 7: ShortMonth = getString(R.string.Aug); break; case 8: ShortMonth = getString(R.string.Sep); break; case 9: ShortMonth = getString(R.string.Oct); break; case 10: ShortMonth = getString(R.string.Nov); break; case 11: ShortMonth = getString(R.string.Dec); break; } TextView datetxt = (TextView) findViewById(R.id.home_date); datetxt.setText(ShortMonth + " " + Day); } </code></pre>
23,142,153
0
How to use @Html.PartialView("XXX") in Jquery function? <p>I have a function that updates a div with raw HTML. However, the raw HTML is in another .CSHTML document.</p> <p>My function is:</p> <pre><code>function Demo(){ $('#ContainerDiv').html('@Html.Partial("MyPartialView")'); } </code></pre> <p>For some reason, whenever I include my partial view within the function, my console shows that it is unable to locate the document.</p> <p>As soon as I remove the @Html.PartialView("MyPartialView") and include it in the body of the document, it loads fine.</p> <p>Any ideas on why this would not be working, or a better way of doing this?</p> <p>Thanks, Mark</p>
33,036,578
1
Not sure what is wrong with my code (Tkinter BEGINNER) <p>I'm making a pretty simple GUI and each frame should have a Continue and Exit button. I need the continue button to open a new frame with writing, widgets...etc on it. </p> <p>The first frame (<code>frame1</code>) works when I call the <code>frame_2</code> function.<br> But from this I do not know how to open a <code>frame_3</code> and destroy <code>frame 2</code> properly.</p> <p>Here is the code so far:</p> <pre><code>import tkinter from tkinter.constants import * tk = tkinter.Tk() def frame_2(): #ENTERING AGE frame1.grid_forget() frame1.destroy() frame2 = tkinter.Frame(tk, borderwidth=2,) frame2.pack(fill=BOTH,expand=1,pady=50,padx=80) need_info = tkinter.Label(frame2, text="I need some information first...") need_info.grid(row=0, column=0) #displays text at top of frame enter_age = tkinter.Label(frame2, text="Please enter your age!") enter_age.grid(row=2, column=0) #displays second line of text age = tkinter.Entry(frame2, width=10) age.grid(row=3, column=0) nextpage = tkinter.Button(frame2,text="Continue",command=frame2.destroy) nextpage.grid(row=10, column=0) exitapp = tkinter.Button(frame2,text="Exit",command=tk.destroy) #exits programme exitapp.grid(row=12, column=0) def frame_three(): #ENTERING EDUCATION frame_2().grid.forget() frame_2().destroy() frame3 = tkinter.Frame(tk, borderwidth=2) frame3.pack(fill=BOTH,expand=1,pady=50,padx=80) def frame_3(): #ENTERING EDUCATION frame_2().grid.forget() frame_2().destroy() frame3 = tkinter.Frame(tk, borderwidth=2) frame3.pack(fill=BOTH,expand=1,pady=50,padx=80) age_confirm = tkinter.Label(frame3, text="You entered 38!") age_confirm.grid(row=0, column=0) nextpage.grid(row=10, column=0) exitapp = tkinter.Button(frame2,text="Exit",command=tk.destroy) #exits programme exitapp.grid(row=12, column=0) frame1 = tkinter.Frame(tk, borderwidth=2) #WELCOME PAGE, a.k.a The first frame frame1.pack(fill=BOTH,expand=1,pady=50,padx=80) label = tkinter.Label(frame1, text="Welcome to NAME GAME! I'm going to guess who you are...") label.grid(row=0, column=0) #displays text at top of frame nextpage = tkinter.Button(frame1,text="Continue",command=frame_2) def frame_2(): #ENTERING AGE frame1.grid_forget() frame1.destroy() frame2 = tkinter.Frame(tk, borderwidth=2,) frame2.pack(fill=BOTH,expand=1,pady=50,padx=80) need_info = tkinter.Label(frame2, text="I need some information first...") need_info.grid(row=0, column=0) #displays text at top of frame enter_age = tkinter.Label(frame2, text="Please enter your age!") enter_age.grid(row=2, column=0) #displays second line of text age = tkinter.Entry(frame2, width=10) age.grid(row=3, column=0) nextpage = tkinter.Button(frame2,text="Continue",command=frame_3) nextpage.grid(row=10, column=0) exitapp = tkinter.Button(frame2,text="Exit",command=tk.destroy) #exits programme exitapp.grid(row=12, column=0) nextpage.grid(row=2, column=0) exitapp = tkinter.Button(frame1,text="Exit",command=tk.destroy) #exits programme exitapp.grid(row=4, column=0) tk.mainloop() </code></pre>
36,912,061
0
How to set filename of excel file to export from html table <p>I try to export datatable html to excel file but right now, i don't know how to set file name in savefiledialog popup</p> <p>here my code</p> <pre><code> $('#exportTable').click(function () { var startDate = $('#startDate').val(); var endDate = $('#endDate').val(); searchReportWithDate(startDate, endDate); setTimeout(function () { var rowCount = $('#tblExportData &gt;tbody &gt;tr').length; alert(rowCount); if (rowCount &gt; 0) { var uri = 'data:application/vnd.ms-excel;base64,' , template = '&lt;html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"&gt;&lt;head&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;/x:Name&gt;&lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt;&lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt;&lt;/xml&gt;&lt;![endif]--&gt;&lt;meta http-equiv="content-type" content="text/plain; charset=UTF-8"/&gt;&lt;/head&gt;&lt;body&gt;&lt;table&gt;{table}&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;' , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) } , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } return function (table, name) { table = document.getElementById("tblExportData") var ctx = {worksheet: name || 'Sheet1', table: table.innerHTML} window.location.href = uri + base64(format(template, ctx)) }() } }, 5000); }); </code></pre>
35,053,146
0
Helicon Ape by Helicon Tech provides support for Apache .htaccess and .htpasswd configuration files in Microsoft IIS.
21,441,777
0
JS. How to get list of div's with similar class name? <p>I have html, like this:</p> <pre><code>&lt;div id="c0" class="bz_comment bz_first_comment"&gt;&lt;/div&gt; &lt;div id="c1" class="bz_comment"&gt;&lt;/div&gt; &lt;div id="c2" class="bz_comment"&gt;&lt;/div&gt; &lt;div class="bz_add_comment"&gt;&lt;/div&gt; </code></pre> <p>How can I get array of all the div's (3 div in example) by class that's starts with "bz_comment[anysymbols]" in JavaScript (not using JQuery)? </p> <p>Or can i get array of div's by id that's starts with "c[numeric_value]"?</p> <pre><code>[numeric_value_can_consist_of_some_numbers] </code></pre> <p>It's the similar question like stackoverflow.com/questions/1225611/ (but i don't have reputation to ask in that question). Thanks in advance.</p>
7,405,118
0
<pre><code> with(Math) { var exp = floor(log(number)/log(10)) - 1; exp = max(exp,0); var n = number/pow(10,exp); var n2 = ceil(n/5) * 5; var result = n2 * pow(10,exp); } </code></pre> <p><a href="http://jsfiddle.net/NvvGf/4/" rel="nofollow">http://jsfiddle.net/NvvGf/4/</a></p> <p>Caveat: only works for the natural numbers.</p>
39,687,720
0
SSL not work in PHP5.6 on Windows <p>I tried:</p> <pre><code>$host = 'ssl://fbcdn-sphotos-c-a.akamaihd.net'; $port = 443; $fp = fsockopen($host, $port, $errno, $errstr, 30); if (!$fp) { var_dump($errno, $errstr); } else { echo 'Connected'; } </code></pre> <p>And:</p> <pre><code>$host = 'ssl://fbcdn-sphotos-c-a.akamaihd.net:443'; $fp = stream_socket_client($host, $errno, $errstr, 30); if (!$fp) { var_dump($errno, $errstr); } else { echo 'Connected'; } </code></pre> <p>But both returns:</p> <pre><code>int(0) string(0) "" </code></pre> <p>As if I had not been able to connect.</p> <ul> <li>I tried PHP5.6 for x86 and PHP5.6 for x64</li> <li>I used lastet release in <a href="http://windows.php.net/download#php-5.6" rel="nofollow">http://windows.php.net/download#php-5.6</a></li> <li>In Linux it seems to work normally.</li> <li>This only occurs with some fields, others work well.</li> <li>PHP with CURL and SSL work fine in PHP5.6</li> </ul> <p><strong>Note:</strong> Strangely in php5.4 works perfectly.</p> <p>Is a bug in this version of PHP?</p> <h2>Details:</h2> <p>PHP 5.4.12</p> <blockquote> <p>Registered Stream Socket Transports: tcp, udp, ssl, sslv3, sslv2, tls</p> <p>Compiler: MSVC9 (Visual C++ 2008)</p> <p>Architecture: x64</p> <p>Configure Command (compile):</p> <pre><code>cscript /nologo configure.js "--enable-embed" "--enable-cli-win32" "--enable-apache2-2handler" "--enable-apache2-2filter" "--enable-apache2-4handler" "--with-mysql=shared" "--with-mysqli=shared" "--enable-pdo" "--with-pdo-mysql=shared" "--with-pgsql=shared" "--with-pdo-pgsql=shared" "--with-mcrypt=static" "--with-openssl=shared" "--enable-sockets=shared" "--enable-intl=shared" "--enable-mbstring=shared" "--enable-mbregex" "--enable-exif=shared" "--with-xmlrpc=shared" "--with-xsl=shared" "--enable-solr=shared" "--enable-solr-debug" "--with-curl=shared" "--with-tidy=shared" "--with-bz2=shared" "--enable-rar=shared" "--enable-fileinfo=shared" "--with-gettext=shared" "--with-mhash" "--with-ldap=shared" "--enable-com-dotnet=shared" "--enable-soap=shared" "--enable-shmop=shared" "--with-gmp=shared" "--with-interbase=shared" "--with-pdo-firebird=shared" "--with-sqlite3=shared" "--with-pdo-sqlite=shared" "--with-pdo-odbc=shared" "--enable-dbase=shared" "--with-pdo-oci=C:\php-sdk\oracle\x64\instantclient_10_2\sdk,shared" "--with-oci8=C:\php-sdk\oracle\x64\instantclient_10_2\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\x64\instantclient_11_2\sdk,shared" "--with-sybase-ct=shared" "--enable-couchdb=shared" "--with-couchbase=shared" "--enable-mongo=shared" "--with-imap=shared" "--enable-mailparse=shared" "--enable-pop3=shared" "--with-smtp=shared" "--with-oauth=shared" "--with-ssh2=shared" "--with-snmp=shared" "--enable-uploadprogress=shared" "--enable-http=shared" "--with-imagick=shared" "--enable-discount=shared" "--with-pdflib=shared" "--with-haru=shared" "--with-excel=shared" "--with-enchant=shared" "--enable-printer=shared" "--with-geoip=shared" "--enable-timezonedb=shared" "--with-xdebug=shared" "--enable-suhosin=shared" "--disable-optimizer-plus" "--enable-pthreads=shared" "--enable-pthreads=shared" "--enable-win32service=shared" "--with-memcached=shared" "--enable-memcache=shared" "--enable-apc=shared" "--enable-apc-srwlock-native" "--enable-apc-debug" "--enable-xcache=shared" "--enable-xcache-optimizer" "--enable-xcache-coverager" "--enable-eaccelerator=shared" "--enable-varnish=shared" "--enable-ffmpeg=shared" "--disable-security-flags" </code></pre> <p><strong>openssl</strong> <br></p> <p>OpenSSL support: enabled</p> <p>OpenSSL Library Version: OpenSSL 1.0.1c 10 May 2012</p> <p>OpenSSL Header Version: OpenSSL 1.0.1e 11 Feb 2013</p> </blockquote> <p>PHP 5.6.26</p> <blockquote> <p>Registered Stream Socket Transports: tcp, udp, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2</p> <p>Compiler: MSVC11 (Visual C++ 2012)</p> <p>Architecture: x64</p> <p>Configure Command (compile):</p> <pre><code>cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:\php-sdk\oracle\x64\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x64\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo" </code></pre> <p><strong>openssl</strong> <br></p> <p>OpenSSL support: enabled</p> <p>OpenSSL Library Version: OpenSSL 1.0.1c 10 May 2012</p> <p>OpenSSL Header Version: OpenSSL 1.0.1t 3 May 2016</p> <p>Openssl default config: c:/openssl-1.0.1c-X64/ssl/openssl.cnf</p> <p>openssl.cafile: no value</p> <p>openssl.capath: no value</p> </blockquote>
8,674,210
0
<p>One thing you can do is to use the interface (i.e. the header files) and provide an implementation of your own, at least for those functions you care about. To switch between both versions essentially amounts to linking with different libraries: yours for testing, theirs for the real implementation.</p> <p>There are a few issues with that which can be addressed e.g. by only retaining the public interface and changing the private interface (on this case compilation needs to be directed at the different declarations, e.g. using different search pathes for the headers):</p> <ul> <li>often the stubbed version wants to store different data</li> <li>some object may need to construct private subobjects in specific ways</li> <li>inline function may call other functions you don't really want to implement</li> </ul>
16,854,165
0
<p>Probably a more elegant way of doing this but you could loop the array and convert each value to a string by adding it to a blank string <code>+=""</code>. Check <a href="http://stackoverflow.com/questions/971039/javascript-string-and-number-conversion">here</a> for javascript type conversions </p> <pre><code>var arr = [1, 2, 3, 4]; for(var i=0;i&lt;arr.length;i++) arr[i]+=""; alert(typeof arr[0]) //String </code></pre>
9,303,307
0
Upgrading application to Ruby 1.8.7, Rails 3 and getting undefined method `config_accessor' for SiteSweeper:Class <p>I'm struggling through upgrading an app to Rails 3 (Ruby 1.8.7), and my current roadblock is when running 'rake test --trace' i get the following:</p> <pre><code>** Invoke test (first_time) ** Execute test ** Invoke test:units (first_time) ** Invoke test:prepare (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Invoke test:functionals (first_time) ** Invoke test:prepare ** Execute test:functionals DEPRECATION WARNING: "Rails.root/test/mocks/test" won't be added automatically to load paths anymore in future releases. (called from &lt;APP PATH&gt;/config/application.rb:17) C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.11/lib/action_controller/caching/pages.rb:47: undefined method `config_accessor' for SiteSweeper:Class (NoMethodError) from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.11/lib/active_support/concern.rb:52:in `class_eval' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.11/lib/active_support/concern.rb:52:in `append_features' from &lt;APP PATH&gt;/app/sweepers/site_sweeper.rb:4:in `include' from &lt;APP PATH&gt;/app/sweepers/site_sweeper.rb:4 from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `require' from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `require' ... </code></pre> <p>The error here points to code that is actually inside the Rails 3.0.11 gem (action_controller/caching/pages.rb:47) and i can't figure out why that would cause problems or why i can't find any others having this problem. I'm also looking for the docs for ActionController::Caching to see if 'config_accessor' would have gone away..?</p> <p>Any assistance is much appreciated.</p>
4,333,894
0
Read td values using prototype <p>I would like to read the values of HTML td using prototype. For example, say you have a table as follows</p> <pre><code>&lt;table id="myTable"&gt; &lt;tr&gt; &lt;td&gt;apple&lt;/td&gt; &lt;td&gt;orange&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;car&lt;/td&gt; &lt;td&gt;bus&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I would like to read the values - apple, orange, car and bus alone. I am unable to find a way to do it? Any help would be of great help.</p> <p>Thanks, J</p>
7,118,415
0
json not loading in iphone device while using sencha touch and phonegap <p>I'm trying to load a json into my view. Im using phonegap with sencha touch and when I load the app to my phone the json does not load at all.. It works fine in the browser and in the simulator. I would really appreciate some help from the experts</p> <p>Here is the main code that im trying:</p> <p>the store:</p> <p>App.stores.freebees = new Ext.data.Store({ model: 'Freebee', autoLoad: true, proxy: { type: 'ajax', url: 'fixtures/freebees', reader: { type: 'json' } } });</p> <p>the list view:</p> <p>App.views.FreebeesList = Ext.extend(Ext.List, { id: 'indexlist', layout: 'fit', store: App.stores.freebees, itemTpl: '{companyName}, {title}, {address}',</p> <pre><code>listeners: { 'itemtap': function(list, index, item, obj) { Ext.dispatch({ controller: 'Freebee', action: 'showDetails', id: list.getRecord(item).data.id, lat: list.getRecord(item).data.lat, longitude: list.getRecord(item).data.longitude, companyName: list.getRecord(item).data.companyName, address: list.getRecord(item).data.address, }); } }, initComponent: function() { App.views.FreebeesList.superclass.initComponent.apply(this, arguments); } </code></pre> <p>}); Ext.reg('App.views.FreebeesList', App.views.FreebeesList);</p> <p>the json:</p> <p>[ { "id": 1, "title": "Freebee 1", "companyName": "Företaget AB 1", "address": "Ekuddsvägen 1 Nacka 131 38 Sweden", "lat": 59.3058, "longitude": 18.1463 }, { "id": 2, "title": "Freebee 2", "companyName": "Företaget AB 2", "address": "Ekuddsvägen 2 Nacka 131 38 Sweden", "lat": 59.305, "longitude": 18.1478 } ]</p>
20,831,969
0
<p>On Ruby <strong>.respond_to?</strong> is a test method. One of the things that does is takes a symbol and returns a <strong>true</strong> if the object can receive a method, a <strong>false</strong> if it doesn't.<br> For example,:<br> <strong>[1, 2, 3].respond_to?(:push)</strong> would return <strong>true</strong>, since you can call <strong>.push</strong> on an array object. However<br> <strong>[1, 2, 3].respond_to?(:to_sym)</strong> would return <strong>false</strong>, since you can't turn an array into a symbol </p> <p>Links:<br> a] Ruby is oriented to what methods call answers to, rather than what type an object is. <a href="http://www.codecademy.com/courses/ruby-beginner-en-1o8Mb/2/3?curriculum_id=5059f8619189a5000201fbcb" rel="nofollow">respond_to?</a> </p>
7,731,904
0
<p>The Hough transform gives you equations of lines (ie infinitely long lines not segments).</p> <p>Once you have these equations you could test how <a href="http://paulbourke.net/geometry/pointline/" rel="nofollow">far each point is from a line</a> and decide whether it is on the line or not (given some maximum distance).</p> <p>When you add new points you can do the same test to see if they are sufficiently close to any of the existing lines.</p>
20,526,267
0
<p>You're returning a pointer to a local array, which is destroyed when the function returns. The best solution is to return a string object:</p> <pre><code>std::string read_word() { std::string input; std::cin &gt;&gt; input; return input; } </code></pre> <p>Note that I also changed the function name to match what it does. If you actually want a line, then you want</p> <pre><code>std::string read_line() { std::string input; std::get_line(std::cin, input); return input; } </code></pre> <p>If you really think you want to return a pointer, then think again. You almost certainly don't.</p> <p>If you still really think you do, then you could return a pointer to a static variable, which lasts as long as the program:</p> <pre><code>// Danger: the returned pointer is only valid until the next call. // Danger: do not call from multiple threads. // Danger: any line longer than 255 characters will cause dreadful calamity. char const * read_line() { static char input[256]; std::cin.getline(input); return input; } </code></pre> <p>or dynamically allocate an array, and hope the caller remembers to delete it:</p> <pre><code>// Danger: the returned pointer must be deleted (with `delete[]`) after use // Danger: any line longer than 255 characters will cause dreadful calamity. char const * read_line() { char * input = new char[256]; std::cin.getline(input); return input; } </code></pre>
38,632,620
0
Yum and RPM show that the number of installed packages is different <pre><code>[root@study ~]# rpm -qa | wc -l 777 [root@study ~]# yum list installed | wc -l 1054 </code></pre> <p>i want to know why different,shoud i get correct number of installed packages?</p>
39,506,983
0
How can I create a reminder using AlarmManager? <p>I tried to make a project that will show <code>Notification</code> on particular time and even the app is not open it will show it. But it is showing message at particular time and also after the given time. Moreover the <code>Notification</code> does not work when the app is closed.</p> <p>How can I stop it permanently after the given time and also run in the background ?</p> <p>code is given below.</p> <pre><code>private PendingIntent pendingIntent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, Calendar.SEPTEMBER); //calendar.set(Calendar.YEAR, 2016); calendar.set(Calendar.DAY_OF_MONTH, 15); calendar.set(Calendar.HOUR_OF_DAY, 14); calendar.set(Calendar.MINUTE, 24); calendar.set(Calendar.SECOND, 05); //calendar.set(Calendar.AM_PM,Calendar.PM); Intent myIntent = new Intent(MainActivity.this, AlarmReceiver.class); pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, myIntent,0); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); alarmManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent); Intent into = new Intent(this, AlarmReceiver.class); PendingIntent ppendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1253, into, 0); AlarmManager alarmManag = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManag.cancel(ppendingIntent); ppendingIntent.(); } @Override public void onReceive(Context context, Intent intent) { Intent service1 = new Intent(context, MyAlarmService.class); context.startService(service1); } </code></pre> <p>Receiver has been added to manifest.</p>
17,554,915
0
Elisp equivalent of Clojure's time? <p>Here's Clojure's doc:</p> <pre><code>clojure.core/time ([expr]) Macro Evaluates expr and prints the time it took. Returns the value of expr. </code></pre> <p>Is there some (semi-) standard way to do this in Emacs lisp?</p>
36,941,627
0
<blockquote> <p>Pushing and popping is definitely not a problem and you dont need a singleton request for it.</p> <p>Other thing for the <code>TableViewCell</code> , i would advise to make separate reusable cell index for the normal table cell and for the advertisement cell. That way , the cell will be reused and you dont need to recreate GADView everytime.</p> </blockquote>
18,057,685
0
<p>You can try:</p> <pre><code>CultureInfo CultureInfoDateCulture = new CultureInfo("en-US"); DateTime date; bool works = DateTime.TryParseExact(dateString, "MM/dd/yyyy", CultureInfoDateCulture , DateTimeStyles.None, out date)) </code></pre>
12,989,084
0
<p>change this </p> <pre><code>message[i].getFrom() </code></pre> <p>to</p> <pre><code>message[i].getFrom()[0].toString()) </code></pre>
40,104,782
0
JAXB marshall date as epoch not consistent across databases <p>When we marhsal a date from a mysql database out of the box JAXB converts this to milliseconds since the epoch, which is what we want.</p> <p>However when swapping the database to oracle the JAXB marshal converts this to a string.</p> <p>I imagine this is due to different formats stored in the databases? Is there a way to force the serialisation to milliseconds to be consistent?</p> <p>Thanks Ian</p>
33,838,176
0
<p>You can explicitly set TerminationGracePeriodSeconds to zero in the PodSpec to obtain the old behavior.</p>
21,194,987
0
<p>Just don't change the <code>overflow</code> property:</p> <pre><code>nav &gt; ul &gt; li:hover &gt; ul { min-height: 110px; /*overflow: visible; Remove this*/ } </code></pre> <p>Check this <a href="http://jsfiddle.net/r9Dyq/1/" rel="nofollow">http://jsfiddle.net/r9Dyq/1/</a></p>
22,925,087
0
how to use html to post multipart/form-data <p>I have form, I want to post through multipart/form-data. How to use html to specify each fields' type.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; New Student &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="http://10.128.157.12:8080/student" method="post" enctype="multipart/form-data"&gt; student first name: &lt;input type="text" size="100" name="firstname" value="Michael"/&gt;&lt;br&gt; student last name: &lt;input type="text" size="100" name="lastname" value="William"/&gt;&lt;br&gt; student age: &lt;input type="text" size="100" name="age" value="34" /&gt; &lt;br&gt; &lt;input type="submit" value="Submit" autofocus="autofocus" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
38,242,778
0
Error When I try to add dynamically component with angular2 using drag and drop <p>this is my directives to drag and drop</p> <p>I want when I apply my drag and drop to add a component to my div I did the some things after event click but now I how to change it to drag and drop </p> <pre><code>import { Directive, Output, EventEmitter, ElementRef, Input, Renderer, ViewContainerRef, ViewChild, ComponentResolver, ComponentRef } from '@angular/core'; import {Div444} from "../gridmanager/div4-4-4.component"; declare var jQuery:JQueryStatic; @Directive({ selector: '[dnd_drag_grid]', host: { '(dragstart)': 'onDragStart($event)', '(dragend)': 'onDragEnd($event)', '(drag)': 'onDrag($event)', } }) export class dnd_drag_grid { elementDrag:HTMLElement; @Input("drag") drag; set draggable(value:boolean) { this.drag = !!value; } elem:HTMLElement; constructor(private componentRef:ComponentRef, private resolver:ComponentResolver, private el:ElementRef, private renderer:Renderer) { this.renderer.setElementAttribute(this.el.nativeElement, 'draggable', 'true'); this.renderer.setElementStyle(this.el.nativeElement, 'cursor', 'move'); } onDrag(event:MouseEvent) { console.log(" -----onDrag---- " + this.drag); this.renderer.setElementStyle(this.el.nativeElement, 'border-style', 'dotted'); } onDragEnd(event:Event) { console.log(" -----DragEnd---- " + this.drag); this.renderer.setElementStyle(this.el.nativeElement, 'border', 'none'); } onDragStart(event:DragEvent) { console.log(" ----DragStart----- " + this.drag); this.elementDrag = this.el.nativeElement; } } @Directive({ selector: '[dnd_drop_grid]', host: { '(dragover)': 'onAllowDrop($event)', '(drop)': 'onDrop($event)', '(dragleave)': 'ondragleave($event)', '(dragenter)': 'onDragEnter($event)' } }) export class dnd_drop_grid { elementDrop:HTMLElement; @Input("drop") drop; @Input("target") target; set droppable(value:boolean) { this.drop = !!value; } set setTarget(value:string) { this.target = value; } elem:HTMLElement; @ViewChild('', {read: ViewContainerRef}) component_target; constructor(private componentRef:ComponentRef, private resolver:ComponentResolver, private el:ElementRef, private renderer:Renderer) { console.log("target "+ this.target); } onAllowDrop(event:DragEvent) { this.component_target = this.target; console.log("target "+ this.target); console.log("on allow drop "); event.preventDefault(); this.renderer.setElementStyle(this.el.nativeElement, 'borderStyle', 'dotted'); this.renderer.setElementStyle(this.el.nativeElement, 'borderColor', 'red'); } ondragleave(event:DragEvent) { this.renderer.setElementStyle(this.el.nativeElement, 'borderStyle', 'bridge'); this.renderer.setElementStyle(this.el.nativeElement, 'borderColor', 'white'); console.log("target "+ this.target); } onDragEnter(event:Event) { console.log("target "+ this.target); } onDrop(event:DragEvent) { console.log("target "+ this.target); this.elementDrop = this.el.nativeElement; event.preventDefault(); this.resolver.resolveComponent(Div444).then((factory) =&gt; { this.componentRef = this.component_target.createComponent(factory); }); this.renderer.setElementStyle(this.el.nativeElement, 'borderStyle', 'bridge'); this.renderer.setElementStyle(this.el.nativeElement, 'borderColor', 'white'); console.log("is dropped !"); } } </code></pre> <p>and I add this in my template .html </p> <pre><code>&lt;li dnd_drag_grid drag="true"&gt;Div 4-4-4&lt;/li&gt; &lt;div dnd_drop_grid target="val" drop="true" class="page" id="content" size="A4" layout="portrait" &gt; &lt;div #val hidden&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>this is my error</p> <pre><code> Unhandled Promise rejection: _this.component_target.createComponent is not a function ; Zone: angular ; Task: Promise.then ; Value: TypeError: _this.component_target.createComponent is not a function(…) </code></pre>
12,097,977
0
<p>CSS:</p> <pre><code>#pages-content ul li{ width: 250px; height: 75px; text-align: center; } </code></pre> <p>HTML:</p> <pre><code>&lt;div id="pages-content"&gt; &lt;ul&gt; &lt;li&gt;Matter here&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p><a href="http://jsfiddle.net/3zLcT/1/" rel="nofollow">Working fiddle</a></p>
32,641,604
0
Java: How would I declare an undefined number of object with user inputted data? <p>for my assignment I am suppose to have a user input the name and price of items. However, they are to enter in an unlimited amount of times until a sentinel value is used. I don't actually know how I'd go about doing this. The only way I know how to declare an object with user input is to use a scanner and then place that data within the arguments of a constructor. But that would only create a single object. Thanks!</p> <pre><code>import java.util.Scanner; public class Item { public static void main(String[] args) { Scanner input = new Scanner(System.in); } private String name; private double price; public static final double TOLERANCE = 0.0000001; public Item(String name,double price) { this.name = name; this.price = price; } public Item() { this("",0.0); } public Item(Item other) { this.name = other.name; this.price = other.price; } public String getName() { return name; } public double getPrice() { return price; } public void setName(String name) { this.name = name; } public void setPrice(double price) { this.price = price; } public void input(String n, double item) { } public void show() { // Code to be written by student } public String toString() { return "Item: " + name + " Price: " + price; } public boolean equals(Object other) { if(other == null) return false; else if(getClass() != other.getClass()) return false; else { Item otherItem = (Item)other; return(name.equals(otherItem.name) &amp;&amp; equivalent(price, otherItem.price)); } } private static boolean equivalent(double a, double b) { return ( Math.abs(a - b) &lt;= TOLERANCE ); } } </code></pre>
33,129,138
0
<p>You use a try..catch block to catch the Exception, then add whatever error handling logic is appropriate.</p> <pre><code>try { var response = authClient.Post&lt;AccessTokenResponse&gt;(authRequest); response.EnsureSuccessStatusCode(); } catch (WebException ex) { // something bad happened, add whatever logic is appropriate to notify the // user, log the error, etc... Console.Log(ex.Message); } </code></pre>
25,347,825
0
PyQt or PySide: QTextEdit deselect all <p>I'm using PySide(PyQt is fine as well) and I want to deselect everything inside a QTextEdit. Selecting everything is very easy and it's done by self.textedit.selectAll(), but I can't find a simple way to deselect everything. Is there a straightforward way to do it that I'm not aware of or is it more complicated than that?</p> <p>Thanks.</p>
16,827,652
0
<p>I know you specifically asked for regex, but you don't really need regex for this. You simply need to split the string by delimiters (in this case a backslash), then choose the part you need (in this case, the 3rd field - the first field is empty).</p> <ul> <li><p><code>cut</code> example:</p> <pre><code>cut -d '/' -f 3 &lt;&lt;&lt; "$string" </code></pre></li> <li><p><code>awk</code> example:</p> <pre><code>awk -F '/' {print $3} &lt;&lt;&lt; "$string" </code></pre></li> <li><p><code>perl</code> expression, using <code>split</code> function:</p> <pre><code>(split '/', $string)[2] </code></pre></li> </ul> <p>etc.</p>
25,502,354
0
How can I limit the results extracted by a query in Acces? <p>I have this query in my Access database:</p> <pre><code>SELECT t_Campioni_CAMPIONE, t_Campioni.[DATA ARRIVO], t_Campioni.PRODUTTORE, t_Campioni.CodF, t_Fornitori.[Nome Fornitore] FROM t_Campioni INNER JOIN t_Fornitori ON t_Campioni.CodF = t_Fornitori.CodF WHERE (((t_Campioni.CAMPIONE)=[Forms]![m_Campioni_modifica]![CAMPIONE])) ORDER BY t_Campioni.[DATA ARRIVO] DESC; </code></pre> <p>It works but I need it to extract only the first record (with the last date). How can I do it?</p>
4,647,666
0
CoreData programming with multiple Entities <p>I'm looking for some help with CoreData and with Entities in general. For the purpose of my question, lets say I have a database of albums. I simple have an entity named albums with Attributes for Name, Artist, Year, Album Art, and such.</p> <p>Now, lets say I want to be able to create songs for this album. I'm thinking I should have a separate Entity for the songs, and have a one-to-many relationship with it. However, I'm not sure exactly how I would do that.</p> <p>Since I have different albums which contain different songs, I want to separate the songs from AlbumA from Album B. Now, I could have a row in the songs database for which album it belongs to, but is that the most efficient way to do this. What if I have a duplicate album name. I tried creating a unique "hash" of the album name using the time created and the name, but is there a better way.</p> <p>I also need a better way to handle deletion for when an album is deleted. </p> <p>Without using one-to-many relationships, I was able to create two separate entities, Albums and Songs, which aren't linked together. However, when I create a new album, it loads a new viewcontroller and passes the "hashes" time-stamped album name to the viewcontroller. Then when I create a new song, it uses that hashed time-stamped album name as a row in the Songs entity. That way, when I'm viewing which songs are in the album, I just set an NSPredicate to only show queries which include the hashes time-stamp. However, deletion is a problem because their are no relationships. </p> <ol> <li>Should I be using a "one-to-many relationship"?</li> <li>How should I handle determining whether an song belongs to a certain album?</li> <li>What if their are multiple albums with the same name?</li> <li>How do I handle deletion?</li> </ol> <p>If anyone could provide answers, code, or tutorial for any of these… it would be greatly appreciated.</p>
26,048,684
0
Sorting an array which the maximum value is similar to its size <p>I'm trying to figure out the best way to sort an array which the maximun value is similar to its size. The array does not contain repeated elements.</p> <pre><code>import java.util.Arrays; import java.util.Random; public class SortExamples { public static void main(String[] args) { SortExamples sortExample = new SortExamples(); int[] sizes = { 10000, 100000, 500000, 750000, 1000000, 1500000, 2000000, 5000000, 7500000, 10000000, 15000000 }; SortingMethod arraySort = new ArraySort(); SortingMethod quickSort = new QuickSort(); for (int i = 0; i &lt; sizes.length; i++) { System.out.println("Sorting array of length: " + sizes[i]); int[] array1 = sortExample.getArraySample(sizes[i]); int[] array2 = Arrays.copyOf(array1, array1.length); assert Arrays.equals(array1, array2); sortExample.sort(array1, arraySort); sortExample.sort(array2, quickSort); assert Arrays.equals(array1, array2); System.out.println(); } } public void sort(int[] array, SortingMethod sortingMethod) { assert !checkOrdered(array); long startTime = System.currentTimeMillis(); sortingMethod.sort(array); long endTime = System.currentTimeMillis(); System.out.println("Total time with " + sortingMethod.getClass().getSimpleName() + ": " + (endTime - startTime) + " millis."); assert checkOrdered(array); } public int[] getArraySample(int size) { int[] array = new int[size]; for (int i = 0; i &lt; size; i++) array[i] = i; shuffle(array); return array; } /** * Same as java.util.Collections.shuffle(List&lt;?&gt;, Random) * * @param array */ public void shuffle(int[] array) { Random random = new Random(); int count = array.length; for (int i = count; i &gt; 1; i--) swap(array, i - 1, random.nextInt(i)); } public boolean checkOrdered(int[] array) { for (int i = 1; i &lt; array.length; i++) if (array[i] &lt; array[i - 1]) return false; return true; } public static class ArraySort implements SortingMethod { public void sort(int[] array) { if (array.length &lt; 2) return; Integer[] auxiliarArray = new Integer[getMax(array) + 1]; for (int i = 0; i &lt; array.length; i++) { int current = array[i]; auxiliarArray[current] = current; } int k = 0; for (int j = 0; j &lt; auxiliarArray.length; j++) { Integer current = auxiliarArray[j]; if (current != null) { array[k] = current; k++; } } } public int getMax(int[] array) { int max = array[0]; for (int i = 0; i &lt; array.length; i++) if (max &lt; array[i]) max = array[i]; return max; } } public static class QuickSort implements SortingMethod { public void sort(int[] array) { sortInternal(array, 0, array.length - 1); } public void sortInternal(int[] array, int start, int end) { int i = start; int j = end; int pivot = array[(start + end) / 2]; while (i &lt;= j) { while (array[i] &lt; pivot) i++; while (array[j] &gt; pivot) j--; if (i &lt;= j) { swap(array, i, j); i++; j--; } } int startLeft = start; int endLeft = i - 1; if (startLeft &lt; endLeft) sortInternal(array, startLeft, endLeft); int startRigth = i; int endRigth = end; if (startRigth &lt; endRigth) sortInternal(array, startRigth, endRigth); } } public interface SortingMethod { public void sort(int[] array); } public static void swap(int[] array, int i, int j) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } } </code></pre> <p>The output I got was:</p> <pre><code>Sorting array of length: 10000 Total time with ArraySort: 2 millis. Total time with QuickSort: 2 millis. Sorting array of length: 100000 Total time with ArraySort: 14 millis. Total time with QuickSort: 16 millis. Sorting array of length: 500000 Total time with ArraySort: 22 millis. Total time with QuickSort: 59 millis. Sorting array of length: 750000 Total time with ArraySort: 25 millis. Total time with QuickSort: 91 millis. Sorting array of length: 1000000 Total time with ArraySort: 33 millis. Total time with QuickSort: 122 millis. Sorting array of length: 1500000 Total time with ArraySort: 66 millis. Total time with QuickSort: 191 millis. Sorting array of length: 2000000 Total time with ArraySort: 100 millis. Total time with QuickSort: 278 millis. Sorting array of length: 5000000 Total time with ArraySort: 391 millis. Total time with QuickSort: 662 millis. Sorting array of length: 7500000 Total time with ArraySort: 2805 millis. Total time with QuickSort: 1033 millis. Sorting array of length: 10000000 Total time with ArraySort: 3629 millis. Total time with QuickSort: 1409 millis. Sorting array of length: 15000000 Total time with ArraySort: 3825 millis. Total time with QuickSort: 2185 millis. </code></pre> <p>Is this an existing method? Could it be useful for something?</p>
2,536,376
0
<p>Selectors are ONE way to go... the alternative is to create a protocol and to require invokers of your API to provide a "delegate" object that implements the protocol. Then you can invoke the required selectors of that protocol on the delegate object that you have been given. Each has its advantages and disadvantages.</p> <p>Example using selectors: <a href="http://developer.apple.com/mac/library/documentation/cocoa/reference/foundation/Classes/NSThread_Class/Reference/Reference.html#//apple_ref/occ/clm/NSThread/detachNewThreadSelector:toTarget:withObject:" rel="nofollow noreferrer">NSThread:detachNewThreadSelector:toTarget:withObject</a></p> <p>Example using delegates:<a href="http://developer.apple.com/mac/library/documentation/cocoa/reference/foundation/Classes/NSXMLParser_Class/Reference/Reference.html#//apple_ref/occ/instm/NSXMLParser/setDelegate:" rel="nofollow noreferrer">NSXMLParser:setDelegate</a> + <a href="http://developer.apple.com/mac/library/documentation/cocoa/reference/foundation/Classes/NSXMLParser_Class/Reference/Reference.html#//apple_ref/occ/instm/NSXMLParser/parse" rel="nofollow noreferrer">NSXMLParser:parse</a> </p>
162,192
0
Visual Studio 2008 - Add Reference <p>When adding a DLL as a reference to an ASP.Net project, VS2008 adds several files to the bin directory. If the DLL is called foo.dll, VS2008 adds foo.dll.refresh, foo.pdb and foo.xml. I know what foo.dll is :-), why does VS2008 add the other three files? What do those three files do? Can I delete them? Do they need to be added in source control?</p>
37,988,054
0
<p>One solution is to create a version of your network that is truncated at the LSTM layer of which you want to monitor the gate values, and then replace the original layer with a custom layer in which the stepfunction is modified to return not only the hidden layer values, but also the gate values.</p> <p>For instance, say you want to access the access the gate values of a GRU. Create a custom layer GRU2 that inherits everything from the GRU class, but adapt the step function such that it returns a concatenation of the states you want to monitor, and then takes only the part containing the previous hidden layer activations when computing the next activations. I.e:</p> <pre><code>def step(self, x, states): # get prev hidden layer from input that is concatenation of # prev hidden layer + reset gate + update gate x = x[:self.output_dim, :] ############################################### # This is the original code from the GRU layer # h_tm1 = states[0] # previous memory B_U = states[1] # dropout matrices for recurrent units B_W = states[2] if self.consume_less == 'gpu': matrix_x = K.dot(x * B_W[0], self.W) + self.b matrix_inner = K.dot(h_tm1 * B_U[0], self.U[:, :2 * self.output_dim]) x_z = matrix_x[:, :self.output_dim] x_r = matrix_x[:, self.output_dim: 2 * self.output_dim] inner_z = matrix_inner[:, :self.output_dim] inner_r = matrix_inner[:, self.output_dim: 2 * self.output_dim] z = self.inner_activation(x_z + inner_z) r = self.inner_activation(x_r + inner_r) x_h = matrix_x[:, 2 * self.output_dim:] inner_h = K.dot(r * h_tm1 * B_U[0], self.U[:, 2 * self.output_dim:]) hh = self.activation(x_h + inner_h) else: if self.consume_less == 'cpu': x_z = x[:, :self.output_dim] x_r = x[:, self.output_dim: 2 * self.output_dim] x_h = x[:, 2 * self.output_dim:] elif self.consume_less == 'mem': x_z = K.dot(x * B_W[0], self.W_z) + self.b_z x_r = K.dot(x * B_W[1], self.W_r) + self.b_r x_h = K.dot(x * B_W[2], self.W_h) + self.b_h else: raise Exception('Unknown `consume_less` mode.') z = self.inner_activation(x_z + K.dot(h_tm1 * B_U[0], self.U_z)) r = self.inner_activation(x_r + K.dot(h_tm1 * B_U[1], self.U_r)) hh = self.activation(x_h + K.dot(r * h_tm1 * B_U[2], self.U_h)) h = z * h_tm1 + (1 - z) * hh # # End of original code ########################################################### # concatenate states you want to monitor, in this case the # hidden layer activations and gates z and r all = K.concatenate([h, z, r]) # return everything return all, [h] </code></pre> <p>(Note that the only lines I added are at the beginning and end of the function).</p> <p>If you then run your network with GRU2 as last layer instead of GRU (with return_sequences = True for the GRU2 layer), you can just call predict on your network, this will give you all hidden layer and gate values.</p> <p>The same thing should work for LSTM, although you might have to puzzle a bit to figure out how to store all the outputs you want in one vector and retrieve them again afterwards.</p> <p>Hope that helps!</p>
1,320,687
0
<p>The <code>&lt;legend&gt;</code> element can contain any <a href="http://www.htmlhelp.com/reference/html40/inline.html" rel="nofollow noreferrer">inline element</a>, so you can apply virtually whatever formatting you'd like.</p>
38,113,748
0
<p>The function <code>row.match</code> in the package <code>prodlim</code> allows you to identify the rows in one matrix that are also found (identical) in another matrix. Very convenient and easy to use.</p> <pre><code>library(prodlim) row.match(x,y) </code></pre>
17,730,994
0
<p>Create a <a href="https://developers.google.com/kml/documentation/kmzarchives" rel="nofollow">KMZ file</a> which includes the pictures and the KML <a href="http://www.google.com/earth/outreach/tutorials/kmz.html" rel="nofollow">KMZ tutorial for google earth</a></p>
40,283,608
0
How to apply vlookup formula in blank cells only <p>I want to apply vlookup formula only in those blank cells B4, B7, B10. I want to write macro so that vlookup formula applies only to the blank cells, rest of the data remain intact. </p> <p><a href="https://i.stack.imgur.com/ecStb.png" rel="nofollow">VLOOKUPFORMULA</a></p>
37,575,458
0
<p>Okay I see where you have gone wrong. Naming conventions would of actually prevented this but anyway. You're actually accessing the name like it's a static property, when in fact it's an instance property. Doing something like this will solve your problem:</p> <pre><code>let category = clothing_categories[indexPath.row] cell.nameclothing_category.text = category.name </code></pre>
8,159,392
0
arm-none-eabi-g++ calling globral constructor <p>I am trying to port c++ application to arm board with gcc tools (using RTOS). But my static const constructors are not being called. </p> <p>Simple code:</p> <pre><code>class TestClass { public: TestClass(); TestClass(int m); TestClass(const TestClass&amp; other); ~TestClass(); int getM() const; const TestClass&amp; operator = (const TestClass&amp; other); private: int m; }; class TestInitClass { static const TestClass TestClassObj; }; const TestClass TestInitClass::TestClassObj = TestClass(5); </code></pre> <p>I provide class definitions. But when I call this with TestInitClass::TestClassObj.getM() it returns me 0.</p> <p>There are multiple problems:</p> <ol> <li>My static const is getting allocated in .bss section. It is not getting in .ctors sections (this may be linker script problem?!)</li> <li>And even if it gets in .ctors section, how do I call these constructors</li> <li>When I use static c++ library how should I call them?</li> </ol> <p>Thanks</p>
9,871,158
0
Annotation based request validation <p>I'm trying to validate a numeric variable in the request, what I'm trying to achieve, for this field to be non null and numeric. I want to have different errors reported for null and conversion error.</p> <p>I was trying to use org.springframework.format.annotation.NumberFormat</p> <p>Why doesn't the @NumberFormat doesn't have default message property? Is there a reason why this has been missed. I'll now have to customize it as I'm not using the message resource bundles.</p> <pre><code>public class AddToJobsShortListWSRequest implements Serializable { @NumberFormat(style = NumberFormat.Style.NUMBER) @NotNull(message="ASL01") private Long userDetailId; </code></pre> <p>controller</p> <pre><code>public ResponseEntity&lt;String&gt; handlePostRequest(String xmlRequest, String... externalIds) { ResponseEntity&lt;String&gt; response = null; Set&lt;Enum&gt; enums = new HashSet&lt;Enum&gt;(); AddToJobsShortListWSRequest addToJobsShortListWSRequest = serializationDeserializationSupport.fromString(xmlRequest, AddToJobsShortListWSRequest.class); if(!jsonRequestValidator.validate(AddToJobsShortListWSError.class, enums, addToJobsShortListWSRequest)) { response = getBadRequestErrorResponseEntity(enums); } else{ ..... } </code></pre> <p>Validator</p> <pre><code> private void validate(@SuppressWarnings("rawtypes") Class enumClass, Object object, @SuppressWarnings("rawtypes") Set&lt;Enum&gt; enums) { BindException errors = new BindException(object, "object"); validator.validate(object, errors); @SuppressWarnings({"rawtypes"}) List fieldErrors = errors.getFieldErrors(); for (int i = 0; i &lt; fieldErrors.size(); i++) { if (fieldErrors.get(i) instanceof FieldError) { String m = ((FieldError) fieldErrors.get(i)).getDefaultMessage(); enums.add(Enum.valueOf(enumClass, m)); } } } </code></pre> <p>Is there any other annotation based validation applicable here? Also, what is the order of validation, which one kicks in first, NumberFormat, NotNull?</p> <p>Thanks in advance :)</p>
4,037,789
0
<p>Combining the images can be done easily using <a href="http://www.mathworks.com/help/techdoc/math/f1-84864.html#f1-85019">concatenation</a>:</p> <pre><code>image3 = [image1 image2]; %# Concatenate horizontally </code></pre> <p>And you can then visualize <code>image3</code> using any of the functions <a href="http://www.mathworks.com/help/techdoc/ref/image.html">IMAGE</a>, <a href="http://www.mathworks.com/help/techdoc/ref/imagesc.html">IMAGESC</a>, or <a href="http://www.mathworks.com/help/toolbox/images/ref/imshow.html">IMSHOW</a>:</p> <pre><code>image(image3); %# Display the image in a figure window </code></pre> <p><br> <strong>NOTE:</strong></p> <p>You didn't mention what type of images you are dealing with, only that they are 2-dimensional matrices of pixel data. This means they could be <a href="http://www.mathworks.com/help/toolbox/images/f14-13543.html#f14-33397">binary images</a> (with pixel values of 0 or 1), <a href="http://www.mathworks.com/help/toolbox/images/f14-13543.html#f14-13941">grayscale images</a> (with pixel values that represent a range from black to white), or <a href="http://www.mathworks.com/help/toolbox/images/f14-13543.html#f14-17587">indexed color images</a> (with pixel values that represent indices into a colormap).</p> <p>For binary and grayscale images, the above solution should work fine. However, indexed color images could be trickier to combine if each image has its own unique <a href="http://www.mathworks.com/help/techdoc/ref/colormap.html">colormap</a>. If the image is loaded from a file using the function <a href="http://www.mathworks.com/help/techdoc/ref/imread.html">IMREAD</a>, you can get the color map like so:</p> <pre><code>[image1,map1] = imread('image1.png'); %# Image and colormap for image file 1 [image2,map2] = imread('image2.png'); %# Image and colormap for image file 2 </code></pre> <p>Now, if <code>map1</code> and <code>map2</code> contain different arrangements of colors, the two images can't be so easily combined. One solution would be to first convert the images to 3-dimensional <a href="http://www.mathworks.com/help/toolbox/images/f14-13543.html#f14-20224">truecolor images</a> using the function <a href="http://www.mathworks.com/help/techdoc/ref/ind2rgb.html">IND2RGB</a>, then combine them using the function <a href="http://www.mathworks.com.au/help/techdoc/ref/cat.html">CAT</a>:</p> <pre><code>image1 = ind2rgb(image1,map1); %# Convert image 1 to RGB image2 = ind2rgb(image2,map2); %# Convert image 2 to RGB image3 = cat(2,image1,image2); %# Concatenate the images along dimension 2 </code></pre> <p>And now you can view <code>image3</code> as described above.</p>
32,251,318
0
Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required <p>I have simple script connection call using PHP 5.2.10 to a Web service working with SOAP 1.2. </p> <p>The same PHP installation is able to connect via Web service to another web server working with SOAP 1.1 without issues. In addition, the web services using 1.2 is working fine with another two servers using almost the same hard code.</p> <p>However, every time I am using SOAP 1.2 on this server with PHP 5.2.10 I got the bellow error if I run the script from a batch file:</p> <pre><code>Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in C: \NewSimpleConnectionTest.php on line 10 </code></pre> <p>If the script is running via Eclipse PHP with PHP 5.2 on a different computer, it does not have any error so the hard code seems fine, user and password are correct too because it is used on the others servers and on the Eclipse test:</p> <p>My script is this: </p> <pre><code>&lt;?php $_endpoint = "http://server:8080/serverv/ServerAPI"; $_username = "userServer"; $_password = "123ABC!"; try { $client = new SoapClient($_endpoint."?WSDL", array('location' =&gt; $_endpoint, 'login' =&gt; $_username, 'password' =&gt; $_password, 'trace' =&gt; 1, 'features' =&gt; SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS, 'soap_version' =&gt; SOAP_1_2)); echo 'Connected to Web Services.'; }catch(Exception $e){ echo 'Failure to connect to WebServices.'; } ?&gt; </code></pre> <p>This is the information in the SOAP and XML phpinfo.</p> <pre><code>SimpleXML Simplexml support =&gt; enabled Revision =&gt; $Revision: 1.151.2.22.2.46 $ Schema support =&gt; enabled soap Soap Client =&gt; enabled Soap Server =&gt; enabled Directive =&gt; Local Value =&gt; Master Value soap.wsdl_cache =&gt; 1 =&gt; 1 soap.wsdl_cache_dir =&gt; /tmp =&gt; /tmp soap.wsdl_cache_enabled =&gt; 1 =&gt; 1 soap.wsdl_cache_limit =&gt; 5 =&gt; 5 soap.wsdl_cache_ttl =&gt; 86400 =&gt; 86400 </code></pre> <p>Any idea about what is missing or the problem on this PHP version to work with SOAP 1.2 in that server?</p> <p>Thanks in advance!!</p>
20,186,846
0
<p>Make your HTML like this:</p> <pre><code>&lt;input type="text" name="mytextbox" id="mytextbox" onKeyUp="countChar(this)" size="1" maxlength="1" value="" /&gt; </code></pre> <p>And JS will be this:</p> <pre><code>function countChar(that) { var xy = that.value; var len = xy.length; if (len &gt;= 2) { that.value = that.value.substring(0, 1); } else { that.value=(1 - len); } } </code></pre>
8,793,450
0
<p>what you have to do to solve this problem is explicitly define the height of the input and then also define the font-size. For example:</p> <pre><code>input{ height:14px; font-size:10px; } </code></pre>
29,135,280
0
Java Array out of bounds error isn't out of bounds? <p>This code is the relevant portion of my program, and it produces an array out of bounds error, and I can't figure out why. My error is 'java.lang.ArrayIndexOutOfBoundsException: 6', with 6 being a random value, at the if statement in randomShot();</p> <pre><code>public class Ai { private int WIDTH; private int HEIGHT; public Ai(){ WIDTH=10; HEIGHT=10; } int[][] board=new int[WIDTH][HEIGHT]; Random rand = new Random(); public void randomShot(){ x=rand.nextInt(WIDTH/2); y=rand.nextInt(HEIGHT); x=x*2; if(y%2==0) { y+=1; } if(board[x][y]!=0) //java.lang.ArrayIndexOutOfBoundsException: 6 { randomShot(); } } </code></pre> <p>I have noticed that if I use the code</p> <pre><code>int[][] board=new int[10][10]; </code></pre> <p>it works perfectly fine. I can't see why this is happening, it's doing exactly the same thing?</p>
36,736,466
0
Google Analytics for Advanced Data Extraction <p>I am planning to use the FREE Google Analytics as the engine for analytic for an ecommerce website. Is it possible for me to do the advanced data extraction from Google Analytics for the following task?</p> <ol> <li><p>Every merchants will have their own analytic statistic on the website control panel to view how is their store page performing, which product people view the most, and etc detail statistic info.</p></li> <li><p>Web system will able to use Google Analytics to have deep understanding about each individual customer like what product they view the most, how frequently they visit and etc. Then, using the info to provide most relevant suggestion to each individual customer.</p></li> </ol> <p>Is this possible to be done with Google Analytics or I really need to have my own analytic system &amp; store all the data myself?</p>
2,086,081
0
<p>I think it's because of the circular reference between InventoryUser and ProductUserPK.</p> <p>Either InventoryUser.pk or ProductUserPK.user should be lazy.</p>
20,657,924
0
<p>When you are storing code in MySQL wrap the input in the <code>addslashes()</code> PHP function. Then when you retrieve code from MySQL you need to wrap the output in <code>stripslashes()</code>. </p> <p>See: <a href="http://www.php.net/stripslashes" rel="nofollow">http://www.php.net/stripslashes</a> <a href="http://li1.php.net/addslashes" rel="nofollow">http://li1.php.net/addslashes</a></p> <p>Hopefully this is what you were looking for.</p>
11,463,190
0
<p>Be careful about trusting the console, there is often asynchronous behavior that can trip you up.</p> <p>You're expecting <code>console.log(x)</code> to behave like this:</p> <ol> <li>You call <code>console.log(x)</code>.</li> <li><code>x</code> is dumped to the console.</li> <li>Execution continues on with the statement immediately following your <code>console.log(x)</code> call.</li> </ol> <p>But that's not what happens, the reality is more like this:</p> <ol> <li>You call <code>console.log(x)</code>.</li> <li>The browser grabs a reference to <code>x</code>, and queues up the "real" <code>console.log</code> call for later.</li> <li>Various other bits of JavaScript run (or not).</li> <li>Later, the <code>console.log</code> call from <strong>(2)</strong> gets around to dumping the current state of <code>x</code> into the console but this <code>x</code> won't necessarily match the <code>x</code> as it was in <strong>(2)</strong>.</li> </ol> <p>In your case, you're doing this:</p> <pre><code>console.log(this.attributes); console.log(this.attributes.widgets); </code></pre> <p>So you have something like this at <strong>(2)</strong>:</p> <pre><code> attributes.widgets ^ ^ | | console.log -+ | console.log -----------+ </code></pre> <p>and then something is happening in <strong>(3)</strong> which effectively does <code>this.attributes.widgets = [...]</code> (i.e. changes the <code>attributes.widget</code> reference) and so, when <strong>(4)</strong> comes around, you have this:</p> <pre><code> attributes.widgets // the new one from (3) ^ | console.log -+ console.log -----------&gt; widgets // the original from (1) </code></pre> <p>This leaves you seeing two different versions of <code>widgets</code>: the new one which received something in <strong>(3)</strong> and the original which is empty.</p> <p>When you do this:</p> <pre><code>console.log(_(this.attributes).clone()); console.log(_(this.attributes.widgets).clone()); </code></pre> <p>you're grabbing copies of <code>this.attributes</code> and <code>this.attributes.widgets</code> that are attached to the <code>console.log</code> calls so <strong>(3)</strong> won't interfere with your references and you see sensible results in the console.</p> <p>That's the answer to this:</p> <blockquote> <p>It's showing that widgets is not empty when logging <code>this.attributes</code> but it's shown as empty when logging <code>this.attributes.widgets</code>. Does anyone know what would cause this?</p> </blockquote> <p>As far as the underlying problem goes, you probably have a <code>fetch</code> call somewhere and you're not taking its asynchronous behavior into account. The solution is probably to bind to an <code>"add"</code> or <code>"reset"</code> event.</p>
7,729,256
0
<p>You might try something like:</p> <pre><code>assemblyTypes.Where(x =&gt; StringList.Contains(x.Name)); </code></pre> <p>Keep in mind this is case sensitive and ignores whitespace, so you will need to add case consideration or trimming if that's an issue.</p> <p><strong>Edit:</strong> (example for loop usage)</p> <pre><code>foreach (Type item in assemblyTypes.Where(x =&gt; StringList.Contains(x.Name))) { // Do stuff } </code></pre>
38,213,016
0
<p>You probably want to have something like</p> <pre><code>void Test2(void(*Func)(wchar_t*, wchar_t*),wchar_t* x, wchar_t* y) { (*Func)(x,y); } int main() { Test2(Test,L"Hello", L"Testing"); return 0; } </code></pre> <p>instead.</p> <hr> <p>As for your comment</p> <blockquote> <p>How do i do this in C++ with templates?</p> </blockquote> <p>I could think of</p> <pre><code>template&lt;typename Param&gt; void Test2(void(*Func)(Param, Param), Param x, Param y) { (*Func)(x,y); } void Test(wchar_t* a, wchar_t* b); int main() { Test2(Test,L"Hello", L"Testing"); return 0; } </code></pre> <p>This should just work fine.</p>
23,093,565
0
<p>A set by definition doesn't contain any duplicates. A set determines if two items are alike, by using either the objects equals()/compareTo(..) method or by using a Comparator. If you only want unique items in your set, implementing the Comparable interface and overriding equals() is what you want to do. BUT in your case, you're only interested in objects in unique groups, so it's then better to create a custom Comparator for the occasion, which you then supply to the Set, telling it to use it, instead of "natural ordering". </p> <pre><code>Set&lt;MyThing&gt; myThings = new TreeSet&lt;&gt;(new Comparator&lt;MyThing&gt;() { @Override public int compare(MyThing o1, MyThing o2) { return o1.getGroupId() - o2.getGroupId(); } }); myThings.addAll(Arrays.asList(myArray)); </code></pre> <p>After creating the set, you add your entire array into it, using the convinience method addAll(..).</p> <p>(How the comparator sorts your objects is completely up to you to decide.)</p>
36,107,296
0
<p>Assuming none of your file names contain any additional dots other than <code>.ogg.M4A</code>, then all you need is a single <code>REN</code> command.</p> <pre><code>ren *.ogg.M4A ??????????????????????????????.m4a </code></pre> <p>Be sure to use enough <code>?</code> to match the longest name in your file set.</p> <p>See <a href="http://superuser.com/q/475874/109090">How does the Windows RENAME (REN) command interpret wildcards?</a> for a full explanation of how REN handles wildcards.</p>
15,676,990
0
Difference of connection pool, jdbc and jndi <p>I need to know my understanding on above are correct,</p> <p>In connection pool you set multiple connection with the use of java.sql.Datasource.</p> <p>In jdbc we directly specify the connection url and oracle.jdbc.driver.OracleDriver and its always one connection where another request has to wait until the connection finish processing. </p> <p>And with JNDI its similar to direct jdbc where we refer the jdbc setting via a name, so that we can specify the connection url and other setting in the application server and not bound to the application right?</p>
1,924,487
0
<p>C# doesn't support covariant return types. When implementing an interface, you have to return the type specified by the interface. If you want to, you can explicitly implement the interface and have another method with the same name that returns the subtype. For example:</p> <pre><code>class MyImplementation : MyInterface { MyBaseClass MyInterface.someFunction() { return null; } public MySubClass someFunction() { return null; } } </code></pre>
21,937,676
0
<p>Use this <code>\[([^\[\]]*)\](.*)</code></p> <pre><code>$input_lines="[Hello World](http://google.com)"; preg_replace("/\[([^\[\]]*)\](.*)/", "$1", $input_lines); </code></pre>
5,856,918
0
Performance with WPF Combo Box inside a ListView <p>I was wondering if I was missing something obvious.</p> <p>I have a simple window with a ListView with 3 columns in it. One displays text and the other two have combo boxes in them.</p> <p>The ListView has approx. 500 records and the Comboboxes both pull from the same contact list which has approx. 8,000 records in it.</p> <p>I am using MVVM.</p> <p>This window takes for ever to open and once it does open it is practically frozen solid (it moves so slow)</p> <p>the queries to the database take under ten seconds (I log when the VM is fully loaded) then it takes two or three minutes to open the window. I made sure to store both lists in <code>List&lt;T&gt;</code> in my VM to make sure its not reprocessing the data or anything like that.</p> <p>As you can see below. I've tried explicitly using Virtualizing Stack Panel but that did not help much.</p> <p>Thank you for any help</p> <pre><code> &lt;DataTemplate x:Key="ComboboxItemTemplate"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Image Grid.RowSpan="3" Source="{Binding ImageURL, IsAsync=True}" Width="50" /&gt; &lt;TextBlock Grid.Column="1" Text="{Binding Name}" /&gt; &lt;TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Email}" /&gt; &lt;TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding CampusName}" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;ListView ItemsSource="{Binding MainList}" IsSynchronizedWithCurrentItem="True" Grid.RowSpan="2"&gt; &lt;ListView.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;VirtualizingStackPanel /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListView.ItemsPanel&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn Width="200" Header="Internal"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Name}" FontWeight="Bold" /&gt; &lt;TextBlock Text="{Binding MName}" /&gt; &lt;TextBlock Text="{Binding CampusName}" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn Width="200" Header="Contact1"&gt; &lt;GridViewColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;ComboBox ItemsSource="{Binding Source={StaticResource VM}, Path=ContactList, IsAsync=True}" SelectedValue="{Binding HisContactID}" SelectedValuePath="id" ItemTemplate="{StaticResource ComboboxItemTemplate}" Background="{Binding HisColor}" Margin="0,82,0,115" Grid.Row="1" Grid.Column="1"&gt; &lt;ComboBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;VirtualizingStackPanel /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ComboBox.ItemsPanel&gt; &lt;/ComboBox&gt; &lt;/DataTemplate&gt; &lt;/GridViewColumn.CellTemplate&gt; &lt;/GridViewColumn&gt; &lt;GridViewColumn Width="200" Header="Contact2"&gt; ... &lt;/GridViewColumn&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; </code></pre>
18,533,221
0
DelegateEvents: Child itemViews's not removed on deletion of model from collection <p>I've a collectionview ItineraryEditorView that is swapped in and out of a layout region. The same instance of collectionView is swapped in using region.show instead of creating new instance for collectioView everytime. The render method on the collection calls delegateEvents() method.</p> <pre><code> ItineraryEditorView = Marionette.CollectionView.extend({ tagName: "div", emptyView: EmptyItineraryDayView, itemView: ItineraryDayView, initialize: function (options) { }, render: function() { Marionette.CollectionView.prototype.render.apply(this); this.delegateEvents(); }, }); </code></pre> <p>The view is swapped out by closing region:</p> <pre><code>plannerLayout.itineraryEditorRegion.close(); </code></pre> <p>Swapping in the view:</p> <pre><code>itineraryEditorView.delegateEvents(); plannerLayout.itineraryEditorRegion.show(itineraryEditorView); </code></pre> <p>Deletion of a model is done by listening to the bubbled up event from itemView to collectionView (works, no issues here)</p> <pre><code>itineraryEditorView.on("itemview:delete:day", function(childView, model) { days.remove(model); //days coll is passed in to coll view on instance creation holiday.save(); }); </code></pre> <p>I'd expect that this would be enough to ensure the the child itemViews in the collection view are removed/closed when a model is removed from the underlying days collection. I can see that the collection is actually modified and and saved on the server,however the collection view is not altered. This scenario ofcourse works when before the collection view is swapped out first time. The coll. view does update itself after I re-visit another tab and come back to this tab (thus the entire collection is rendered- confirming the change/deletion)</p> <p>What is the best way get around this issue? If I recreate the instance of collection view, it does cause to loose other "on" handles in the code.</p>
23,807,810
0
<p>you can just do</p> <pre><code>std::ratio&lt;a,b&gt;::num </code></pre> <p>if you don't want to use typedef</p>
9,069,461
0
<p>In MATLAB, you can run</p> <pre><code>format debug </code></pre> <p>in the MATLAB Command Window to force it to display the variable as its memory location, rather than as its value. (This is an undocumented (AFAIK), but publicly known, option for the FORMAT function.)</p> <p>See HELP FORMAT to determine what your current display format is, and more importantly, how to restore it, once you're done looking at the memory locations.</p>
31,230,674
0
Using AsyncTask with timer in fragment <p>I'm using Asynctask to load data via Volley. I want to do that AsyncTask invoked after n minutes, maybe this is duplicate and a silly question, but i cant figure how to implement it. Maybe I need to implement AsyncTask in my fragment ?</p> <p>This is my AsyncTask.class</p> <pre><code>package com.aa.qc.task; import android.os.AsyncTask; import com.aa.qc.callbacks.ZleceniaLoadedListner; import com.aa.qc.extras.ZleceniaSorter; import com.aa.qc.extras.ZleceniaUtils; import com.aa.qc.network.VolleySingleton; import com.aa.qc.pojo.Zlecenia; import com.android.volley.RequestQueue; import java.util.ArrayList; public class TaskLoadZlecenia extends AsyncTask&lt;Void, Void, ArrayList&lt;Zlecenia&gt;&gt;{ private ZleceniaLoadedListner myComponent; private VolleySingleton volleySingleton; private RequestQueue requestQueue; private ZleceniaSorter mSorter = new ZleceniaSorter(); public TaskLoadZlecenia(ZleceniaLoadedListner myComponent) { this.myComponent = myComponent; volleySingleton = VolleySingleton.getsInstance(); requestQueue = volleySingleton.getmRequestQueue(); } @Override protected ArrayList&lt;Zlecenia&gt; doInBackground(Void... params) { ArrayList&lt;Zlecenia&gt; listZlecenias = ZleceniaUtils.loadZlecenia(requestQueue); mSorter.sortZleceniaByTime(listZlecenias); return listZlecenias; } @Override protected void onPostExecute(ArrayList&lt;Zlecenia&gt; listZlecenias) { if (myComponent != null) { myComponent.onZleceniaLoaded(listZlecenias); } } } </code></pre> <p>This is listner.class</p> <pre><code>package com.aa.qc.callbacks; import com.aa.qc.pojo.Zlecenia; import java.util.ArrayList; public interface ZleceniaLoadedListner { public void onZleceniaLoaded(ArrayList&lt;Zlecenia&gt; listZlecenias); } </code></pre> <p>This is my fragment where i want to repeat asynctask (I have activity with two tabs, each tabs is a fragment)</p> <pre><code>public class FragmentZlecenia extends Fragment implements SortListener, ZleceniaLoadedListner, SwipeRefreshLayout.OnRefreshListener { // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private ArrayList&lt;Zlecenia&gt; listZlecenias = new ArrayList&lt;&gt;(); private RecyclerView zleceniaArrived; private AdapterZlecenia adapterZlecenia; private SwipeRefreshLayout mSwipeRefreshLayout; private ZleceniaSorter mSorter = new ZleceniaSorter(); // TODO: Rename and change types of parameters private String mParam1; private String mParam2; /** * Use this factory method to create a new instance of * this fragment using the provided parameters. * * @param param1 Parameter 1. * @param param2 Parameter 2. * @return A new instance of fragment FragmentZlecenia. */ // TODO: Rename and change types and number of parameters public static FragmentZlecenia newInstance(String param1, String param2) { FragmentZlecenia fragment = new FragmentZlecenia(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } public FragmentZlecenia() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } public void onSortByTime() { L.t(getActivity(), "Sort by time"); mSorter.sortZleceniaByTime(listZlecenias); adapterZlecenia.notifyDataSetChanged(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View layout = inflater.inflate(R.layout.fragment_zlecenia, container, false); mSwipeRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipeZlecenia); mSwipeRefreshLayout.setOnRefreshListener(this); zleceniaArrived = (RecyclerView) layout.findViewById(R.id.listZlecenia); zleceniaArrived.setLayoutManager(new LinearLayoutManager(getActivity())); adapterZlecenia = new AdapterZlecenia(getActivity()); zleceniaArrived.setAdapter(adapterZlecenia); if (savedInstanceState != null) { //if this fragment starts after a rotation or configuration change, load the existing zlecenias from DB listZlecenias = MyApplication.getWritableDatabase().getAllZlecenia(); } else { //if this fragment starts for the first time, load the list of zlecenias from a database MyApplication.getWritableDatabase().deleteAll(); //if the database is empty, trigger an AsycnTask to download zlecenias list from the web if (listZlecenias.isEmpty()) { new TaskLoadZlecenia(this).execute(); } } //update your Adapter to containg the retrieved zlecenias adapterZlecenia.setListZlecenia(listZlecenias); return layout; } @Override public void onZleceniaLoaded(ArrayList&lt;Zlecenia&gt; listZlecenias) { L.m("onZleceniaLoaded Fragment"); new TaskLoadZlecenia(this).execute(); adapterZlecenia.setListZlecenia(listZlecenias); } @Override public void onRefresh() { L.t(getActivity(), "onRefresh"); new TaskLoadZlecenia(this).execute(); } } </code></pre>
40,505,891
0
<p>Dart2JS was indeed the culprit. Turning minification off and looking at the output Javascript reveals:</p> <pre><code>t2 = J.getInterceptor(selection); t1 = t2.toString$0(selection); </code></pre> <p>Manually replacing it after compiling with:</p> <pre><code>t1 = selection.toString(); </code></pre> <p>fixes the issue.</p> <p>I've reported the bug: <a href="https://github.com/dart-lang/sdk/issues/27789" rel="nofollow noreferrer">https://github.com/dart-lang/sdk/issues/27789</a></p>
1,552,943
0
<p>What specific problem are you encountering? Do you wish to get rid of the login page, and "automatically" use the user's AD credentials passed by IE? </p>
36,316,370
0
<p>Detailed guide for newbies like me. Took a long time to get it to work.</p> <p>I initially followed: <a href="http://php.net/manual/en/imagick.installation.php" rel="nofollow">http://php.net/manual/en/imagick.installation.php</a></p> <p>but after installation, PHPInfo under imagick shows number of supported formats = 0 </p> <p>So I followed these steps, clobbered from various sources to get it to work.</p> <ol> <li><p>Click PHPInfo and check:</p> <p>Architecture = x86 or x64</p> <p>Thread Safety = yes or no</p></li> <li><p>Download ImageMagick from:</p> <p><a href="http://windows.php.net/downloads/pecl/deps/" rel="nofollow">http://windows.php.net/downloads/pecl/deps/</a></p> <p>In my case I downloaded: ImageMagick-6.9.3-7-vc11-x86.zip</p> <p>because the Architecture under PHPInfo is x86</p> <p>as for vc11 or vc14</p> <p>search google for "visual c++ 11 runtime" or "visual c++ 14 runtime" and install it</p></li> <li><p>Unzip and copy all dlls from the bin subfolder to the Apache bin directory. It's a bunch of CORE_RL_<em>.dll and IM_MOD_RL_</em>.dll plus a few other dlls.</p> <p>In my case, I installed UwAmp in C:\UwAmp, so:</p> <p>(from zip) bin/*.dll --> C:\UwAmp\bin\apache\bin</p></li> <li><p>Goto:</p> <p><a href="http://pecl.php.net/package/imagick" rel="nofollow">http://pecl.php.net/package/imagick</a></p> <p>as of today, latest is 3.4.1 so I went to: <a href="http://pecl.php.net/package/imagick/3.4.1/windows" rel="nofollow">http://pecl.php.net/package/imagick/3.4.1/windows</a></p> <p>My PHP version is: 5.6.18, and Thread Safety is Yes from Step #1, so I downloaded:</p> <p>5.6 Thread Safe (TS) x86</p> <p>and got: php_imagick-3.4.1-5.6-ts-vc11-x86.zip</p></li> <li><p>Unzip and copy "php_imagick.dll" to the php extension folder:</p> <p>In my case: php_imagick.dll --> C:\UwAmp\bin\php\php-5.6.18\ext</p> <p>Note: this ZIP also contains dlls which other guides says to extract to the extension folder of apache. NO NEED TO DO IT. Step #3 has taken care of it.</p></li> <li><p>Edit "php.ini" and add:</p> <p>extension=php_imagick.dll</p> <p>or (I placed it at the very end):</p> <p>[Imagick]</p> <p>extension=php_imagick.dll</p> <p>For super newbies: click the edit button in the UwAmp UI, "php_uwamp.ini" will open and edit it. It will be copied to the correct php.ini when UwAmp is restarted. I had trouble at first since there are several php*.ini scattered all over.</p></li> <li><p>Restart Apache</p></li> <li><p>Check PHPInfo scroll to section (or find): imagick<br> number of supported formats: 234 (on mine)</p> <p>If there is no "imagick" section or "supported format" is 0, something went wrong.</p></li> </ol> <p>Hope this helps.</p> <p>BTW, the comment to the question by "Gras Double" works, just wish I had found it earlier.</p>
6,543,730
0
<p>Create a table with an autoicrement id and the columns of the original table.</p> <p>Then</p> <pre><code>INSERT INTO new_table (column1, column2,.....) -- refer all columns except autoincrement id SELECT * FROM old_table </code></pre> <p>Update the old table by joining with the new, assuming the is a key composite or not that distincts each row</p>
29,935,815
0
<pre><code>new Date("2015/04/29 11:24:00").getTime(); //for answer in milliseconds (new Date("2015/04/29 11:24:00").getTime()/1000); //to get answer in seconds </code></pre> <p>:)</p>
25,642,960
0
<p>You can make use of <code>dir.create</code> in conjunction with <code>paste</code> and <code>Sys.Date</code>, like this:</p> <pre><code>dir.create(paste("Test", Sys.Date(), sep = "_")) </code></pre> <p>If you want to change into that directory, I would suggest storing the output of <code>paste</code> as a character vector and using <code>setwd</code> after creating the new directory.</p> <p>Demo:</p> <pre><code>x &lt;- getwd() ## I'm going to demo in a tempdir setwd(tempdir()) list.dirs() # [1] "." # [2] "./downloaded_packages" # [3] "./rs-graphics-16e13b20-59b3-4ef3-bdcd-02852b1ea576" newdir &lt;- paste("Test", Sys.Date(), sep = "_") dir.create(newdir) setwd(newdir) list.dirs() # [1] "." # [2] "./downloaded_packages" # [3] "./rs-graphics-16e13b20-59b3-4ef3-bdcd-02852b1ea576" # [4] "./Test_2014-09-03" setwd(x) ## Reset to original working directory </code></pre> <hr> <p>You could always create a function like the following, but be careful of recursion!</p> <pre><code>Today &lt;- function(prefix = "Test") { newdir &lt;- paste(prefix, Sys.Date(), sep = "_") dir.create(newdir) setwd(newdir) } </code></pre> <p>This could be called simply with <code>Today()</code> and would create the necessary directory in whatever directory you're currently in and set your working directory to that new directory.</p>
2,512,629
0
<p>Are you sure your database is not set up to try to do cascading deletes?</p> <p>One other thing to check, crack open the .edmx file in the xml editor and see if you have a line like this that relates to the entity in question:</p> <pre><code>&lt;OnDelete Action="Cascade"&gt;&lt;/OnDelete&gt; </code></pre>
38,074,742
1
Built-in functions vs recursive functions <p>I am not a mathematician, nor a computer scientist - just a hobbyist programmer and I am trying to teach myself Python by doing the Euler Project problems. One of them requires the use of a factorial. I wrote my own calculation using a recursive function and then realised that there was probably a built-in function which I could use. Having found it I thought I would see how much quicker it was than my recursive function. To my surprise I find that it is actually slower.</p> <p>Does this surprise anyone? I am just curious.</p> <p>I enclose my code (and for good measure I have also included a loop method for an extra comparison).</p> <pre><code>import math import time x = 50 def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) secs = time.clock() print(math.factorial(x)) print ("The built-in function took {a:0.5f} seconds.".format(a = time.clock() - secs)) secs = time.clock() print (factorial(x)) print ("The recursive function took {a:0.5f} seconds.".format(a = time.clock() - secs)) secs = time.clock() factl = 1 for i in range (1,x+1): factl *= i print (factl) print ("The loop method took {a:0.5f} seconds.".format(a = time.clock() - secs)) </code></pre> <p>Output:</p> <p>30414093201713378043612608166064768844377641568960512000000000000</p> <p>The built-in function took 0.00549 seconds.</p> <p>30414093201713378043612608166064768844377641568960512000000000000</p> <p>The recursive function took 0.00299 seconds.</p> <p>30414093201713378043612608166064768844377641568960512000000000000</p> <p>The loop method took 0.00259 seconds.</p>
5,109,190
0
<p>You can use <a href="http://www.postgresql.org/docs/current/static/functions-admin.html">pg_terminate_backend()</a> to kill a connection. You have to be superuser to use this function. This works on all operating systems the same. </p> <pre><code>SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE -- don't kill my own connection! pid &lt;&gt; pg_backend_pid() -- don't kill the connections to other databases AND datname = 'database_name' ; </code></pre> <p>Before executing this query, you have to <a href="http://www.postgresql.org/docs/current/interactive/sql-revoke.html">REVOKE</a> the CONNECT privileges to avoid new connections:</p> <pre><code>REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, username; </code></pre> <blockquote> <p>If you're using Postgres 8.4-9.1 use procpid instead of pid</p> </blockquote> <pre><code>SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE -- don't kill my own connection! procpid &lt;&gt; pg_backend_pid() -- don't kill the connections to other databases AND datname = 'database_name' ; </code></pre>
3,877,198
0
how to dice up the array <p>I have an array like this (below is the var_dump)</p> <pre><code>array 0 =&gt; object(stdClass)[11] public 'VN' =&gt; string '571.5' (length=5) public 'color' =&gt; string 'GREEN' (length=5) public 'name' =&gt; string 'CIRRHOSIS' (length=9) public 'icd9ID' =&gt; string '5765' (length=4) public 'ID' =&gt; string '46741' (length=5) 1 =&gt; object(stdClass)[12] public 'VN' =&gt; string '571.5' (length=5) public 'color' =&gt; string 'GREEN' (length=5) public 'name' =&gt; string 'CIRRHOSIS' (length=9) public 'icd9ID' =&gt; string '5765' (length=4) public 'sortOrder' =&gt; string '1' (length=1) public 'ID' =&gt; string '46742' (length=5) 2 =&gt; object(stdClass)[15] public 'VN' =&gt; string 'V58.69' (length=6) public 'color' =&gt; string 'ORANGE' (length=6) public 'name' =&gt; string 'Long-term (current) use of other medications' (length=44) public 'icd9ID' =&gt; string '15116' (length=5) public 'ID' =&gt; string '46741' (length=5) 3 =&gt; object(stdClass)[14] public 'VN' =&gt; string '070.32' (length=6) public 'color' =&gt; string 'GREEN' (length=5) public 'name' =&gt; string 'HEPATITIS B CHRONIC' (length=19) public 'icd9ID' =&gt; string '14463' (length=5) public 'ID' =&gt; string '46742' (length=5) 4 =&gt; object(stdClass)[13] public 'VN' =&gt; string '070.32' (length=6) public 'color' =&gt; string 'GREEN' (length=5) public 'name' =&gt; string 'HEPATITIS B CHRONIC' (length=19) public 'icd9ID' =&gt; string '14463' (length=5) public 'ID' =&gt; string '46741' (length=5) </code></pre> <p>I want to two HTML tables. One that will carry all the same ID and second one will carry the other ID</p> <p>How can I do that Thanks!</p>
21,977,347
0
<p>You need to ask your fellow developers or repository administrator what your repository location is. You should already have the project checked out, in which case you are already using a working copy that is linked to it and you don't need to do any more to point at the right location.</p> <p>As for how to add an item, that will depend on what client you're using. In Subclipse, it's Team -> Add. In TortoiseSVN, it's TortoiseSVN -> Add. On the command line, it's <code>svn add &lt;filename&gt;</code></p> <p>It sounds like you have no experience with Subversion. You would do well to <a href="http://svnbook.org/" rel="nofollow">read the fine manual</a> before you get yourself into trouble.</p>
29,751,859
0
Laravel 5 hasMany relationship on two columns <p>Is it possible to have a hasMany relationship on two columns?</p> <p>My table has two columns, <code>user_id</code> and <code>related_user_id</code>.</p> <p>I want my relation to match either of the columns.</p> <p>In my model I have </p> <pre><code>public function userRelations() { return $this-&gt;hasMany('App\UserRelation'); } </code></pre> <p>Which runs the query: <code>select * from user_relations where user_relations.user_id in ('17', '18')</code>.</p> <p>The query I need to run is: </p> <pre><code>select * from user_relations where user_relations.user_id = 17 OR user_relations.related_user_id = 17 </code></pre> <p><strong>EDIT:</strong></p> <p>I'm using eager loading and I think this will affect how it will have to work.</p> <pre><code>$cause = Cause::with('donations.user.userRelations')-&gt;where('active', '=', 1)-&gt;first(); </code></pre>
23,832,876
0
Adding an entity to the context <p>Why is this simple add not working! I get a previous record from the database, instantiate a new entity to add by using the previous record's data, except I increment the report number by 1. I keep getting the error "The property 'ReportNbr' is part of the primary key and cannot be modified." I thought this error was when you tried to update an existing entities' primary key field.</p> <p>Here's my object and previous record that I use.</p> <pre><code>var previousRecord = _repo.GetLatestRecord(); var recordToAdd = new Record() { Year = previousRecord.Year, Month = previousRecord.Month, ReportNbr = ++previousRecord.ReportNbr, ...//other info }; _repo.AddRecord(recordToAdd); </code></pre> <p>The three fields show are the primary key to the table. Any help would be greatly appreciated.</p>
30,529,537
0
<p>I ran into a similar problem once. What you can try is like </p> <pre><code>var cssLink = document.createElement("link") cssLink.href = "style.css"; cssLink .rel = "stylesheet"; cssLink .type = "text/css"; window.frames[0].document.body.appendChild(cssLink); </code></pre> <p>Try this out it may help you though i'm not sure but it worked for me. Where the style.css is the css file where you specify your styling for the frame</p>
32,298,993
0
<p>You have to use <code>providers</code> instead of <code>injectables</code></p> <pre class="lang-ts prettyprint-override"><code>@Component({ selector: 'my-app', providers: [NameService] }) </code></pre> <p><a href="https://github.com/Mellbourn/angular2-step-by-step-guide">Complete code sample here</a>.</p>
27,567,050
0
<p>Do you play your music in Service? Anyway, you should stop the playing manually in onStop method.</p>
35,105,947
0
Answer Set Programming: Group into two sets so that those who like each other are in same set, and dislike = different set <p>I'm basically a beginner to Answer Set Programming (CLINGO), so I've been attempting this problem for hours now. </p> <p>person(a;b;c;d;e;f).</p> <p>likes(b,e; d,f).</p> <p>dislikes(a,b; c,e).</p> <p>People who like each other must be in the same set, and cannot be in the same set as someone they dislike. So the output should be: b,e | a, c, d,f</p> <p>I know the logic behind it; partition it so that if an element is in both likes &amp; dislikes, then it should be in its own set, and everything else in the other. But this is declarative programming, so I'm not sure how to tackle this. Any help would be appreciated.</p>
15,523,386
0
<p>Note:</p> <ol> <li>Use getElementsByTagName</li> <li>There is no documentList tag in your xml</li> <li><p>Tag document is the only array in your xml not document_list</p> <pre><code>function viewXMLFiles() { console.log("viewXMLFiles() is running"); xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET","TestInfo.xml",false); xmlhttp.send(); xmlDoc = xmlhttp.responseXML; console.log("still running"); var getData = xmlDoc.getElementsByTagName("document"); console.log("getting tired"); document.getElementById("documentList").innerHTML = getData[0].getElementsByTagName("document_name")[0].childNodes[0].nodeValue; document.getElementById("documentList1").innerHTML = getData[1].getElementsByTagName("document_name")[0].childNodes[0].nodeValue; console.log("done"); } </code></pre></li> </ol> <p>Add one more span with id documentList1 to execute the above code</p>
11,707,681
0
<p>Well this was an interesting problem and kept me guessing for a while... </p> <p>I wasn't able to derive the logic first but then I switched back to basics and derived the <code>boolean expression</code> for calculation the sum &amp; carry for a 3 bit operation and here is the solution:</p> <pre><code>public static BitSet addBitSet(int n, List&lt;BitSet&gt; bitSetList){ BitSet sumBitSet = new BitSet(n); for (BitSet firstBitSet : bitSetList) { BitSet secondBitSet = (BitSet) sumBitSet.clone(); System.out.println("A: " + printBitSet(firstBitSet, 6)); System.out.println("B: " + printBitSet(secondBitSet, 6)); boolean carryForNext = false, sum,a,b,c; for (int i = n - 1; i &gt;= 0; i--) { a=firstBitSet.get(i); b=secondBitSet.get(i); c=carryForNext; sum = a&amp;!b&amp;!c|!a&amp;!b&amp;c|!a&amp;b&amp;!c|a&amp;b&amp;c; carryForNext = a&amp;b&amp;!c|a&amp;!b&amp;c|!a&amp;b&amp;c|a&amp;b&amp;c; sumBitSet.set(i,sum); } System.out.println("SUM:" + printBitSet(sumBitSet, 6)); } System.out.println(printBitSet(sumBitSet, 6)); return sumBitSet; } </code></pre> <p>and here is the code for <code>printBitSet</code>:</p> <pre><code>public static String printBitSet(BitSet bitSet, int size) { StringBuilder builder = new StringBuilder(""); for (int i = 0; i &lt; size; i++) { if (bitSet.get(i)) builder.append("1"); else builder.append("0"); } return builder.toString(); } </code></pre>
3,967,202
0
Storing log into .log file using SLF4j/log4j <p>I am using SLF4J and as per requirement i have to store the logs into the .log file. But when i run the program the log are not written into thelog file. </p> <p>Class :</p> <pre><code>import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TestSLF4J { // private static Logger _logger = LoggerFactory.getLogger(TestSLF4J.class); private static Logger _logger = LoggerFactory.getLogger(TestSLF4J.class); public static void main(String[] args) { logger .debug("Sample debug message"); logger .info("Sample info message"); logger .warn("Sample warn message"); logger .error("Sample error message"); } } </code></pre> <p>log4j.properties</p> <pre><code>log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.maxFileSize=100KB log4j.appender.file.maxBackupIndex=5 log4j.appender.file.File=C:/checkLog.log log4j.appender.file.threshold=DEBUG log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n log4j.rootLogger=DEBUG,file </code></pre> <p>i can see info,warn,error on console but not debug value..!!</p> <p>Can anyone help me store log into the checkLog.log file.??</p>
35,455,526
0
Disable button when there are validation errors in listbox datatemplate <p>I have listbox with list of textboxes created using data template, And I want to disable save button when there are validation errors in listbox datatemplate(list of textboxes). I have used IDataErrorInfo for validation.</p> <pre><code>&lt;Style x:Key="ButtonStyle" TargetType="{x:Type Button}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding ElementName=errorList, Path=(Validation.HasError)}" Value="True"&gt; &lt;Setter Property="IsEnabled" Value="False"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; </code></pre> <p></p>
24,335,677
0
<p>Can you supply a dropbox link to one of the images so I can see what you mean? Do you mean you have one scan of 4 images all on the same layer, and you need to crop 4x and resave individual images? Or is each image on its own layer?</p> <p>Are the 100 images all exactly the same layout? If so, you may be able to create an action that would cut down on your time.</p> <p>If the images are on separate layers, you can use File > Scripts > Export Layers to files...</p>
36,279,537
0
<p>There's a Jenkins plugin precisely for this matter: <a href="https://wiki.jenkins-ci.org/display/JENKINS/Plugin+Usage+Plugin+%28Community%29" rel="nofollow noreferrer">Plugin Usage</a></p> <p>Thanks to this wonderful plugin I found many redundant plugins to remove in the Plugin Manager (you will be able to remove plugins that has no dependencies).</p> <p>Here's how it looks - the plugin interface has a link on Jenkins sidebar. It lists all the plugins which any of an existing job uses (pressing on the expend button to see jobs names):</p> <p><a href="https://i.stack.imgur.com/y42oh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y42oh.png" alt="enter image description here"></a></p>
22,047,775
0
Move of class with pimpl won't compile <p>In the following example, how is it possible that ~CImpl is called correctly but when the class needs to be moved, the compiler says it has an incomplete type?</p> <p>If the declaration of Impl is moved to the header it works, my question is how come the destructor is called fine so it doesn't seem that the type is incomplete, but the problem appears when moving.</p> <p>file: C.hpp</p> <pre><code>#include &lt;memory&gt; class Impl; class C { public: C(); ~C(); C(C&amp;&amp;) = default; C&amp; operator=(C&amp;&amp;) = default; std::unique_ptr&lt;Impl&gt; p; }; </code></pre> <p>file C.cpp</p> <pre><code>#include "C.hpp" #include &lt;iostream&gt; using namespace std; class Impl { public: Impl() {} virtual ~Impl() = default; virtual void f() = 0; }; class CImpl: public Impl { public: ~CImpl() { cout &lt;&lt; "~CImpl()" &lt;&lt; endl; } void f() { cout &lt;&lt; "f()" &lt;&lt; endl; } }; C::C(): p(new CImpl()) {} C::~C() </code></pre> <p>file: main.cpp</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include "C.hpp" using namespace std; int main(int argc, char *argv[]) { vector&lt;C&gt; vc; // this won't compile //vc.emplace_back(C()); C c; C c2 = move(c); // this won't compile } </code></pre> <p>Compiler output:</p> <pre><code>+ clang++ -std=c++11 -Wall -c C.cpp + clang++ -std=c++11 -Wall -c main.cpp In file included from main.cpp:3: In file included from ./C.hpp:1: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/memory:80: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:65:16: error: invalid application of 'sizeof' to an incomplete type 'Impl' static_assert(sizeof(_Tp)&gt;0, ^~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:184:4: note: in instantiation of member function 'std::default_delete&lt;Impl&gt;::operator()' requested here get_deleter()(__ptr); ^ ./C.hpp:12:5: note: in instantiation of member function 'std::unique_ptr&lt;Impl, std::default_delete&lt;Impl&gt; &gt;::~unique_ptr' requested here C(C&amp;&amp;) = default; ^ ./C.hpp:3:7: note: forward declaration of 'Impl' class Impl; ^ 1 error generated. </code></pre>
37,657,907
0
<p>You can get the hashtable as javascript object with this snippet:</p> <pre><code>&lt;script type="text/javascript"&gt; var hashtable = @Html.Raw(Json.Encode(Model.YourHashtable) &lt;/script&gt; </code></pre> <p>After that you will be able to access your data by value:</p> <pre><code>hashtable["sample"] </code></pre>
34,413,478
0
<p>FlipView is a Windows Store/Universal App only class.</p> <p>The page you link to clearly states:</p> <blockquote> <p>Requirements (Windows 10 device family)</p> <p><strong>Device family</strong> Universal</p> </blockquote> <p>and</p> <blockquote> <p>Requirements (Windows 8.x and Windows Phone 8.x)</p> <p><strong>Minimum supported client</strong> Windows 8 [Windows Store apps only]</p> </blockquote> <p>If you want to have the same functionality in a WPF desktop application you will need to either find a third party control that does the same or write your own.</p>
25,505,286
0
Hive : How to execute a query from a file and dump the output in hdfs <p>I can execute a query from a sql file and store the output in a local file using </p> <pre><code>hive -f /home/Prashasti/test.sql &gt; /home/Prashasti/output.csv </code></pre> <p>Also, I can store the output of a hive query in hdfs using :</p> <pre><code>insert overwrite directory 'user/output' select * from folders; </code></pre> <p>Is there any way I can run the query from a sql file and store the output in hdfs too?</p>
9,979,233
0
Could I export class names and package names into csv file? (java) <p>I have one java project in netBeans. There are some packages, and classes in that packages. Can I export this structure to csv?</p> <p>Example of csv:</p> <p>myPackage1,MyClass1;</p> <p>myPackage1,MyClass2;</p> <p>I would be more pleased if I can put parameters in constructors or voids into that csv.</p> <p>Thank you for ideas.</p> <p>EDIT: If there are applications that are able to do reverse engineering to class diagram, there must be some easy way how to do it.</p>
31,531,967
0
<p>Found the answer and put it here for reference.</p> <p>My requestFocus() action on the JTable did indeed leave selection on the right row, but without any selection of the (single) column. Even when running as normal (not testing) the JTable column did not initially respond to F2. It was puzzling to me why the cell was not initially surrounded by a heavy black border. The answer was therefore to put this line after the requestFocus line:</p> <pre><code>dates_table.setColumnSelectionInterval( 0, 0 ) </code></pre>
18,424,940
0
malloc:what can "corrupt" allocated memory in Linux/Qt application (threads involved)? <p><em>Dirty hacks at 05:00 AM. I have sinned, SO</em>, by passing pointer's address between same process's threads with FIFO:</p> <pre><code>total_buf = (char*)malloc(msize); // ... long addr = (long)&amp;total_buf; // ... write(fifo, buf, 128); </code></pre> <p>After receiving pointer to total_buf in receiver thread, <code>void* pt = (void*)addr;char* tbuf = (char*)pt;</code> I noticed that buffer content changed, and that was clearly confirmed by examining memory content: <code>(gdb) x/1024xb tbuf</code>.</p> <p>What are possible reasons for this to happen - in a context of multithreaded Qt+pure pthreads application's plugins trying to communicate directly? For some reason, I feel it's not some obvious garbage collection and afair, Linux threads are using shared process memory, so it's no address mismatch, and the pointer dereference looks alright too,.</p>
30,140,741
0
<p>Do we really need to convert?</p> <pre><code>SELECT * FROM DBO.CUSTOMER WHERE CAST([date] AS DATE) &gt;= '01/12/2014' AND CAST([date] AS DATE) &lt;= '31/12/2014' </code></pre>
12,451,996
0
<p>I'd have the entire content in an <code>article</code>, with each book in a <code>section</code>. </p> <p>This would make it extremely consistent with the third <a href="http://www.w3.org/TR/html5/the-section-element.html#the-section-element" rel="nofollow">section example given by the W3C</a> </p>
30,748,306
0
How to edit the link of a variable in opencart register.tpl file? <p>Here is the code of register.tpl file. The variable is called and this $action variable called the account/login.php file how to I can change the link of $action variable.</p> <pre><code>&lt;form action="&lt;?php echo $action; ?&gt;" method="post" enctype="multipart/form-data"&gt; &lt;h2&gt;&lt;?php echo $text_your_details; ?&gt;&lt;/h2&gt; &lt;div class="content"&gt; &lt;table class="form"&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="required"&gt;*&lt;/span&gt; &lt;?php echo $entry_firstname; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="firstname" value="&lt;?php echo $firstname; ?&gt;" /&gt; &lt;?php if ($error_firstname) { ?&gt; &lt;span class="error"&gt;&lt;?php echo $error_firstname; ?&gt;&lt;/span&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="required"&gt;*&lt;/span&gt; &lt;?php echo $entry_lastname; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="lastname" value="&lt;?php echo $lastname; ?&gt;" /&gt; &lt;?php if ($error_lastname) { ?&gt; &lt;span class="error"&gt;&lt;?php echo $error_lastname; ?&gt;&lt;/span&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="required"&gt;*&lt;/span&gt; &lt;?php echo $entry_email; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="email" value="&lt;?php echo $email; ?&gt;" /&gt; &lt;?php if ($error_email) { ?&gt; &lt;span class="error"&gt;&lt;?php echo $error_email; ?&gt;&lt;/span&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="required"&gt;*&lt;/span&gt; &lt;?php echo $entry_telephone; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="telephone" value="&lt;?php echo $telephone; ?&gt;" /&gt; &lt;?php if ($error_telephone) { ?&gt; &lt;span class="error"&gt;&lt;?php echo $error_telephone; ?&gt;&lt;/span&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre>
28,335,868
0
<p><strong>Short answer:</strong> none, but you may feel like it is taking a few milliseconds depending on your processor speed and the amount of things angular need to check before it updates the HTML</p> <p><strong>Long answer:</strong> As soon as you update the model (well, at the end of the current javascript context), Angular will execute a digest cycle on which it will process all the $watchers (in this case <code>{{text}}</code> is a watcher over the <code>text</code> property). If a watcher has a different value than last time, it will run a new digest cycle, and so on, until all watchers are stable. Then it will process the HTML and updates all value, before the browser finally render the view. Hence from a "machine" point of view, it is immediate as in the same execution context: your browser will not render anything in between.</p> <p>Now if your code is asynchronous (like a call to some server), that "immediaticity" I have been talking about starts from the latest call to <code>$scope.$apply</code></p>