pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
31,289,958
0
auto fix errors when removing a user control property <p>When I remove a user control property that I have created and used in a project. There will be as many errors as times I have used control in project. For example imagine I have user control and it has a property named <code>p1</code>. when I remove <code>p1</code> I get errors saying myusercontrol.p1 doesn't exist. </p> <p>Is there a way to get rid of them automatically?</p>
35,638,617
0
<p>You code is not formatted with indents, so this may be wrong.</p> <p>I suspect your indentation results in <code>if j in screen:</code> running after the <code>for j...</code> loop, not in it. Also, read the definition of <code>pass</code>.</p>
36,789,589
0
<p>As far as I understand, you don't need to use <code>Semaphore</code> here. Instead, you should use <code>ReentrantReadWriteLock</code>. Additionally, the <code>test</code> method is not thread safe. </p> <p>The sample below is the implementation of your logic using RWL</p> <pre><code>private ConcurrentMap&lt;String, ReadWriteLock&gt; map = null; void test() { String hash = null; ReadWriteLock rwl = new ReentrantReadWriteLock(false); ReadWriteLock lock = map.putIfAbsent(hash, rwl); if (lock == null) { lock = rwl; } if (lock.writeLock().tryLock()) { try { compute(); map.remove(hash); } finally { lock.writeLock().unlock(); } } else { lock.readLock().lock(); try { compute(); } finally { lock.readLock().unlock(); } } } </code></pre> <p>In this code, the first successful thread would acquire <code>WriteLock</code> while other <code>Thread</code>s would wait for release of write lock. After release of a <code>WriteLock</code> all <code>Thread</code>s waiting for release would proceed concurrently.</p>
12,090,560
0
<p>According to <a href="http://msdn.microsoft.com/en-us/library/hh180779%28v=vs.95%29.aspx?ppud=4" rel="nofollow">this</a> article you must set <code>[MediaStreamAttributeKeys.CodecPrivateData]</code></p> <p>in the format that codec is expecting ([START_CODE][SPS][START_CODE][PPS])</p> <pre><code>videoStreamAttributes[MediaStreamAttributeKeys.CodecPrivateData] = "000000012742000D96540A0FD8080F162EA00000000128CE060C88"; </code></pre>
721,811
0
Excel VBA - Initializing Empty User Types and Detecting Nulls <p>I have created a user defined type to contain some data that I will use to populate my form. I am utilizing an array of that user defined type, and I resize that array as I pull data from an off-site server.</p> <p>In order to make my program easier to digest, I have started to split it into subroutines. However, when my program is initialized, I cannot tell when a particular array has been initialized, and so I cannot be certain that I can call a size function to see if the array is empty.</p> <p>Is there a way to initialize an empty user type or detect a null user type? Currently, I am hard-coding it in and I would prefer a more elegant solution.</p>
22,040,153
0
<p>I'd use a <code>Timer</code> object.</p> <p>There's a full example:</p> <pre><code>public class TimerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MyTimerTask myTask = new MyTimerTask(); Timer myTimer = new Timer(); myTimer.schedule(myTask, 3000, 1500); } // In this class you'd define an instance of your `AsyncTask` class MyTimerTask extends TimerTask { MyAsyncTask atask; final class MyAsyncTask extends AsyncTask&lt;Param1, Param2, Param3&gt; { // Define here your onPreExecute(), doInBackground(), onPostExecute() methods // and whetever you need ... } public void run() { atask = new MyAsyncTask&lt;Param1, Param2, Param3&gt;(); atask.execute(); } } } </code></pre>
34,570,311
0
does not change the options <p>I'm trying to make the options to search by company name or identification of the company with the options on rails. I'm using it with simple_form, someone can help me to choose the options.</p> <p>the line number is 60 which says : <code>&lt;%= f.collection_radio_buttons :options, [['C', 'CLIENTE'] ,['R', 'RUC']], :first, :last %&gt;</code></p> <pre><code>&lt;%= simple_form_for(@referral_guide) do |f| %&gt; &lt;%= f.error_notification %&gt; &lt;div class="form-inputs"&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="450px"&gt;&lt;%=h f.input :fecha, label: 'Fecha de Emisión' %&gt;&lt;/th&gt; &lt;th class="text-center" width="450px"&gt;&lt;%=h f.input :fecha_vencimiento, label: 'Fecha de Vencimiento' %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="900px"&gt;&lt;strong&gt;La Guia de Remisión incluye Impuesto (Se genera en caso la Factura) ? : &lt;/strong&gt;&lt;%= f.collection_radio_buttons :impuesto, [['S', 'Si'], ['N', 'No']], :first, :last %&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="150px"&gt;&lt;%=h f.input :moneda, collection: ["S/.", "US$"], label: 'Tipo de Moneda', :input_html =&gt; { :style =&gt; 'width: 80'} %&gt; &lt;/th&gt; &lt;th class="text-center" width="200px"&gt;&lt;%=h f.input :costo, label: 'Costo mínimo', :input_html =&gt; { :style =&gt; 'width: 190' } %&gt;&lt;/th&gt; &lt;th class="text-center" width="200px"&gt;&lt;%=h f.association :status, :input_html =&gt; { :style =&gt; 'width: 180'} %&gt;&lt;/th&gt; &lt;th class="text-center" width="320px"&gt;&lt;%=h f.input :orden_compra, label: 'Orden de Compra', :input_html =&gt; { :style =&gt; 'width: 240' } %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="450px"&gt;&lt;%=h f.association :sale, label: 'Vendedor', :input_html =&gt; { :style =&gt; 'width: 420px'},label_method: "#{:nombre}", value_method: :id %&gt;&lt;/th&gt; &lt;th class="text-center" width="450px"&gt;&lt;%= f.association :motivo, label: 'Motivo de Traslado', label_method: "#{:nombre}", value_method: :id, :input_html =&gt; {:style =&gt; 'width: 420px'} %&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="225px"&gt;&lt;%=h f.input :marca_placa, label: 'Marca y Número de Placa', :input_html =&gt; { :style =&gt; 'width: 200px' }%&gt; &lt;/th&gt; &lt;th class="text-center" width="225px"&gt;&lt;%=h f.input :numero_constancia, label: 'Número de Constancia de Inscripción', :input_html =&gt; { :style =&gt; 'width: 200px' } %&gt;&lt;/th&gt; &lt;th class="text-center" width="225px"&gt;&lt;%=h f.input :numero_licencia, label: 'Número de Licencia', :input_html =&gt; { :style =&gt; 'width: 200px' } %&gt;&lt;/th&gt; &lt;th class="text-center" width="225px"&gt;&lt;%=h f.input :chofer, label: 'chofer', :input_html =&gt; { :style =&gt; 'width: 200px' } %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="300px"&gt;&lt;%=h f.input :nombre_transporte, label: 'Nombre de la empresa de Transportes', :input_html =&gt; { :style =&gt; 'width: 250px' } %&gt; &lt;th class="text-center" width="300px"&gt;&lt;%=h f.input :ruc_transporte, label: 'Ruc de la empresa de Transportes', :input_html =&gt; { :style =&gt; 'width: 250px' } %&gt; &lt;th class="text-center" width="300px"&gt;&lt;%=h f.input :chofer_transporte, label: 'Chofer de la empresa de Transportes', :input_html =&gt; { :style =&gt; 'width: 250px' } %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table&gt; &lt;tr&gt; &lt;th class="text-center" width="600px"&gt;&lt;%=h f.association :customer, label_method: "#{:nombre}", value_method: :id, prompt: "Debes buscar el nombre de la empresa", label: 'Empresa', :input_html =&gt; { :style =&gt; 'width: 550px' } %&gt; &lt;/th&gt; &lt;th class="text-center" width="300px"&gt;&lt;%=h f.association :customer, label_method: "#{:ruc}", value_method: :id, prompt: "Debes buscar el ruc de la empresa", label: 'RUC', :input_html =&gt; { :style =&gt; 'width: 250px' } %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Debe Seleccionar las opciones para buscar el nombre o ruc del cliente&lt;/strong&gt;&lt;/p&gt; &lt;%= f.collection_radio_buttons :options, [['C', 'CLIENTE'] ,['R', 'RUC']], :first, :last %&gt; &lt;% if f.object.options == 'C' %&gt; &lt;%=h f.association :customer, label_method: "#{:nombre}", value_method: :id, prompt: "Debes buscar el nombre de la empresa", label: 'Empresa', :input_html =&gt; { :style =&gt; 'width: 550px' } %&gt; &lt;% else %&gt; &lt;%=h f.association :customer, label_method: "#{:ruc}", value_method: :id, prompt: "Debes buscar el ruc de la empresa", label: 'RUC', :input_html =&gt; { :style =&gt; 'width: 250px' } %&gt; &lt;% end %&gt; &lt;%=h f.input :numero_factura, label: 'Ingresar el Numero de Factura que vas a generar, si no desea generar, poner cero', :input_html =&gt; { :style =&gt; 'width: 250px' } %&gt; &lt;div&gt; &lt;table id="items"&gt; &lt;tr&gt; &lt;th class="text-center" width="60px"&gt;ITEM&lt;/th&gt; &lt;th class="text-center" width="225px"&gt;DESCRIPCION&lt;/th&gt; &lt;th class="text-center" width="100px"&gt;CANTIDAD&lt;/th&gt; &lt;th class="text-center" width="110px"&gt;PRECIO&lt;/th&gt; &lt;th class="text-center" width="150px"&gt;TOTAL&lt;/th&gt; &lt;th class="text-center" width="63px"&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;% @totales = 0.00 %&gt; &lt;%= simple_nested_form_for @referral_guide, :wrapper =&gt; false do |g| %&gt; &lt;table id="detail_referral_guides"&gt; &lt;%= g.simple_fields_for :detail_referral_guides do |p| %&gt; &lt;tr class="fields"&gt; &lt;th align="center" width="74px" class="text-center"&gt;&lt;%= p.input :item, label: false %&gt;&lt;/th&gt; &lt;th align="center" width="276px" class="description"&gt;&lt;%= p.input :description, label: false, input_html: {:rows =&gt; 3} %&gt;&lt;/th&gt; &lt;th align="center" width="123px" class="text-center"&gt;&lt;%= p.input :cantidad, label: false %&gt;&lt;/th&gt; &lt;th align="center" width="135px" class="text-right"&gt;&lt;%= p.input :precio, label: false %&gt;&lt;/th&gt; &lt;% @total_price = p.object.cantidad.to_s.to_d * p.object.precio.to_s.to_d %&gt; &lt;th align="right" width="184px" class="text-right"&gt;&lt;%= number_with_precision(@total_price, :delimiter =&gt; ',', :separator =&gt; '.' ) %&gt;&lt;/th&gt; &lt;th align="center" width="77px" class="text-center"&gt;&lt;%= p.link_to_remove "", class: "btn btn-danger fa fa-trash" %&gt;&lt;/th&gt; &lt;% @totales = @totales + @total_price %&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;/table&gt; &lt;% if f.object.impuesto == 'S' %&gt; &lt;% @valor_venta = @totales / (1 + ( @empresa.impuesto / 100.00)) %&gt; &lt;% @valor_igv = @valor_venta * (@empresa.impuesto / 100.00) %&gt; &lt;% @valor_totales = @totales %&gt; &lt;% else %&gt; &lt;% @valor_venta = @totales %&gt; &lt;% @valor_igv = @totales * (@empresa.impuesto / 100.00) %&gt; &lt;% @valor_totales = @valor_venta + @valor_igv %&gt; &lt;% end %&gt; &lt;table id="items"&gt; &lt;tr&gt; &lt;th width="700px"&gt;&lt;/th&gt; &lt;th class="text-center" width="110px"&gt;VALOR DE VENTA : &lt;/th&gt; &lt;th class="text-right" width="150px"&gt;&lt;%= number_with_precision(@valor_venta, :delimiter =&gt; ',', :separator =&gt; '.') %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th width="700px"&gt;&lt;/th&gt; &lt;th class="text-center" width="110px"&gt;I.G.V. : &lt;/th&gt; &lt;th class="text-right" width="150px"&gt;&lt;%= number_with_precision(@valor_igv, :delimiter =&gt; ',', :separator =&gt; '.') %&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th width="700px"&gt;&lt;/th&gt; &lt;th class="text-center" width="110px"&gt;TOTAL : &lt;/th&gt; &lt;th class="text-right" width="150px"&gt;&lt;div class="due"&gt;&lt;/div&gt; &lt;%= number_with_precision(@valor_totales, :delimiter =&gt; ',', :separator =&gt; '.') %&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;% if f.object.impuesto == 'S' %&gt; &lt;p&gt;&lt;strong&gt;LOS PRECIOS OFERTADOS ESTAN INCLUIDOS I.G.V.&lt;/strong&gt;&lt;/p&gt; &lt;% else %&gt; &lt;p&gt;&lt;strong&gt;LOS PRECIOS OFERTADOS NO ESTAN INCLUIDOS I.G.V.&lt;/strong&gt;&lt;/p&gt; &lt;% end %&gt; &lt;br&gt;&lt;br&gt; &lt;p&gt;&lt;%= g.link_to_add "Adicionar Producto", :detail_referral_guides, :data =&gt; { :target =&gt; "#detail_referral_guides" }, class: "btn btn-primary" %&gt;&lt;/p&gt; &lt;div class="form-actions"&gt; &lt;%= f.button :submit %&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre>
27,045,735
0
<p>The Implicit Grant Type is being seen by many (lucadegasperi's oauth2-server-laravel among others) as the least secure of the OAuth2 grant types, therefore I recommend you to use JWT for your service website instead.</p> <p>To integrate JWT with Laravel, have a look at the following library. It works very well, and is also supported by the popular out-of-the-box API package Dingo for Laravel (<a href="https://github.com/dingo/api" rel="nofollow">https://github.com/dingo/api</a>):</p> <ul> <li><a href="https://github.com/tymondesigns/jwt-auth" rel="nofollow">https://github.com/tymondesigns/jwt-auth</a></li> </ul> <p>As for the app(s), if the app is a first-party app, go for the OAuth2 password grant as mentioned by Florens Morselli. If it is third-party app, use the authorization code grant instead.</p>
37,466,112
0
<p>I was able to get this to work by adding my custom class to the Entity Framework model (even though it does not have a table). I think it was easier with the a code model. I don't know if it would have been doable with a design model (edmx).</p> <p>This link got me started:</p> <p><a href="http://breeze.github.io/doc-js/metadata-with-ef.html" rel="nofollow">http://breeze.github.io/doc-js/metadata-with-ef.html</a></p>
21,298,408
0
Trying to get two buttons remained in the status column of a grid <p>I'm trying to place a couple of buttons under the Status column as per screenshot.</p> <p>Here's my HTML code below( the picture)</p> <p><img src="https://i.stack.imgur.com/9OKXq.png" alt="enter image description here"></p> <pre><code>&lt;div class="table_heading_row"&gt; &lt;div class="table_column" style="width: 100px;"&gt; Leave Type &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; Total Count &lt;/div&gt; &lt;div class="table_column" style="width: 150px;"&gt; Start Date &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; End Date &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; Status &lt;/div&gt; &lt;/div&gt; &lt;div class="table_row 1"&gt; &lt;div class="table_column" style="width: 100px;"&gt; Sick Leave &lt;/div&gt; &lt;div class="table_column" style="width: 150px;"&gt; 2 Days &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; 2.8.2013 &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; 3.8.2013 &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; Rejected &lt;/div&gt; &lt;/div&gt; &lt;div class="table_row 2"&gt; &lt;div class="table_column" style="width: 100px;"&gt; Sick Leave &lt;/div&gt; &lt;div class="table_column" style="width: 150px;"&gt; 3 days &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; 6.3.2014 &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; 8.3.2014 &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; Rejected &lt;/div&gt; &lt;/div&gt; &lt;div class="table_row 3"&gt; &lt;div class="table_column" style="width: 100px;"&gt; Annual Leave &lt;/div&gt; &lt;div class="table_column" style="width: 150px;"&gt; 13 days &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; 6.3.2014 &lt;/div&gt; &lt;div class="table_column" style="width: 100px;"&gt; 8.3.2014 &lt;/div&gt; &lt;div class="table_column" style="width: 100px; display:inline-flex;"&gt; &lt;div style="float:left; style=" background-color: green; width: 64px;"&gt; &lt;input type="button" name="Approve" value="Approve"&gt; &lt;/div&gt; &lt;div style="float:left;" style="background-color: red;width: 64px;"&gt; &lt;input type="button" name="Reject" value="Reject"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Under the div class <code>table_row3</code> for the annual leave part row, I want to make to make the last column to include two buttons (with some CSS styling on) and I ended up have two green and red buttons stick next each other. Whilst this is the closest resemblance to the picture below, I'm just not sure this is great approach... I need another suggestion of a better way of handling this buttons sitting under the status columns with such margins or paddings.</p> <p>Any ideas?</p> <p>You can also check it live online.</p> <p><a href="http://cms.tmadev.com.au/staffleaveapproval.html" rel="nofollow noreferrer">http://cms.tmadev.com.au/staffleaveapproval.html</a></p>
25,030,459
0
Convert JObject to type at runtime <p>I am writing a simple event dispatcher where my events come in as objects with the clr type name and the json object representing the original event (after the byte[] has been processed into the jobject) that was fired. I'm using GetEventStore if anyone wants to know the specifics.</p> <p>I want to take that clr type to do 2 things:</p> <ol> <li>find the classes that implements IHandles and </li> <li>call Consume(clr type) on that class</li> </ol> <p>I have managed to get part 1 working fine with the following code:</p> <pre><code> var processedEvent = ProcessRawEvent(@event); var t = Type.GetType(processedEvent.EventClrTypeName); var type = typeof(IHandlesEvent&lt;&gt;).MakeGenericType(t); var allHandlers = container.ResolveAll(type); foreach (var allHandler in allHandlers) { var method = allHandler.GetType().GetMethod("Consume", new[] { t }); method.Invoke(allHandler, new[] { processedEvent.Data }); } </code></pre> <p>ATM the issue is that processedEvent.Data is a JObject - I know the type of processedEvent.Data because I have t defined above it.</p> <p>How can I parse that JObject into type t without doing any nasty switching on the type name?</p>
15,508,454
0
If you are using this tag, it is a good indication that you are asking a question that does not belong here.
36,726,504
0
Autohotkey Open Folder of Current Application or Process <p>In this code no open current application folder because the FilePath variable include exe file name</p> <pre><code>F11:: PID = 0 WinGet, hWnd,, A DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt *", PID) hProcess := DllCall("OpenProcess", "UInt", 0x400 | 0x10, "Int", False , "UInt", PID) PathLength = 260*2 VarSetCapacity(FilePath, PathLength, 0) DllCall("Psapi.dll\GetModuleFileNameExW", "UInt", hProcess, "Int", 0, "Str", FilePath, "UInt", PathLength) DllCall("CloseHandle", "UInt", hProcess) Run, Explorer %FilePath% </code></pre> <p>Thanks in advance for any assistance. </p>
7,330,809
0
How to create a short url for sharing on social media <p>I'm trying to write some code which shares a page on Facebook and twitter. The problem I'm facing is that the page I'm trying to share has a big query string like:</p> <pre><code>http://domain.com/see.php?c=3&amp;a=123&amp;v=1 </code></pre> <p>But it seems that Facebook and Twitter don't like that big query string.</p> <p>I also tried using tiny url with following method in which I passed the URL to a PHP function to get the tiny URL:</p> <pre><code>var a = $("#Link").val(); </code></pre> <p>I get the correct value of <code>**a**</code>. After that I pass this value to a PHP file:</p> <pre><code>$.post("ShortLink.php?value="+a </code></pre> <p>In that PHP file I got the following value:</p> <pre><code>http://domain.com/see.php?c=3 </code></pre> <p>All the values after <code>3</code> is deleted.</p> <p>Thanks</p>
39,705,323
0
Call different method depending on Bool without if-statement in Swift <p>Is it possible to call one or another method depending a <code>Bool</code> value? I wish to do this:</p> <pre><code>var isLocked: Bool { didSet { // This is not Swift but indicates what I'm looking for. self.activityIndicator.(isLocked ? startAnimating() : stopAnimating()) } } </code></pre> <p>I'm looking to do this using existing Swift 2 (or 3) language features; without class extensions.</p> <p>Possibly a duplicate, but couldn't find.</p>
1,757,839
0
<p>I assume pageTabPanel isn't defined at the time you trigger the handler. Try to remove the var keyword in front of "var pageTabPanel =" to make it a global variable.</p> <p>If that works, it's a scope/variable issue. The better solution is to give the tabpanel an id and call Ext.getCmp('tabpanelid').render('contentpanel') in your renderPageTabs method.</p> <p>Hope that helps.</p> <p>Regards, Steffen</p>
15,910,002
0
<p>I have created an example where you can sort your ArrayList even if its with objects. You can read through it an see if it's helps.</p> <p>I have made two classes and a test class:</p> <p>First class is Country:</p> <pre><code>public class Country { private String countryName; private int number; public Country(String countryName, int number){ this.countryName = countryName; this.number = number; } public String getCountryName(){ return countryName; } public void setCountryName(String newCountryName){ countryName = newCountryName; } public int getNumber(){ return number; } public void setNumber(int newNumber){ number = newNumber; } public String toString(){ return getCountryName() + getNumber(); } } </code></pre> <p>Next class is Methods:</p> <pre><code>public class Methods { private Country country; private ArrayList&lt;Country&gt; overview = new ArrayList&lt;Country&gt;(); private ArrayList&lt;Country&gt; overviewSorted = new ArrayList&lt;Country&gt;(); int [] test; public void regCountry(String countryname, int numbers){ if(!(countryname == "" &amp;&amp; numbers == 0)){ overview.add(new Country(countryname, numbers)); } else { System.out.println("The input was null"); } } public void showRegisteredCountries(){ if(!(overview.size() &lt; 0)){ for(int i = 0; i &lt; overview.size(); i++){ System.out.println("The country: " + overview.get(i).getCountryName() + " has the number: " + overview.get(i).getNumber() + " registered"); } } else { System.out.println("There are no country registered"); } } public void numbersOverFromArrayList(){ if(!(overview.size() &lt; 0)){ test = new int [overview.size()]; for(int i = 0; i &lt; overview.size(); i++){ test[i] = overview.get(i).getNumber(); } } } public void sortArrayAndCopyItBack(){ if(!(test.length &lt; 0)){ java.util.Arrays.sort(test); for(int i = 0; i &lt; test.length; i ++){ for(int j = 0; j &lt; overview.size(); j++){ if(test[i] == overview.get(j).getNumber()){ overviewSorted.add(new Country(overview.get(j).getCountryName(), overview.get(j).getNumber())); } } } } } public void showTableSorted(){ if(!(overviewSorted.size() &lt; 0)){ for(int i = 0; i &lt; overviewSorted.size(); i++){ System.out.println("Country name: " + overviewSorted.get(i).getCountryName() + " with number: " + overviewSorted.get(i).getNumber()); } } else { System.out.println("There are non countrys in table that is sorted"); } } } </code></pre> <p>Next is the test class:</p> <pre><code>public class test2 { public static void main(String [] args){ Methods methodes = new Methods(); for(int i = 0; i &lt; 4; i++){ String inCountry = JOptionPane.showInputDialog("Country:"); String inNumber = JOptionPane.showInputDialog("number:"); String country = inCountry; int number = Integer.parseInt(inNumber); methodes.regCountry(country, number); } methodes.showRegisteredCountries(); methodes.numbersOverFromArrayList(); methodes.sortArrayAndCopyItBack(); methodes.showTableSorted(); } } </code></pre> <p>My output:</p> <pre><code>The country: Norway has the number: 5 registered The country: Sweden has the number: 2 registered The country: Denmark has the number: 9 registered The country: Finland has the number: 7 registered Country name: Sweden with number: 2 Country name: Norway with number: 5 Country name: Finland with number: 7 Country name: Denmark with number: 9 </code></pre>
34,445,315
0
<p>Basically <code>nscurl --ats-diagnostics &lt;url&gt;</code> just tries all possible variants of connection to server and responses with PASS/FAIL results for each test. You should just find which tests pass for your server and set ATS configuration accordingly.</p> <p><a href="http://useyourloaf.com/blog/app-transport-security.html" rel="nofollow">Here's</a> a good article on ATS and checking server compliance, it also contains an nscurl example.</p>
40,849,963
0
<p>You need to loop over the sheets in the workbook and manipulate each one individually:</p> <pre><code>Dim sheet As Worksheet For Each sheet In ActiveWorkbook.Worksheets sheet.Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete Next </code></pre>
29,992,582
0
How to perform Array/Object destructuring manually & efficiently? <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment" rel="nofollow">Array destructuring</a> is super useful:</p> <pre><code>var [a, b, c] = [1, 2, 8]; </code></pre> <p>It looks like it was <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7#Destructuring_assignment_%28Merge_into_own_page.2Fsection%29" rel="nofollow">implemented into Javascript 1.7</a>, but then <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1083498" rel="nofollow">removed with bug 1083498</a>. Now according to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Browser_compatibility" rel="nofollow">this table</a> it's not supported by any browser except Firefox! :(</p> <p>I wish I could use it because I don't like having to create an extra unnecessary variable. </p> <p>With destructuring:</p> <pre><code>var a, b, c; var input = "1 2 8"; [a, b, c] = arr.split(" "); </code></pre> <p>Without destructuring:</p> <pre><code>var a, b, c; var input = "1 2 8"; var inputArr = input.split(" "); a = inputArr[0]; b = inputArr[1]; c = inputArr[2]; </code></pre> <p>Is there a way to do this without the need to create the extra unneeded <code>inputArr</code> and draw from it multiple times?</p>
19,892,982
0
Button appears on hover <p>I have a box. when you put your mouse over the box, a button appears on top of the box. the hover function works in such a way that it doesn't recognize that the mouse is still on top of the box. how can I solve it?</p> <pre><code>//I create the paper var paper = Raphael(0, 0, 500,500); //I add the box var box = paper.add([{ type: "rect", x: 100, y: 100, width: 100, height: 100, fill: '#000', }]) // I declare a varible for the button var button //I add hover functions to the box. //first function: when the mouse is on, create a red circle and add an //onclick event to the circle box.hover(function () { button = paper.circle(150, 150, 25).attr({ 'fill': 'red' }) button.click(function () { alert("You clicked me!")}) }, //second function: when the mouse leaves the box, remove the circle function () { button.remove() }) </code></pre> <p>Here is an example</p> <p><a href="http://jsfiddle.net/V4E4Q/" rel="nofollow">http://jsfiddle.net/V4E4Q/</a></p>
19,602,175
0
<p>you can hide the table before it is initialized and show it after initializing is complete.</p> <p>Use CSS to hide the table.</p> <pre><code>.grid { display: none; } </code></pre> <p>add fnInitComplete to your datatable settings to show the table once it is intililized.</p> <pre><code>enter code here $(".grid").dataTable({ // Your settings "fnInitComplete": function(oSettings, json) { $(".grid").show() } }); </code></pre>
13,484,797
0
<p>After investigation it seems that getting a 403 error happens if the account that is set in <code>.setServiceAccountUser("[email protected]")</code> is not a "Super Admin" of the domain.</p> <p>However in the case above "[email protected]" is indeed a Super Admin of the domain. Also the code works well with any other Super Admin of the domain which leads to believe that there is something wrong with the account "[email protected]" in particular.</p> <p>If this happens to anyone else - a.k.a. an account set as "Super Admin" which does not work to access Admins-only APIs through Service Accounts - make sure you let us know in the comments below and we'll investigate further if this impacts lots of people.</p>
35,340,840
0
<p>You can have similar code for other radiobuttons also</p> <pre><code>$("#laufzeit_0").change(function(){ if($(this).is(":checked")){ if($("#abrechnung_0").is(":checked")){ $("div.YOUR_DIV_CLASS").show(); } } }); </code></pre>
6,392,749
0
i want my shape when hit with inside of stage , rotate and countinue move in true angle forever <p>![My Map][1]</p> <p>i want simulate Billiard ball in my project. but my code does not work good. when start with (for example) 34 degree , when hit with wall(stage in this example) return with true degree. in flash , as3</p> <pre><code>public function loop(e:Event) : void { if(luanch) { y += Math.sin(degreesToRadians(rotation)) * speed; x += Math.cos(degreesToRadians(rotation)) * speed; if (x &gt; stage.stageWidth){ rotation -= 90; x = stage.stageWidth; trace("X :" , x , rotation); } else if (x &lt; 0) { rotation += 90; x=3; //rotation += 90; trace("X :" , x , rotation); } if (y &gt; stage.stageHeight) { y = stage.stageHeight; rotation -= 90; trace("Y : " , y , rotation); } else if (y &lt;0) { rotation += 90; //rotation += 90; trace("Y :" , y , rotation); } } } public function degreesToRadians(degrees:Number) : Number { return degrees * Math.PI / 180; } } } </code></pre>
12,647,043
0
<p>You should not be storing numeric data as a string but if you do, then you will need to <code>cast()</code> it to apply a <code>SUM()</code> aggregate to it:</p> <pre><code>SELECT SUM(CAST(yourcolumn AS DECIMAL(10, 2))) FROM yourtable </code></pre> <p>So your query will be:</p> <pre><code>select sum(cast(qty as DECIMAL(10, 2))) from inventory i where i.refDocNum = 485 and i.refApp = 'WO' and i.type in (20, 21) </code></pre>
29,697,845
0
<p>I am finally able to find solution for this. I added encode property like this $mail->encoding = base64. It worked.</p>
32,024,825
0
Combine two wallets bitcoin <p>I have two PC and bitcoin-qt on both. On first PC I have a wallet encrypted with my passphrase <code>AAAAAAA</code> and on my second PC I have a wallet encrypted with other passphrase <code>BBBBBBBBB</code>. I want have all my btcs in my first PC because I want to sell my other PC.</p> <p>I know that I can send my btcs from second PC to first PC. But I prefer join the wallets.</p> <p>Can I merge two wallets in one? </p>
17,577,082
0
<p>I don't think it's possible to retrieve completely unrelated tables through LINQ in one shot. Maybe for performance reasons you should consider caching so you won't need to query the database every time.</p> <p>With plain SQL on MSSQL you could use batch statements.</p> <pre><code>var batchSql = "select * from Repository; select * from StaffMembersRepository; select * from CategoriesRepository"; // ... // iterate over batch results using(var reader = command.ExecuteReader()) { var currentResultSet = 0; while(reader.NextResult()) { currentResultSet++; switch(currentResultSet) { case 1: while(reader.Read()) { // retrieve row data } case 2: // similar case 3: // similar } } } </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.nextresult.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.nextresult.aspx</a></p> <p>But I don't think it's a nice way.</p>
1,598,810
0
<p>Is it a high resolution image? which you are trying to load,</p>
13,168,742
0
<p>Gibberish,</p> <p>Try the <strong><a href="http://www.outsharked.com/imagemapster/" rel="nofollow">ImageMapster</a></strong> jQuery plugin, which acts on image maps to offer (at v1.2.6) the following features :</p> <ul> <li>Highlight and select areas</li> <li>Cool effects by using an alternate image</li> <li>Bind the image map to an external list</li> <li>Show floating tooltips for areas or area groups</li> <li>Grouping and exclusion masks to create complex functionality</li> <li>Automatic scaling of imagemaps to any display size, even while active</li> </ul> <p>The feature you need is the last one listed.</p> <p>I've not used ImageMapster myself, but the <strong><a href="http://www.outsharked.com/imagemapster/default.aspx?demos.html" rel="nofollow">demos</a></strong> are very impressive and indicative of a well written plugin.</p>
14,922,606
0
Easier way to work with $$ <p>I am looking for an easier way to make my example below:</p> <pre><code>&lt;?php $q = "Q".rand(1, 3); echo $$q; ?&gt; </code></pre> <p>Thanks.</p>
34,538,239
0
Navigating to another HTML Page in Apps for Office gets Office.js has not been fully loaded yet <p>This is in regards to Apps for Office.</p> <p>I have two pages: <em>Home.html</em> and <em>Details.Html</em>. Once I load some data into a table in Excel, I then use <code>location.href="Details.html"</code> to load the page <em>Details.html</em>. Within Details the Javascript file has:</p> <pre><code> Office.initialize = function (reason) { $(document).ready(function () { app.initialize(); $('#get-employee-details').click(getEmployeeDetails); }); }; </code></pre> <p>But before it even gets to that code, I get an error coming from office.js stating: </p> <blockquote> <p>Unhandled exception at line 11, column 11313 in <a href="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" rel="nofollow">https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js</a></p> <p>0x800a139e - JavaScript runtime error: Office.js has not been fully loaded yet. Please try again later or make sure to add your initialization code on the Office.initialize function.</p> </blockquote> <p>The only Javascript code is inside the Office initialize function so I am lost as to why I am getting this error.</p>
29,008,393
0
<p>I must say that it works perfectly like it should be.</p> <p>If you want it to be:</p> <pre><code>Before After Screen </code></pre> <p>Try this:</p> <pre><code>final LinearLayout screenRL = (LinearLayout) findViewById(R.id.screenRL); new Thread(new Runnable() { @Override public void run() { for (int i = 0; i &lt; 4; i++) { LayoutInflater inflater = getLayoutInflater(); final View view = inflater.inflate(R.layout.dl, null); TextView txtTitleView = (TextView) view.findViewById(R.id.txtTitleView); txtTitleView.setText((i + 1) + ". Post"); Log.i("Check", "Before : "); runOnUiThread(new Runnable() { public void run() { Log.i("Check", "After"); screenRL.addView(view); } }); } runOnUiThread(new Runnable() { public void run() { Log.i("Check", "Screen"); } }); } }).start(); </code></pre>
2,342,382
0
<p>Having previously worked with Spring's HTTP invoker remoting, I can say that there's built-in support for passing Spring security tokens. I would assume that Spring's RMI solution also has this feature, but you'd need to dig around in Spring's RMI classes/javadoc to confirm this.</p> <p>On the client side, you'll need the <code>ContextPropagatingRemoteInvocationFactory</code> class, which will automatically include a Spring security context on the remote invocation.</p>
34,627,665
1
Adding error bars in line figure with missing data <p>I want to draw lines between missing data as suggested <a href="https://stackoverflow.com/questions/14399689/matplotlib-drawing-lines-between-points-ignoring-missing-data">here</a> but with error bars.</p> <p>This is my code.</p> <pre><code>import matplotlib.pyplot as plt import numpy as np x = [1, 2, 3, 4, 5] y_value = [12, None, 18, None, 20] y_error = [1, None, 3, None, 2] fig = plt.figure() ax = fig.add_subplot(111) plt.axis([0, 6, 0, 25]) ax.plot(x, y_value, linestyle = '-', color = 'b', marker = 'o') ax.errorbar(x, y_value, yerr = y_error, linestyle = '' , color = 'b') plt.show() </code></pre> <p>But because of the missing data, I get </p> <blockquote> <p>TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'</p> </blockquote> <p>What should I do?</p>
6,029,712
0
<p>If you're on Windows, try using <a href="http://4dpiecharts.com/2011/04/15/friday-function-setinternet2/" rel="nofollow"><code>setInternet2</code></a> so that your IT network thinks that it is Internet Explorer connecting to the internet. Often useful for evading corporate lockdown.</p>
30,435,216
0
Search in mysql column against provided json value <p>I have a table contents. Columns -> id, title, description.</p> <pre><code> CREATE TABLE IF NOT EXISTS `contents` ( `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(255) DEFAULT NULL, `description` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; </code></pre> <p>-- Dumping data for table <code>contents</code>--</p> <pre><code>INSERT INTO `contents` (`id`, `title`, `description`) VALUES (1, 'My fab phone', 'I own an iphone 5c.'), (2, 'I hate my phone', 'I have a Samsung S4. :('); </code></pre> <p>I have a json vaue made by input from user. Its like -> </p> <pre><code>[{"devices":"iPhone 5c"},{"devices":"Samsung S4"}] </code></pre> <p>I would like to search against it against the title, description comlumn in mysql.. my application is in php. is it even possible in mysql ? or I have to manipulate the json run it in loop and then simple search in mysql ? ...If its possible in mysql then please help</p>
11,296,367
0
<p>Another way is, don't extend <code>ListActivity</code>. Just extends <code>Activity</code>, then you can create your list view by <code>setContentView()</code> and get the list view by <code>findViewById(R.id.yourlistview)</code>.</p> <p>If you extends from <code>ListActivity</code>, then don't use <code>setContentView()</code>. You need get the default list view hosted in list activity by <code>getListView()</code>.</p>
17,551,424
0
Can't access array item within angular.js view <p>I'm trying to access the first item in an array within an angular.js view like this:</p> <pre><code>&lt;p class="name-label"&gt;{{user_profile.email[0].emailAddress}}&lt;/p&gt; </code></pre> <p>My object looks like this:</p> <pre><code>Object { .... "email": [ { "emailType": "Primary", "emailAddress": "[email protected]" } ], .... } </code></pre> <p>This is not working - I don't get an error - it just doesn't display anything! Any ideas?</p> <p>Thank you!</p>
40,792,557
0
Select past days from Calendar <p>I am trying to open calendar from past days but calendar starts from today and past days.How to show only past days.For example today's date is 24-11-2016,i want to open calendar from 23-11-2016.This is my snippet code</p> <pre><code> `Calendar c = Calendar.getInstance(); fromYear = c.get(Calendar.YEAR); fromMonth = c.get(Calendar.MONTH); fromDay = c.get(Calendar.DAY_OF_MONTH);` </code></pre>
35,112,854
0
<p>Finally found the answer <a href="https://github.com/Mantle/Mantle/issues/263" rel="nofollow">here</a>. It's quite an ingenious way, and I was surprised to see it not being mentioned in the docs explicitly.</p> <p>The way to combine multiple keys into a single object is by mapping the target property to multiple keys using an array in the <code>+JSONKeyPathsByPropertyKey</code> method. When you do so, Mantle will make the multiple keys available in their own <code>NSDictionary</code> instance.</p> <pre><code>+(NSDictionary *)JSONKeyPathsByPropertyKey { return @{ ... @"location": @[@"latitude", @"longitude"] }; } </code></pre> <p>If the target property is an NSDictionary, you're set. Otherwise, you will need specify the conversion in either the <code>+JSONTransformerForKey</code> or the <code>+propertyJSONTransformer</code> method.</p> <pre><code>+(NSValueTransformer*)locationJSONTransformer { return [MTLValueTransformer transformerUsingForwardBlock:^CLLocation*(NSDictionary* value, BOOL *success, NSError *__autoreleasing *error) { NSString *latitude = value[@"latitude"]; NSString *longitude = value[@"longitude"]; if ([latitude isKindOfClass:[NSString class]] &amp;&amp; [longitude isKindOfClass:[NSString class]]) { return [[CLLocation alloc] initWithLatitude:[latitude floatValue] longitude:[longitude floatValue]]; } else { return nil; } } reverseBlock:^NSDictionary*(CLLocation* value, BOOL *success, NSError *__autoreleasing *error) { return @{@"latitude": value ? [NSString stringWithFormat:@"%f", value.coordinate.latitude] : [NSNull null], @"longitude": value ? [NSString stringWithFormat:@"%f", value.coordinate.longitude]: [NSNull null]}; }]; } </code></pre>
37,464,570
0
Interpolating Surface in R <p>I'm trying to interpolate a polynomial of the form</p> <p><code>z = Ax^2 + By^2 + Cxy + Dx + Ey + F</code></p> <p>In <code>R</code>, where the capital letters are constant coefficients.</p> <p>For the following data</p> <p>My horizontal axis is: <code>KSo&lt;-c(0.90,0.95,1.00,1.05,1.10)</code></p> <p>My vertical axis is: <code>T&lt;-c(1/12,3/12,6/12,1,2,5)</code></p> <p>And the data mapped by <code>KSo X T</code> are:</p> <p><code>14.2 13.0 12.0 13.1 14.5</code></p> <p><code>14.0 13.0 12.0 13.1 14.2</code></p> <p><code>14.1 13.3 12.5 13.4 14.3</code></p> <p><code>14.7 14.0 13.5 14.0 14.8</code></p> <p><code>15.0 14.4 14.0 14.5 15.1</code></p> <p><code>14.8 14.6 14.4 14.7 15.0</code></p> <p>In other words, the observed datum for <code>(1.00,6/12)</code> is <code>12.5</code></p> <p>How would I interpolate, for example, the predicted data for <code>(0.98,11/12)</code>? </p> <p>Edit: I found a nice package, <code>akima</code>, with the <code>bicubic</code> function, that uses splines. I'd still like to see what people suggest </p>
39,677,957
1
Python MP3 Player <p>I Am Trying To Play An MP3 File On Python , But I Can't Find The Right Module! I've Tried This:</p> <pre><code>import os os.startfile('hello.mp3') </code></pre> <p>But I Just Got The <strong>Error</strong>:</p> <pre><code>Traceback (most recent call last): File "/Applications/Youtube/text 2 speech/test.py", line 2, in &lt;module&gt; os.startfile('hello.mp3') AttributeError: 'module' object has no attribute 'startfile' </code></pre> <p>I Have Also Tried This:</p> <pre><code>import vlc p = vlc.MediaPlayer("file:hello.mp3") p.play() </code></pre> <p>But I Get The <strong>Error</strong>:</p> <pre><code>Traceback (most recent call last): File "/Applications/Youtube/text 2 speech/test.py", line 1, in &lt;module&gt; import vlc ImportError: No module named 'vlc' </code></pre> <p>But I Still Can't Find The Right Module. Could Someone Please Help?</p>
4,182,405
0
A simple thread's pool in C++ with thread priorities <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4179316/threadpool-in-c">threadpool in c++</a> </p> </blockquote> <p>I need to write my own or use already written thread's pool in C++ with priorities. Boost threadpool is too complicated. Please, advice me one.</p>
1,144,825
0
can i do caching with php? <p>I have read a few things here and there and about PHP being able to "cache" things. I'm not super familiar with the concept of caching from a computer science point of view. How does this work and where would I use it in a PHP website and/or application.</p> <p>Thanks!</p>
34,910,745
0
What are the best practices for single-instanced classes in java? <p>In my program I have a menu system in which I have a separate class for each menu, for example MainMenu would be a separate class. But the class is only supposed to be instanced once, and after I instance it, it is saved in a list which is all is used for after that. Should I use another solution than a separate class? Or should I make the constructor private and then make a private instance inside the class? I feel like this violates OOP, but I don't see another solution.</p>
29,683,503
0
parsing data from JSON <p>I am making an AJAX call to a JSON file containing thumbnail images and website urls, I am then listing each out using AngularJS directive ng-repeat to list. The problem is the thumbnails and website urls are no longer populating my page. I reformatted my JSON file data into an array because I will be adding multiple arrays to my JSON file that will contain different objects to be used on other pages throughout the website. </p> <p>JSON:</p> <pre><code>{"websites":[ { "thumbnail": "thumbnail1.jpg", "website": "http://somewebsite.com" }, { "thumbnail": "thumbnail2.jpg", "website": "http://somewebsite.com" }, { "thumbnail": "thumbnail3.jpg", "website": "http://somewebsite.com" } ]} </code></pre> <p>Angular:</p> <pre><code>angular.module('myApp') .constant("dataUrl", "../json/data.json") .controller("websitesController", function($scope, $http, dataUrl){ $scope.data ={}; $http.get(dataUrl) .success(function(data){ $scope.data.projects = data; }) .error(function(error){ $scope.data.error = error; }); }); </code></pre> <p>HTML: </p> <pre><code>&lt;ul ng-controller="websitesController"&gt; &lt;li ng-repeat="item in data.projects"&gt; &lt;img ng-src="{{item.thumbnail}}" /&gt; &lt;div&gt; &lt;a ng-href="{{item.website}}" target="_blank"&gt;&lt;b&gt;Website&lt;/b&gt;&lt;/a&gt; &lt;/div&gt; &lt;/li&gt; &lt;ul&gt; </code></pre>
21,473,611
0
Netbeans swing Master detail sample form delete not working <p>I'm using NB 7.4, JavaDb , jdk 7.</p> <p>I tried to work on this example : <a href="http://simsam7.blogspot.in/2013/06/quick-crud-application-on-netbeans-73.html" rel="nofollow">http://simsam7.blogspot.in/2013/06/quick-crud-application-on-netbeans-73.html</a></p> <p>In CRUD, CRU works good, but delete not working,and its not throwing any error also.</p> <p>My Code for delete button.</p> <pre><code> int[] selected = masterTable.getSelectedRows(); List&lt;com.fz.PurchaseOrder&gt; toRemove = new ArrayList&lt;com.fz.PurchaseOrder&gt;(selected.length); for (int idx = 0; idx &lt; selected.length; idx++) { com.fz.PurchaseOrder p = list.get(masterTable.convertRowIndexToModel(selected[idx])); toRemove.add(p); entityManager.remove(p); } list.removeAll(toRemove); </code></pre> <p>I done debug, and i think error at entityManager.remove(p).</p> <p><strong>INFO :</strong> Output GUI - The row in table removes/delete good, but when i refresh it shows again.</p>
7,123,838
0
<p>If there's no duplicate, then this query will do an insert, and the <code>Time</code> value will be null, as no value was ever set. <code>Null + anything</code> is null, hence the error.</p> <p>Try <code>... Time = COALESCE(Time, 0) + INTERVAL $time SECOND</code> or similar to get aroun dit.</p>
31,622,023
0
<p>The best way would be through feature detection in the browser. Since there is not a standard way of detecting touch through CSS. I would just do this JavaScript:</p> <pre><code>if ('ontouchstart' in document) { // Bring in the necessary CSS optimized for touch } </code></pre>
7,476,431
0
<p>You can take in a parameter of <code>HttpServletRequest</code>, and read the <code>ServletInputStream</code> using <a href="http://download.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getInputStream%28%29" rel="nofollow"><code>getInputStream()</code></a> from there. The stream will contain the body of the request.</p> <pre><code>@Controller public class MyController { @RequestMapping("/test") public String aTest(HttpServletRequest request) { InputStream body = request.getInputStream(); //process request body return myReturnVal; } } </code></pre>
16,493,992
0
How to locate search links in google in Selenium for testing <p>I am trying to search Google for Selenium, then run down the list of links by clicking each one, printing the page title, then navigating back.</p> <pre><code>List&lt;WebElement&gt; linkElements = driver.findElements( **&lt;insert code here&gt;** ); for(WebElement elem: linkElements) { String text = elem.getText(); driver.findElement(By.linkText(text)).click(); System.out.println("Title of link\t:\t" + driver.getTitle()); driver.navigate().back(); } </code></pre> <p>To find the elements, I have tried By.tagName("a") which doesn't work because it gets ALL the links, not just the search ones. Using Firebug, I see that each search link has a class of r used on the header h3, and the a tag nested inside it.</p> <p>See the following:</p> <pre><code>&lt;h3 class="r"&gt; &lt;a href="/url sa=t&amp;amp;rct=j&amp;amp;q=selenium&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;ved=0CC8QFjAA&amp;amp;url=http%3A%2F%2Fseleniumhq.org%2F&amp;amp;ei=y4eNUYiIGuS7iwL-r4DADA&amp;amp;usg=AFQjCNHCelhj_BWssRX2H0HZCcPqhgBrRg&amp;amp;sig2=WBhmm65gCH7RQxIv9vgrug&amp;amp;bvm=bv.46340616,d.cGE" onmousedown="return rwt(this,'','','','1','AFQjCNHCelhj_BWssRX2H0HZCcPqhgBrRg','WBhmm65gCH7RQxIv9vgrug','0CC8QFjAA','','',event)"&gt;&lt;em&gt;Selenium&lt;/em&gt; - Web Browser Automation &lt;/a&gt;&lt;/h3&gt; </code></pre> <p>What code can I insert to make this work?</p>
15,914,069
0
<p>Well, it seems like the main issue was with your css. When a mouseover event was triggered, the modalMask element was shown. The problem however was that you placed it on top of everything else with:</p> <pre><code>position: absolute; ... width: 100%; height: 100%; ... z-index: 1000; </code></pre> <p>This means that you had an invisible layer blocking access to the links, and that's why there was no reaction after the first event.</p> <p>While troubleshooting, i cleaned up the code for you at: <a href="http://jsfiddle.net/Z4ZGZ/18/" rel="nofollow">http://jsfiddle.net/Z4ZGZ/18/</a></p> <p>The 'close' button doesn't work in the fiddle, but it worked for me locally when i included the script file at the bottom of the body element.</p>
36,908,979
0
<p>u can try this plugin contact form 7 AutoSaver , Select some forms to enable auto-save on them, meaning when a user fill the form, without even submitting it, then navigates to another page and comes back or refreshes the page, they will see the data they previously filled still available for them!</p> <pre><code>https://wordpress.org/plugins/cf7-autosaver/ </code></pre>
9,728,436
0
<p>the problem with <code>mailto:</code> is that web scrapers can be used to "harvest" into a "spam mailing list". these are common in e-mail marketers (email advertising). also, search engines like Google will also pick them up, making your email a public item, easilty searchable, easily spammable.</p> <p>common methods employed today to prevent spamming thru email is a contact page &amp; following/friending in social sites (since social sites have the ability to block users, spammers won't waste time making accounts and keep friending/following you).</p>
30,098,562
0
mobilefirst logout redirect to new page <p>I am using jquery mobile and I am using $.mobile.changePage( "#newpage"); option when the user authentication is done to move to next page. in the next page I have a logout button and when user clicks on that it has to logout and on success it has to come back to the login screen again. </p> <pre><code>WL.Client.logout('CustomAuthenticatorRealm',{onSuccess: WL.Client.reloadApp}) </code></pre> <p>in this code onsuccess it is reloading the same url. i tried to change it like onSuccess: $.mobile.changePage( "#loginpage");</p> <p>but it is not working. any suggestions please</p>
36,290,219
0
Htaccess 301 change old URL <p>I would like change url in my htaccess and using redirect 301 for SEO.</p> <p>my old url:</p> <pre><code>RewriteRule ^my-oldurl-(([0-9]+)-[a-zA-z0-9_-]+).html$ index.php?page=my-detail&amp;id=$1&amp;cat=$2 [QSA,L] </code></pre> <p>my new url:</p> <pre><code>RewriteRule ^my-newurl-(([0-9]+)-[a-zA-z0-9_-]+).html$ index.php?page=my-detail&amp;id=$1&amp;cat=$2 [QSA,L] </code></pre> <p>My last test (error 500):</p> <pre><code>RewriteRule ^my-oldurl-(([0-9]+)-[a-zA-z0-9_-]+).html ^my-newurl-(([0-9]+)-[a-zA-z0-9_-]+).html [QSA,R=301] </code></pre> <p>Thank you for any advice.</p>
10,809,155
0
<p>I think you need specify the SqlDBType when assigning the values to date in command.Parameters .and please cross check the parameter names which you have specified in insert statement with the parameters specified in parameters.Add </p> <pre><code>string sql = "INSERT INTO spending VALUES (@date, @amount_spent, @spent_on)"; using (var cn = new SqlConnection("..connection string..")) using (var cmd = new SqlCommand(sql, cn)) { cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = date_dateTimePicker.Value; command.Parameters.AddWithValue("@amount_spent",Convert.ToDecimal(amount_spent_textBox.Text)); command.Parameters.AddWithValue("@spent_on", spent_on_textBox.Text); connect.Open(); </code></pre> <p>Some time its better to use invariant culture to store things like date/time in database .You can try that CultureInfo.Invariantculture</p> <pre><code>DateTime date = date_dateTimePicker.Value.Date; string sDate = date.ToString("dd-MM-yy", System.Globalization.CultureInfo.InvariantCulture); DateTime dateInsert = Convert.ToDateTime(sDate); </code></pre>
3,914,484
0
How to set the opacity of a datagridview row <p>I plan to create a datagridview that will only have about 10 rows max. It will get updated at regular intervals and I want for it to have nice effects where each row will have it's opacity increased to full, the first row being the first and the last row becoming fully opaque at the end.</p> <p>Do you know how to edit the opacity of a datagridview row?</p> <p>Is it possible because I don't think the rows have an opacity property?</p>
6,998,781
0
<p>Consider this simplified problem</p> <pre><code>interface Item&lt;C extends Container&lt;Item&lt;C&gt;&gt;&gt; interface Container&lt;I extends Item&lt;Container&lt;I&gt;&gt;&gt; </code></pre> <p>It doesn't work, because subtypes of <code>Container&lt;Item&lt;C&gt;&gt;</code> are quite limited - <code>Container&lt;MyItem&gt;</code> is not a subtype of it, just like <code>List&lt;string&gt;</code> is not a subtype of <code>List&lt;Object&gt;</code></p> <p>We can relax it with wildcards:</p> <pre><code>interface Item&lt;C extends Container&lt;? extends Item&lt;C&gt;&gt;&gt; interface Container&lt;I extends Item&lt;? extends Container&lt;I&gt;&gt;&gt; </code></pre> <p>Now it works fine</p> <pre><code>class MyItem implements Item&lt;MyContainer&gt; class MyContainer implements Container&lt;MyItem&gt; </code></pre> <p>mostly. The following declaration is also allowed, but not what we intended</p> <pre><code>class HerItem implements Item&lt;MyContainer&gt; // nooo! </code></pre> <p>This is because we relaxed the constraints too much. Well, it's not a really serious problem. Sure, our type system isn't as tight as we want (no type system is), but programmers would instinctively follow the intended constraints, don't go out of their ways to write bizarre stuff just because they can.</p> <p>Ideally, we would want a <code>This</code> type, and our intended constraints can be expressed as</p> <pre><code>interface Item&lt;C extends Container&lt;This&gt;&gt;&gt; interface Container&lt;I extends Item&lt;This&gt;&gt; </code></pre> <p>Since we don't have <code>This</code>, one would attempt to approach it by a type parameter</p> <pre><code>interface Item&lt;C extends Container&lt;This, C&gt;&gt;, This extends Item&lt;C, This&gt; &gt; interface Container&lt;I extends Item&lt;This, I&gt;, This extends Container&lt;I, This&gt;&gt; </code></pre> <p>(or, more symmetrically </p> <pre><code> interface Item&lt;C extends Container&lt;I, C&gt;&gt;, I extends Item&lt;C, I&gt; &gt; interface Container&lt;I extends Item&lt;C, I&gt;, C extends Container&lt;I, C&gt;&gt; </code></pre> <p>)However, this is not really tight either. <code>This</code> isn't really the "this type". It's possible to</p> <pre><code>class HerItem implements Item&lt;MyContainer, MyItem&gt; // uh? </code></pre> <p>Once again, we must rely on programmer's discipline not to do stuff like that.</p>
4,363,446
0
<p>Host it on IIS and then it should work.</p>
24,922,753
0
<blockquote> <p>why use [yield]? Apart from it being slightly less code, what's it do for me?</p> </blockquote> <p>Sometimes it is useful, sometimes not. If the entire set of data must be examined and returned then there is not going to be any benefit in using yield because all it did was introduce overhead.</p> <p>When yield really shines is when only a partial set is returned. I think the best example is sorting. Assume you have a list of objects containing a date and a dollar amount from this year and you would like to see the first handful (5) records of the year. </p> <p>In order to accomplish this, the list must be sorted ascending by date, and then have the first 5 taken. If this was done without yield, the <em>entire</em> list would have to be sorted, right up to making sure the last two dates were in order.</p> <p>However, with yield, once the first 5 items have been established the sorting stops and the results are available. This can save a large amount of time.</p>
39,227,367
0
Zombie getting error Unhandled rejection Error: Timeout: did not get to load all resources on this page <p>I am new to zombie JS. I want to fill the login fields and post the login form. I tried to code this in zombiejs, but getting below error.</p> <p>Unhandled rejection Error: Timeout: did not get to load all resources on this page at timeout (C:\Users\sapna.maid\Desktop\nodejs\index\node_modules\zombie\lib \eventloop.js:601:38) at Timer.listOnTimeout (timers.js:92:15)</p> <p>My code snippet is as below:</p> <pre><code>var zombie = require("zombie"); zombie.waitDuration = '30s'; //Browser.waitDuration = '300s'; var assert = require("assert"); browser = new zombie({ maxWait: 10000, waitDuration: 30*1000, silent: true }); browser.visit("https://example.com", function () { // fill search query field with value "zombie" console.log("LOADEDDDD !!!!", browser.location.href); console.log(this.browser.text('title')); assert.equal(this.browser.text('title'), 'Welcome - Sign In'); browser.fill('#user', '[email protected]'); browser.fill('#pass', 'pass@123'); browser.document.forms[0].submit(); console.log(browser.text('title')); // wait for new page to be loaded then fire callback function browser.wait(5000).then(function() { // just dump some debug data to see if we're on the right page console.log(this.browser.success); assert.ok(this.browser.success); console.log("Browser title:: --------- " + this.browser.text('title')); assert.equal(this.browser.text('title'), 'Dashboard'); }) }); </code></pre> <p>Please help me to resolve this issue. I am stuck here for long duration. Thanks in advance!</p>
34,774,819
0
0x3 error using pdbstr (Source indexing) <p>I am trying to use the PDBSTR.EXE tool to merge version information into a PDB file and from time to time I encounter the following error: [result: error 0x3 opening K:\dev\main\bin\mypdbfile.pdb] &lt;- can be a different PDB file.</p> <p>An example of the command line that I use is: </p> <pre><code>pdbstr.exe -w -s:srcsrv -p:K:\dev\main\bin\mypdbfile.pdb -i:C:\Users\username\AppData\Local\Temp\tmp517B.stream </code></pre> <p>Could you tell me what would cause error code 0x3? </p> <p>If the error code is similar to the standard System error code 3 ERROR_PATH_NOT_FOUND, then it seems to think that the path K:\dev\main\bin\mypdbfile.pdb does NOT exist when in fact it DOES. However please note that my K: drive is a SUBST'ed drive.</p> <p>(System error code reference <a href="https://msdn.microsoft.com/en-ca/library/windows/desktop/ms681382(v=vs.85).aspx" rel="nofollow">https://msdn.microsoft.com/en-ca/library/windows/desktop/ms681382(v=vs.85).aspx</a>)</p> <p>Do you know what the 0x3 error code could possibly mean?</p>
34,284,692
0
jquery validate date in range or empty, it is not allowed to submit empty date <p>I used the jquery validation to check a range of date or allow an empty date with under jquery mask. It is passed on editing, but the empty date field still prompt "Require" on form submit, what can I do?</p> <pre><code>$.validator.addMethod("daterange", function(value, element) { var ymd = value.split("/"); var d = new Date(ymd[0], ymd[1]-1,ymd[2]); var startDate = Date.parse('2015/01/01'), endDate = Date.parse('2100/12/31'), enteredDate = Date.parse(value); if(value=="____/__/__") return true; else if (isNaN(enteredDate)) return false; else if (d.getFullYear() == ymd[0] &amp;&amp; d.getMonth() == ymd[1]-1 &amp;&amp; d.getDate() == ymd[2]) return ((startDate &lt;= enteredDate) &amp;&amp; (enteredDate &lt;= endDate)); else return false; },"Invalid Date" ); d1_eff_date : { required: false, daterange:true}, </code></pre>
15,287,073
0
MongoDB finding documents that are valid on a specific date <p>I have some data stored in a mongodb collection similar to:</p> <pre><code>{"_id": 1, "category": "food", "name": "chips", "price": 1.50, "effectiveDate": ISODate("2013-03-01T07:00:00Z")} {"_id": 2, "category": "food", "name": "chips", "price": 1.75, "effectiveDate": ISODate("2013-03-05T07:00:00Z")} {"_id": 3, "category": "food", "name": "chips", "price": 1.90, "effectiveDate": ISODate("2013-03-10T07:00:00Z")} {"_id": 4, "category": "beverage", "name": "pop", "price": 2.00, "effectiveDate": ISODate("2013-03-01T07:00:00Z")} {"_id": 5, "category": "beverage", "name": "pop", "price": 2.25, "effectiveDate": ISODate("2013-03-05T07:00:00Z")} {"_id": 6, "category": "beverage", "name": "pop", "price": 1.80, "effectiveDate": ISODate("2013-03-10T07:00:00Z")} </code></pre> <p>In mongodb, how would I go about writing a query that would return the documents that were active on a specific date, grouped by the category.</p> <p>If I specified March 6, 2013 i'd expect to see the results:</p> <pre><code>{"_id": 2, "category": "food", "name": "chips", "price": 1.75, "effectiveDate": ISODate("2013-03-05T07:00:00Z")} {"_id": 5, "category": "beverage", "name": "pop", "price": 2.25, "effectiveDate": ISODate("2013-03-05T07:00:00Z")} </code></pre> <p>I am new to mongo and have been trying to do this using group, aggregate and mapreduce but have been just spinning in circles.</p> <p>Thanks in advance!</p>
12,450,958
0
<p>If you can update the elements to have a common class, e.g., <code>class="state"</code>, then:</p> <pre><code>var SetState = function(state) { var s = document.getElementsByClassName("state"), i; for (i=0; i &lt; s.length; i++) s[i].style.display = 'none'; document.getElementById(state).style.display = 'block'; }; </code></pre> <p>That is, loop through all elements with the <code>state</code> class and hide them, then show just the one that was passed into the function with:</p> <pre><code>SetState('ohio'); </code></pre> <p>Alternatively, if you can't change the html, put all the state names in an array and loop through the array to hide them.</p>
38,517,765
1
Strip operation is removing a character from a url when it shouldnt be <p>I have a strange problem here. I have a list of Youtube urls in a txt file, these aren't normal YT urls though as I believe they were saved from a mobile device and thus they are all like this</p> <p><a href="https://youtu.be/A6RXqx_QtKQ" rel="nofollow">https://youtu.be/A6RXqx_QtKQ</a></p> <p>I want to download the audio from all these urls with youtube-dl for Python so all I need is the 11 digit id so to obtain that I have stripped out everything else from the urls like so:</p> <pre><code>playlist_url = [] f = open('my_songs.txt', 'r') for line in f: playlist_url.append(line.strip('https://youtu.be/')) </code></pre> <p>this works fine for nearly all the urls apart from any that start with 'o' in the 11 digit id e.g. this one</p> <p><a href="https://youtu.be/o5kO4y87Gew" rel="nofollow">https://youtu.be/o5kO4y87Gew</a></p> <p>the 'o' at the start of the digit would not be there and then youtube-dl would stop working saying it couldn't find the proper url or 11 digit id needed to continue. So I went back and printed out all the urls in 'playlist_url' and for the two urls with an 'o' at the start the 'o' is stripped out leaving them with just 10 digits. All other urls are stripped just fine though.</p> <p>why is this happening?</p>
2,217,431
0
<p>Yes you can create multiple controls in the same project, you simply have to place the all the default templates in a single /themes/generic.xaml file. Each controls template is identified by the <code>TargetType</code>. So your generic.xaml file would look something like:-</p> <pre><code> &lt;ResourceDictionary ... blah namespace stuff ...&gt; &lt;Style TargetType="local:CustomControl1"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="local:CustomControl1"&gt; &lt;!-- Template for Custom control 1 --&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;Style TargetType="local:CustomControl2"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="local:CustomControl2"&gt; &lt;!-- Template for Custom control 2 --&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;!-- and so on --&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>The Silverlight Toolkit chapies do have a neat tool which allows you to place each control template in its own file. The tool dynamically constructs the generic.xaml from the contents of all these files. I really wish they'd blog about it so we could find out how to use it ourselves. Hello any of you Msofties lurky listening in? </p>
8,802,330
0
RadioButtonList messed up in IE <p>I have a RadioButtonList:</p> <pre><code>&lt;p&gt; &lt;label for="rblIAm"&gt;I am&lt;/label&gt; &lt;asp:RadioButtonList ID="rblIAm" ValidationGroup="RegForm" runat="server"&gt; &lt;asp:ListItem Text="Gay" Value="Gay"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="Bisexual" Value="Bisexual"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="Straight" Value="Straight"&gt;&lt;/asp:ListItem&gt; &lt;/asp:RadioButtonList&gt; &lt;/p&gt; </code></pre> <p>With CSS like so:</p> <pre><code>label { float: left; width: 10em; font-size: 90.9%; padding-left: 1em; } input { background-color: #000; border: 1px solid #fff; color: #fff; font-size: 90.9%; height: 20px; clear: right; } input[type=radio] { height: 11px; border: none; border-color: transparent; } </code></pre> <p>In Chrome it looks fine:</p> <p><img src="https://i.stack.imgur.com/p74ih.jpg" alt="Chrome"></p> <p>In IE it looks messed up:</p> <p><img src="https://i.stack.imgur.com/qXJmH.jpg" alt="enter image description here"></p> <p>Can someone explain what's going wrong and the fix?</p> <p>Thanks</p>
6,195,637
0
<p>Essentially this is a duplicate of <a href="http://stackoverflow.com/questions/2472422/django-file-upload-size-limit">Django File upload size limit</a> </p> <p>You have two options:</p> <ol> <li><p>Use validation in Django to check the uploaded file's size. The problem with this approach is that the file must be uploaded completely before it is validated. This means that if someone uploads a 1TB file, you'll probably run out of hard drive space before the user gets a form error.</p></li> <li><p>Configure the Web server to limit the allowed upload body size. e.g. if using Apache, set the <code>LimitRequestBody</code> setting. This will mean if a user tries to upload too much, they'll get an error page configurable in Apache</p></li> </ol> <p>As @pastylegs says in the comments, using a combination of both is probably the best approach. Say you want a maximum of 5MB, perhaps enforce a 20MB limit at the Web server level, and the 5MB limit at the Django level. The 20MB limit would provide some protection against malicious users, while the 5MB limit in Django provides good UX.</p>
9,934,852
0
<p>Do you mean a short url something like this: <code>http://snd.sc/abc123</code>? If so, could you include the request which gives you that short_url? Otherwise if it's a 'normal' url like <code>http://soundcloud.com/username/track</code>, you can use the <a href="http://developers.soundcloud.com/docs/api/resolve" rel="nofollow">resolve endpoint</a> to get the track (or user, or set, etc) data.</p>
5,854,848
0
how to load a carousel from a xml file? <p>I'd like to load a carousel from a xml file and put it in the middle of a window and below the carousel I have a view that contains the description of each image.</p> <p>kind when I scroll the images I have every description of this picture that I'm also recovering from an xml file</p> <p>Can you tell me how I could do?</p> <p>Thank you</p>
27,383,491
0
<p>I think your permission should be filtered by the role. Something like this :</p> <pre><code>var rolePermissions = new HashSet&lt;int&gt;(tDbContext.RoleDetail.Where(rd =&gt; rd.RoleId == role.RoleID).Select(rd =&gt; rd.PermissionId)); </code></pre> <p>Your passing the role to your function but don't even use it : PopulateAssignedPermissionData(Role role). If i understand properly the code, now the <code>allPermission</code> and the <code>rolePermissions</code> are the same.</p>
15,781,227
0
<p>pageX and pageY are properties of the DOM-event, it appears the event you observe is a <a href="https://developers.google.com/maps/documentation/javascript/reference?hl=en#MouseEvent" rel="nofollow"><code>google.maps.MouseEvent</code></a>, which does not expose the requested properties.</p> <p>Use <code>addDomListener</code> instead to observe the DOM-event(of the node that contains the map):</p> <pre><code>google.maps.event.addDomListener(map.getDiv(), 'mouseover', function(e){ console.log(e.pageX+','+e.pageY); }); </code></pre>
27,496,671
0
cant display results from database <p>So i got a table on the database, that got some fields, and the image field got only the name of the images, the images are saved on a folder. I got this code to display the results, but its not showing anything, the page is blank..</p> <pre><code>&lt;?php include('ligacao.php'); $result = mysql_query("SELECT nome, genero, ano, banda, preco, arquivo FROM albuns"); while($row = mysql_fetch_array($result)) { { echo "&lt;div id='sitios'&gt;"; echo "&lt;div class='imageRow'&gt;"; echo "&lt;div class='single'&gt;"; echo "&lt;a href='imagens_albuns/" . $row['arquivo'] . "' rel='lightbox'&gt;&lt;img src='imagens_albuns/thumbnails/". $row['arquivo'] . "'/&gt;&lt;/a&gt;"; echo "&lt;/div&gt;"; echo "&lt;/div&gt;"; echo "&lt;div id='texto'&gt;"; echo "&lt;h2&gt;&lt;b&gt;" . $row['nome'] . "&lt;/b&gt;&lt;/h2&gt;"; echo "&lt;h3&gt;&lt;b&gt;Genero::&lt;/b&gt;&lt;/h3&gt;" . $row['genero'] . "&lt;/br&gt;"; echo "&lt;h3&gt;&lt;b&gt;Ano:&lt;/b&gt;&lt;/h3&gt;" . $row['ano'] . "&lt;/br&gt;"; echo "&lt;h3&gt;&lt;b&gt;Banda:&lt;/b&gt;&lt;/h3&gt;" . $row['banda'] . "&lt;/br&gt;"; echo "&lt;h3&gt;&lt;bPreço:&lt;/b&gt;&lt;/h3&gt;" . $row['preco'] . "€"; echo "&lt;/div&gt;"; echo "&lt;/div&gt;"; } } mysql_close($ligacap); ?&gt; </code></pre> <p>What can it be?</p>
38,099,841
0
<p>Thanks Uzbekjon!! I resolved the issue by modifying the path in C:\RailsInstaller\Ruby2.2.0\bin rackup.bat file. The path was wrongly mentioned in the file.Once I updated the correct location of rackup path, the issue is resolved.</p>
9,575,975
0
<p>Your opcode is incorrect, this works:</p> <pre><code>if(data) { *p++ = 0xb8; //mov $1, %eax *p++ = 0x01; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0xC3; //ret } </code></pre> <p>0xb8 is moving a 32bit immediate into eax, so you have to specify all 4 bytes.</p>
14,540,486
0
<p>Here's another approach which accounts for cents:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Money Conversion&lt;/title&gt; &lt;script type="text/javascript"&gt; function numberToCurrency(amount) { var wholeDigits; var thousandsSeparator = "," var centSeparator = "." var currencyNum = ""; if(amount.indexOf(".") != -1) { var hasCents = true; } else { var hasCents = false; } if (hasCents == true) { var num = amount.split("."); var wholeDigits = num[0].split(""); var centAmount = num[1]; var centDigits = num[1].split(""); if (centDigits.length == 0) { centDigits += "00"; } if ((centDigits.length &gt; 0) &amp;&amp; (centDigits.length &lt; 2)) { centDigits += "0"; } } else { centDigits = ""; centSeparator = ""; wholeDigits = amount.split(""); } var countDigits = wholeDigits.length; var revDigits = wholeDigits.reverse(); for(var i=0; i&lt;countDigits; i++) { if ((i%3 == 0) &amp;&amp; (i !=0)) { currencyNum += thousandsSeparator+revDigits[i]; } else { currencyNum += wholeDigits[i]; } }; var revCurrency = currencyNum.split("").reverse().join(""); var finalCurrency = "$"+revCurrency+centSeparator+centAmount; return finalCurrency; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; document.write(numberToCurrency('12326563523.37')); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>It does the trick, though it doesn't round the cent amounts or strip off extras past 2 digits.</p>
13,228,387
0
How do I append an object to NSMutableArray? <p>I want to update an mutable array. i have one array "ListArray" with some keys like "desc", "title" on other side (with click of button.) i have one array name newListArray which is coming from web service and has different data but has same keys like "desc" "title". so i want to add that data in "ListArray" . not want to replace data just add data on same keys. so that i can show that in tableview.</p> <p>..........So my question is how to add data in "ListArray". or any other way to show that data in tableview but replacing old one just want to update the data</p> <pre><code> NSMutableArray *newListArray = (NSMutableArray*)[[WebServices sharedInstance] getVideoList:[PlacesDetails sharedInstance].userId tokenValue:[PlacesDetails sharedInstance].tokenID mediaIdMin:[PlacesDetails sharedInstance].minId mediaIdMax:[PlacesDetails sharedInstance].maxId viewPubPri:@"Public_click"]; NSDictionary *getNewListDic = [[NSDictionary alloc] initWithObjectsAndKeys:newListArray,@"videoList", nil]; [listVidArray addObject:getNewListDic]; NSArray *keys = [NSArray arrayWithObjects:@"desc",@"url",@"media_id",@"img",@"status",@"media_id_max",@"fb_url",@"title", nil] ; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; for(int i = 0 ; i &lt; [listVidArray count] ; i++) { for( id theKey in keys) { // NSMutableArray *item = [NSMutableArray array]; NSLog(@"%@",theKey); NSLog(@"%@",keys); [dict setObject:[[[listVidArray objectAtIndex:i]valueForKey:@"videoList"] valueForKey:theKey] forKey:theKey]; // [dict setObject:[newListArray valueForKey:theKey] forKey:theKey]; } } </code></pre> <p><img src="https://i.stack.imgur.com/Vr5OT.png" alt="enter image description here"></p>
20,485,389
0
<p>Redefine <code>String#inspect</code>.</p> <pre><code>class String def inspect; "'#{self}'" end end </code></pre>
26,696,851
0
Loading a view in codeigniter <p>I have a view where i used bootstrap tabpanels. On the first tab(active one), i have the home message. On the second one i have a form with 3 input fields and a submit button. In the model function where i validate the data for those fields, I output form validation errors or success message, and after I reload the view.</p> <pre><code> $data['table'] = $this -&gt; model_admin -&gt; get_users(); $data['title'] = 'Administrator'; $this -&gt; load -&gt; view('admin_view', $data); </code></pre> <p>What i want to do is to manage, after i click submit button to reload the view, but with the second tab being active. Like I could load instead of ..../admin_view.php, ..../admin_view.php#add.</p>
11,334,785
0
<pre><code>you can try with int count = 0; and add ; not , between two instructions string needle=textBox1.Text.Trim(); cboxSelection = comboBox1.Text; </code></pre>
12,398,535
0
<p>Could be some sort of <code>utf8_encode()</code> problem. <a href="http://us.php.net/manual/en/function.utf8-encode.php#103126" rel="nofollow">This comment</a> on the documentation page seems to indicate if you encode an Umlaut when it's already encoded, it could cause issues.</p> <p>Maybe test to see if the data is already utf-8 encoded with <a href="http://php.net/manual/en/function.mb-detect-encoding.php" rel="nofollow"><code>mb_detect_encoding()</code></a>. </p>
41,029,456
0
AngularJS 1 approach for "new foobar" UI overlay <p>I'm using AngularJS 1 with angular-material and ui-router.</p> <p>Does anyone know what the best practice is for providing a UI for some "new foobar" type thing? In other words, let’s say I have a ui.route putting me at <code>/app/#/foobars/</code> which shows a list of all the foobars. At the bottom right is a FAB with a big plus sign, which will bring up a new UI something to allow the user to specify how they want their foobar. What is the best practices for this "UI something" that comes up, using Angular?</p> <ul> <li>Should I use an angular-material dialog? (That’s my first inclination, but it seems old-fashioned.)</li> <li>Do I create a route to <code>/app/#/new-foobar/</code> and just bring up another UI? (This seems heavy-handed; I don’t want to change the URI, plus I probably want to get back to where I came from after creating the foobar.)</li> <li>I think that ui-router allows nested states; is this something I would use? But I don't want the new view/component to be embedded in the current view --- I would expect a card or something to somehow "overlay" whatever view is showing.</li> </ul>
37,903,302
0
replace after string character by character in (notepad ++) using a not matched group? <p>i want replace after "string"</p> <p>stringreplacefield character by character </p> <p>for generate </p> <pre><code> stringstringeplacefield </code></pre> <p>after the first replace </p> <pre><code> stringstringstringplacefield </code></pre> <p>after the second replace</p> <pre><code> stringstringstringstringlacefield </code></pre> <p>after third replace</p> <pre><code> stringstringstringstringstringacefield </code></pre> <p>using a not matched group<br> in notepad++</p> <p>I have tried this several days</p> <p>please help me </p>
28,101,264
0
Neo4j performance difference in using shell and API <p>I understand that Neo4j supports different options to run the Cypher queries. The web browser, neo4j shell and the REST API. Is there a difference in performance when using the shell and the API?</p> <p>I'm working on a dataset that has around 10 million objects(nodes+edges).</p> <p>Thanks! </p>
13,592,065
0
Convert type 'System.Dynamic.DynamicObject to System.Collections.IEnumerable <p>I'm successfully using the JavaScriptSerializer in MVC3 to de-serialize a json string in to a dynamic object. What I can't figure out is how to cast it to something I can enumerate over. The foreach line of code below is my latest attemt but it errors with: "Cannot implicitly convert type 'System.Dynamic.DynamicObject' to 'System.Collections.IEnumerable'. How can I convert or cast so that I can iterate through the dictionary?</p> <pre><code> public dynamic GetEntities(string entityName, string entityField) { var serializer = new JavaScriptSerializer(); serializer.RegisterConverters(new[] { new MyProject.Extensions.JsonExtension.DynamicJsonConverter() }); dynamic data = serializer.Deserialize(json, typeof(object)); return data; } foreach (var author in GetEntities("author", "lastname")) </code></pre>
24,413,364
0
How to receive emails and store them automatically in Alfresco <p>We are working with Alfresco 4.2.c community version and the need is to configure Alfresco to store automatically received emails (from Outlook) in a specific workspace.</p> <p>I really need your help.</p>
26,478,442
0
<p>I took a look at the apis in sklearn.svm.* family. All below models, e.g.,</p> <ul> <li>sklearn.svm.SVC</li> <li>sklearn.svm.NuSVC</li> <li>sklearn.svm.SVR</li> <li>sklearn.svm.NuSVR</li> </ul> <p>have a common <a href="http://scikit-learn.org/0.11/modules/generated/sklearn.svm.NuSVR.html" rel="nofollow noreferrer">interface</a> that supplies a </p> <pre><code>probability: boolean, optional (default=False) </code></pre> <p>parameter to the model. If this parameter is set to True, libsvm will train a probability transformation model on top of the SVM's outputs based on idea of <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.1639" rel="nofollow noreferrer">Platt Scaling</a>. The form of transformation is similar to a logistic function as you pointed out, however two specific constants <code>A</code> and <code>B</code> are learned in a post-processing step. Also see this <a href="http://stackoverflow.com/questions/15111408/how-does-sklearn-svm-svcs-function-predict-proba-work-internally">stackoverflow</a> post for more details.</p> <p><img src="https://i.stack.imgur.com/LcIQF.png" alt="enter image description here"></p> <p>I actually don't know why this post-processing is not available for LinearSVC. Otherwise, you would just call <code>predict_proba(X)</code> to get the probability estimate. </p> <p>Of course, if you just apply a naive logistic transform, it will not perform as well as a calibrated approach like <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.1639" rel="nofollow noreferrer">Platt Scaling</a>. If you can understand the underline algorithm of platt scaling, probably you can write your own or contribute to the scikit-learn svm family. :) Also feel free to use the above four SVM variations that support <code>predict_proba</code>.</p>
23,450,131
0
displaying blogs in webview <p>I want to display my blog as a part of an android application..i have the code ready..it works well when displaying websites like google etc but not with my blog..can someone help me solve this problem</p> <p>mainActivity.java:</p> <pre><code>package com.mkyong.android; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { private Button button; public void onCreate(Bundle savedInstanceState) { final Context context = this; super.onCreate(savedInstanceState); setContentView(R.layout.main); button = (Button) findViewById(R.id.buttonUrl); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(context, WebViewActivity.class); startActivity(intent); } }); } } </code></pre> <p>webViewActivity.java:</p> <pre><code>package com.mkyong.android; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; import android.webkit.WebViewClient; public class WebViewActivity extends Activity { private WebView webView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webview); webView = (WebView) findViewById(R.id.webView1); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient()); webView.loadUrl("pavan7vasan.blogspot.com"); } } </code></pre> <p>main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/buttonUrl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Go to http://www.google.com" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>webview.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webView1" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre> <p>it shows web page not available in the android emulator</p>
11,381,829
0
<pre><code>pid_t pid; int pipeIDs[2]; if (pipe (pipeIDs)) { fprintf (stderr, "ERROR, cannot create pipe.\n"); return EXIT_FAILURE; } pid = fork (); if (pid == (pid_t) 0) { /* Write to PIPE in this THREAD */ FILE * file = fdopen( pipe[1], 'w'); fprintf( file, "Hello world"); return EXIT_SUCCESS; } else if (pid &lt; (pid_t) 0) { fprintf (stderr, "ERROR, cannot create thread.\n"); return EXIT_FAILURE; } FILE* myFile = fdopen(pipe[0], 'r'); // DONE! You can read the string from myFile .... ..... </code></pre>
10,073,081
0
<p>JavaScript variables are scoped by function declarations, not by blocks. Thus, you are using two different variables.</p>
29,358,373
0
Interrupt OutputStream - Android <p>I'm using a <a href="http://www.codejava.net/java-se/networking/upload-files-by-sending-multipart-request-programmatically" rel="nofollow">this</a> class to upload files in HTTP, my problem is that I noticed when I remove the lan cable from my router the upload stucks as the write call blocks, below shows where it exactly stuck, I tried interrupting the thread but that didn't help either.</p> <p>Now the question is how can I interrupt outputStream? </p> <pre><code>public void addFilePart(String fieldName, File uploadFile) throws IOException { ... //removed code from here for clarity. //Can be found in the link above FileInputStream inputStream = new FileInputStream(uploadFile); byte[] buffer = new byte[4096]; int bytesRead = -1; while ((bytesRead = inputStream.read(buffer)) != -1) { //The code stuck here. //using if (Thread.interrupted()) doesn't help //as the write blocks when the network cable //removed from the router outputStream.write(buffer, 0, bytesRead); } outputStream.flush(); inputStream.close(); writer.append(LINE_FEED); writer.flush(); } </code></pre>
10,587,962
0
How to clean-up HTTP::Async if still in use <p>I am using Perl library <a href="http://search.cpan.org/~evdb/HTTP-Async-0.10/lib/HTTP/Async.pm" rel="nofollow">HTTP::Async</a> as follows:</p> <pre><code>use strict; use warnings; use HTTP::Async; use Time::HiRes; ... my $async = HTTP::Async-&gt;new( ... ); my $request = HTTP::Request-&gt;new( GET =&gt; $url ); my $start = [Time::HiRes::gettimeofday()]; my $id = $async-&gt;add($request); my $response = undef; while (!$response) { $response = $async-&gt;wait_for_next_response(1); last if Time::HiRes::tv_interval($start) &gt; TIME_OUT; } ... </code></pre> <p>When <code>while</code> loop timeout and script ends, I experience the the following error message: </p> <pre><code>HTTP::Async object destroyed but still in use at script.pl line 0 HTTP::Async INTERNAL ERROR: 'id_opts' not empty at script.pl line 0 </code></pre> <p>What are my options? How can I "clean-up" HTTP::Async object if still in use, but not needed anymore?</p>
11,258,134
0
IsHandledCreated is set to false but during runtime it is set to true? <p><strong>Hi,</strong></p> <p>I have the following code that is runned during Application.Exit : </p> <pre><code> if (InvokeRequired &amp;&amp; this.IsHandleCreated) { this.Invoke(new Action(() =&gt; EndUpdate(Caller))); return; } </code></pre> <p>This throws the exception : <strong>Invoke or BeginInvoke cannot be called on a control until the window handle has been created</strong> but only when application is exeting.</p> <p>The strange part is that when debugger breaks for the error I can see that both InvokeRequired and IsHandledCreated is set to false so im not sure how it manage to get to the internal code(this.Invoke)?</p> <p>In this case I just want to close the application without any exceptions.</p>
16,960,390
0
<pre><code>class A_Class { Ref&lt;string&gt; link; void A_Class( Ref&lt;string&gt; link) { this.link= link; } void somefunction( string str ) { if(link.Value.Length &gt; 2) link.Value = str; } } public class Ref&lt;T&gt; { private Func&lt;T&gt; getter; private Action&lt;T&gt; setter; public Ref(Func&lt;T&gt; getter, Action&lt;T&gt; setter) { this.getter = getter; this.setter = setter; } public T Value { get { return getter(); } set { setter(value); } } } </code></pre>
33,041,779
0
Show page from another URL <p>For, example, if I have this working link: </p> <pre><code>/test1/index.php?prop1=val1 </code></pre> <p>And I have this HTML tag: </p> <pre><code>&lt;a href="/test2-val2/"&gt;link&lt;/a&gt; </code></pre> <p>How can I use this tag for opening the first link with the following content: </p> <pre><code>/new_link-test1/index.php?prop2=val2 </code></pre> <p>My guess was to use <code>.htaccess</code>: </p> <pre><code>RewriteRule ^new_link-(.*)/$ /test1/index.php?$1 [L] </code></pre> <p>It works fine until I have the following next URL: </p> <pre><code>/new_link-(.*)/?other_params=other_values </code></pre> <p>with additional unusable parameters which show after page manipulations.</p> <p>And when this URL opens, it doesn't show me the content on working link. </p> <p>How can I change <code>.htaccess</code> to fix this?</p>
10,089,156
0
<p><em>null</em> value from database has its own special type:</p> <pre><code>if (r["Varandas"] != DBNull.Value &amp;&amp; r["Varandas"] != null) </code></pre> <p>To make it more elegant you can write some simple function or even extension for the DataRow class.</p>