pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
21,140,590 | 0 | Dynamic INSERT Statement in Python <p>I am working on updating some Python code I have been working with and was looking for some advice on the best way to deal with an idea I am working with. The part of my code that I wish to change is :</p> <pre><code>my_reader = csv.reader(input, delimiter = ',',quotechar='|') mouse.executemany("INSERT INTO Example_Input (ID,Name,Job,Salary) VALUES (?,?,?,?)", my_reader) </code></pre> <p>The code works. My question is, can I change the "(?,?,?,?)" into something more dynamic like 'range()' to allow user input. I understand that I would also have to have a dynamic create table statement, so another solution might be to count the number of inputs. </p> <p>To be a little more clear: for example if I had raw_input("How many variables does the table contain?: ") and the input was 2, the program would know to run as if (?,?).</p> <p>Thoughts?</p> <p>(also I am using SQLite3 and python 2.7)</p> |
17,279,971 | 0 | <p>Permanent network settings are stored in various files in <code>/etc/networking</code> and <code>/etc/network-scripts</code>. You could use <code>diff</code> to compare what's in those files between the system. However, that's just the network stuff (static v.s. dynamic, routes, gateways, iptables firewalls, blah blah blah). If there's no differences there, you'll have to start expanding the scope of your search.</p> |
25,142,512 | 0 | Powershell Http post request <p>Read over the stackoverflow for the answer, still can't find what causing this..</p> <p>Trying to connect and send a POST request using powershell, and getting "unable to connect to remote server" error. Tried 3 different dummy servers like <a href="http://posttestserver.com/post.php" rel="nofollow">http://posttestserver.com/post.php</a></p> <p>Script:</p> <pre><code>Get-ExecutionPolicy [string]$url = "http://posttestserver.com/post.php" function Execute-HTTPPostCommand() { param([string]$target = $null) #$username = "administrator" #$password = "mypass" $webRequest = [System.Net.WebRequest]::Create($target) $webRequest.ContentType = "text/html" $post = "abcdefg" $PostStr = [System.Text.Encoding]::UTF8.GetBytes($Post) $webrequest.ContentLength = $PostStr.Length $webRequest.ServicePoint.Expect100Continue = $false #$webRequest.Credentials = New-Object System.Net.NetworkCredential -ArgumentList $username, $password #$webRequest.PreAuthenticate = $true $webRequest.Method = "POST" try { $requestStream = $webRequest.GetRequestStream() } catch { write-host $_.Exception } $requestStream.Write($PostStr, 0,$PostStr.length) $requestStream.Close() [System.Net.WebResponse]$resp = $webRequest.GetResponse(); $rs = $resp.GetResponseStream(); [System.IO.StreamReader]$sr = New-Object System.IO.StreamReader -argumentList $rs; [string]$results = $sr.ReadToEnd(); return $results; } Execute-HTTPPostCommand $url [System.GC]::Collect() </code></pre> |
10,606,113 | 0 | <p>Subtract one hour from the date/time and format <em>that</em>.</p> |
1,486,859 | 0 | <pre><code>echo sprintf('-%u',abs(-123)); </code></pre> <p>or</p> <pre><code>$n = -123; echo sprintf("%s%u", $n < 0 ? "-":"", abs($n)); </code></pre> <p>Though if you actually want to see the two's complement unsigned value of a negative number restricted to 32 bits just do:</p> <pre><code>echo sprintf("%u", $n & 0xffffffff); </code></pre> <p>And that will print <code>4294967173</code> on all systems.</p> |
673,607 | 0 | <p>According to the <a href="http://msdn.microsoft.com/en-us/library/aa260631(SQL.80).aspx" rel="nofollow noreferrer">documentation</a>, the Transact-SQL <strong>timestamp</strong> data type is just an incrementing number and does not preserve a date or a time. You can't convert that to a meaningful <code>DateTime</code> value.</p> <p>The documentation says that it's an 8-byte value. So, if it's stored in a <code>System.Data.Linq.Binary</code>, you could convert it to a <code>long</code> with this code:</p> <pre><code>System.Data.Linq.Binary timestampValue; // Somehow get a reference to the SQL timestamp you're interested in // Use BitConverter to convert the 8 bytes to a long long timestampLong = BitConverter.ToInt64(timestampValue.ToArray(), 0); </code></pre> <p>You could try to convert that value to a <code>DateTime</code> by calling the constructor that takes a <code>ticks</code> value, but the results would be meaningless. You might also encounter an exception if the <code>ticks</code> value is out of range.</p> |
34,860,032 | 0 | HighCharts - Horizontal line with the zoomed average of the values <p>I need to display the average of the values of my 2 datasets, but with a specific characteristic: when the users zoom the chart, the average line is recalculated ONLY with the values of the zoomed area. How is this done?</p> <p>Here is my JS:</p> <pre><code>$(function () { $('#container').highcharts({ chart: { type: 'scatter', zoomType: 'xy' }, title: { text: 'Test' }, subtitle: { text: '' }, xAxis: { type: 'datetime', title: { enabled: true, text: 'Date' }, startOnTick: true, endOnTick: true, showLastLabel: true }, yAxis: { title: { text: '' } }, legend: { layout: 'vertical', align: 'left', verticalAlign: 'top', x: 100, y: 70, floating: true, backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF', borderWidth: 1 }, plotOptions: { scatter: { marker: { radius: 5, states: { hover: { enabled: true, lineColor: 'rgb(100,100,100)' } } }, states: { hover: { marker: { enabled: false } } }, tooltip: { headerFormat: '<b>{series.name}</b><br>', pointFormat: '{point.x} date, {point.y} dose' } } }, series: [{ name: 'ag', color: 'rgba(223, 83, 83, .5)', data: [[1426719600000,0.9659],[1426719600000,0.8928],[1445205600000,1.6428],[1445205600000,1.4711],[1445205600000,1.4209],[1445205600000,1.9574],[1445205600000,1.1226],[1445205600000,0.8159],[1445205600000,1.0114],[1445205600000,0.9168],[1445464800000,1.175],[1445464800000,1.2219],[1445464800000,1.2641],[1445464800000,1.3006],[1445464800000,0.9375],[1445464800000,0.8966],[1445464800000,0.9374],[1445464800000,1.0811]] }, { name: 'cf', color: 'rgba(119, 152, 191, .5)', data: [[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.015],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.265],[1445378400000,2.015],[1445378400000,2.015],[1445378400000,2.015],[1445464800000,1.2254],[1445464800000,1.1065],[1445464800000,1.3482],[1445464800000,1.3015],[1445292000000,1.2297]] }] }); }); </code></pre> <p>Thanks in advance!</p> |
40,049,973 | 0 | htaccess add index.php to the route with more paths after it <p>I am building a REST using framework. Normally I can call my web services by going to this route</p> <blockquote> <p><a href="https://www.domainname.com/webservices/index.php/something/else/here" rel="nofollow">https://www.domainname.com/webservices/index.php/something/else/here</a></p> </blockquote> <p>Now I want to be able to hide index.php but still call the same route like this</p> <blockquote> <p><a href="https://www.domainname.com/webservices/something/else/here" rel="nofollow">https://www.domainname.com/webservices/something/else/here</a></p> </blockquote> <p>Currently I am able to get 200-OK from only going up to webservices/</p> <p>using the following htaccess rewrite:</p> <blockquote> <p>RewriteRule ^webservices/(.*)/$ webservices/index.php/$1 [R,L]</p> </blockquote> <p>however, everything after the webservices/ will give me a 404 not found</p> <p>here is an example.</p> <ul> <li>webservices/ ---200-OK (I see the page of webservices/index.php</li> <li>webservices/something ---404 not found</li> <li>webservices/some/thing ---404 not found</li> </ul> <p>I guess the biggest question is how do I add the paths after I add the index.php (the level of paths should be dynamic)</p> <p>P.S. I don't want to display index.php in the URL at all</p> |
3,748,451 | 0 | Quick Question About IIS 7 Asp.Net Setup <p>I have been trying to configure a small website on a Windows Server 2008 running IIS 7. Unfortunately, when trying to load the website I keep getting the error: <em>Server Error 401 - Unauthorized: Access is denied due to invalid credentials.</em></p> <p>The permissions on the website folder include <code>read</code>, <code>write</code>, and <code>execute</code> for user <code>ASP.NET v4.0</code>. I even clicked "Check names" before adding the user to folder, to make sure that I spelled everything correctly. But the error continues to show. Also, I noticed that everything works okay if I add "Users" to the permissions for the folders containing the website, but I don't see why this should be necessary. I only want to give <code>ASP.NET v4.0</code> access to the folder.</p> <p>Some other noteworthy points include that I'm using the <code>ASP.NET v4.0</code> application pool, that the managed pipeline is integrated, and that load user profile is set to true.</p> <p>If anyone has any ideas, I'd appreciated the help. I'm stumped!</p> <p>EDIT: Does it matter that the website is on the d: drive? I just assumed this wasn't important...</p> |
36,316,094 | 0 | Encode/Decode (Encrypt/Decrypt) datetime var in vb6 <p>I want to encode a datetime var into a 8-byte alphanumeric string that can be decoded later. I don't need too much security.</p> <pre><code>201603301639 -> X5AHY6J9 </code></pre> <p>and viceversa.</p> |
16,316,127 | 0 | <p>A global variable declared outside function cannot be accessed inside the function try declaring global iinside the function itself.</p> <p>Change it to this</p> <pre><code>function kit($name) { global $foo; if($foo == $name){echo 'Works';}else{echo 'Does not work';} } </code></pre> |
20,611,140 | 0 | Use object from DLL instead of WebProxy in amsx web service <p>I have a solution with two projects in VS2012. One is an old ASMX web service project and one is a DLL project called Utils.</p> <p>The Web Service project makes alot of use of the Utils project and the idea is that this DLL will also be shipped to clients because they will need functionality from it as well.</p> <p>So a <code>WebMethod</code> in the Web Service project looks like this:</p> <pre><code>using Utils; [WebMethod] [XmlType(Namespace = "http://url/invoice")] public void CheckInvoice(CToken token) { ... } </code></pre> <p>So in this example the Web Method <code>CheckInvoice</code> expects an instance of class <code>CToken</code>, which is in the <code>Utils</code> namespace.</p> <p>But when i generate the proxy class of the Web Service, then the exposed method <code>CheckInvoice</code> expects a <code>CToken</code> instance from the <code>ServiceProxy</code> namespace instead of the <code>Utils</code> namespace.</p> <p>But the clients also have the <code>Utils</code> DLL. So how can i force generation of the proxy to use the <code>CToken</code> class from the <code>Utils</code> namespace and not from the (default) ServiceProxy namespace?</p> <p>--</p> <p>When i add the <code>Service Reference</code> then i checked the <strong><em>Reuse types in referenced assemblies</em></strong> checkbox and also <strong><em>Reuse types in all referenced assemblies</em></strong>. But this doesn't make any difference. Maybe this only works for WCF web services? I'm looking for a solution for ASMX web services.</p> <p>Anyone any idea how to solve this problem?</p> |
20,979,364 | 0 | <p>Try to change:</p> <pre><code>$stmt->bindParam(':username', $username, ':password', $password); </code></pre> <p>to:</p> <pre><code>$sth->bindParam(':username', $username, PDO::PARAM_STR); $sth->bindParam(':password', $password, PDO::PARAM_STR); </code></pre> <p>I have tried again to edit your code, you don't need to use global variable, because you instantiate the PDO class directly and use it on the fly. </p> <pre><code>try { $pdo = new PDO('mysql:host=localhost;dbname=redgrace_staxapp', 'root', ''); $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch (PDOException $e) { die('MySQL connection fail! ' . $e->getMessage()); } function delete_user($username, $password) { if (username_exists($username)) return TRUE; $query = "DELETE FROM users WHERE username = :username and password = :password"; $stmt = $pdo->prepare($query); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->bindParam(':password', $password, PDO::PARAM_STR); $stmt->execute(); } </code></pre> |
7,772,431 | 0 | <p>How about</p> <pre><code>(!!!) :: [a] -> Int -> Maybe a xs !!! n = Maybe.listToMaybe $ drop n xs </code></pre> |
36,466,602 | 0 | when button click to activated mouse scroll in android <p>After button click to mouse scroll to be activted,then scroll up to value increment and scroll down to value decrement.Button inside code here not working, my sample code here,please analysis code to help me.</p> <pre><code>enter code here public class MainActivity extends Activity { Button button; int x,f; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button=(Button)findViewById(R.id.button1); button.setOnTouchListener(new OnTouchListener() { @SuppressLint("NewApi") @Override public boolean onTouch(View arg0, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f) //selectNext(); { x=Integer.parseInt(button.getText().toString()); f=x+5; button.setText(""+f); } else { x=Integer.parseInt(button.getText().toString()); f=x-5; button.setText(""+f); return true; } } return false; } }); </code></pre> <p>} </p> |
9,949,696 | 0 | Fetching only few attributes of a document in couchdb <p>I have a site where I have documents that are around 1MB in size. To avoid any kind of conceptual joins I have put all related data in a single document. </p> <p>Now I often need to fetch only one or two attributes of a document. Each document has over 10 attributes many of which are pretty large. I can not go on writing views for every single combination of the attributes. </p> <p>How should I do it ? The only way I see is creating views on the fly and then using those views. OR is there any better method ? </p> |
402,892 | 0 | <p>I don't think it's necessary in most web-pages. If you're entering information, and you enter it wrong, then you'll need to go through every wrong text-box and re-enter it. The reset button is, at minimum, one extra button click on top of that.</p> <p>If you don't want to enter information, you just don't click the submit button. </p> <p>The only time I see a reset button being useful is if you have a multi-page workflow, and need to be able to start from scratch. Even then I would suggest re-designing the workflow.</p> |
24,325,114 | 0 | <p><a href="http://guides.rubyonrails.org/active_record_validations.html#conditional-validation" rel="nofollow"><strong>Conditional Validations</strong></a></p> <p>Was going to suggest you use some sort of <a href="http://guides.rubyonrails.org/active_record_validations.html" rel="nofollow">conditional validations</a>, as follows (then I read the comments):</p> <pre><code>#app/models/consumer.rb class Consumer < ActiveRecord::Base ... validates :password_confirmation, presence: {message: "Retype password!"}, if: Proc.new {|a| a.password.present? } end </code></pre> <p>This is the best I can provide for your particular situation - I've not created a <code>password</code> signup / authentication procedure myself (always relied on other classes), so if you wanted to use <code>has_secure_password</code> etc - I'll have to update my answer to help</p> |
30,197,400 | 0 | <p>A static site has 3 components: </p> <ol> <li>HTML files (or other content to serve via the web, like .txt files)</li> <li>referenced assets (js, images, css)</li> <li>a web server</li> </ol> <p>There is no database from which data is retrieved, compared to something like wordpress where all of your posts and pages live in a database. There is no server-side scripting engine with which to process information and render content.</p> <p>Static site generators exist to provide you with tools like templating, shared data, and custom tags to assist in the creation of the static HTML pages that your web server will be serving.</p> <p>The benefits of a static site are:</p> <ul> <li>Security. The web server is the only moving part.</li> <li>Portability. The HTML files will render the same when served from your local machine as they will on the web.</li> <li>Speed. When almost everything is cacheable, compressed, and doesn't require any data crunching, things load very fast.</li> </ul> |
4,252,065 | 0 | If I'm trying to learn OpenGL ES 2.x, is an OpenGL 3.0 book suitable? <p>I've been doing about an hour of research on this, coming from zero graphics experience. The official website says that OpenGL ES 2.x is defined relative to OpenGL 2.0. However, I've read that a major difference between 2.0/3.0 is the deprecation of the fixed-function pipeline (no idea what that is at this point), and that ES 2.x doesn't have a fixed-function pipeline. These last details are what's confusing me.</p> <p>The reason I'm asking is because I'm considering buying the <a href="http://rads.stackoverflow.com/amzn/click/0321712617" rel="nofollow">OpenGL Superbible 5th Edition</a>. According to the author and some Amazon reviewers, this book is heavily biased towards OpenGL 3.0, and it's actually recommended to get earlier editions for OpenGL 2.0. Considering that I'm mainly interested in ES, which OpenGL version is most relevant, 2.0 or 3.0?</p> <p>Also, if for some reason I decide to go with ES 1.1, I'm assuming a 2.0 book is the right choice?</p> |
17,428,887 | 0 | Set multiple alarms using sqlite database but only one alarm remaining <p>I set multiple alarms using SQLite, but when I set the clock, there is just one alarm that is the last one I set. How can I fix this?</p> <pre><code>public class alert extends Activity{ DatePicker pickerDate; TimePicker pickerTime; Button buttonSetAlarm; Button insertButton;`enter code here` TextView info; Context mContext; AlarmManager mAlarmManager; dalAlarm dbAlarm ; SQLiteOpenHelper dbHelper; SQLiteDatabase database; final static int RQS_1 = 0; dalAlarm dalAl = new dalAlarm(this); public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.alertscreen); info = (TextView)findViewById(R.id.info); pickerDate = (DatePicker)findViewById(R.id.pickerdate); pickerTime = (TimePicker)findViewById(R.id.pickertime); Calendar now = Calendar.getInstance(); pickerDate.init( now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), null); pickerTime.setCurrentHour(now.get(Calendar.HOUR_OF_DAY)); pickerTime.setCurrentMinute(now.get(Calendar.MINUTE)); buttonSetAlarm = (Button)findViewById(R.id.setalarm); buttonSetAlarm.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { Calendar current = Calendar.getInstance(); Calendar cal = Calendar.getInstance(); cal.set(pickerDate.getYear(), pickerDate.getMonth(), pickerDate.getDayOfMonth(), pickerTime.getCurrentHour(), pickerTime.getCurrentMinute(), 00); //dbAlarm.addNewAlarm(new dalHelper_alarm(pickerTime.getCurrentHour(),pickerTime.getCurrentMinute(),cal.getTime().toString())); if(cal.compareTo(current) <= 0){ Toast.makeText(getApplicationContext(), "Invalid Date/Time", Toast.LENGTH_LONG).show(); }else{ // dbAlarm.addNewAlarm(new dalHelper_alarm(pickerTime.getCurrentHour(),pickerTime.getCurrentMinute(),cal.getTime().toString())); setAlarm(cal); database(); } } }); } public void setAlarm(Calendar targetCal) { info.setText("\n\n***\n" + "Alarm is set@ " + targetCal.getTime() + "\n" + "***\n"); dalAlarm db = new dalAlarm(alert.this); dalHelper_alarm test = new dalHelper_alarm(pickerTime.getCurrentHour(),pickerTime.getCurrentMinute(),targetCal.getTime().toString()); db.addNewAlarm(test); } public void newAlarm(Calendar newCal){ Intent intent = new Intent(getBaseContext(), popUp.class); PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT); AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, newCal.getTimeInMillis(), pendingIntent); } public void database(){ ArrayList<dalHelper_alarm> alarm = dalAl.getAllAlarm(); Calendar newCal = Calendar.getInstance(); newCal.set(pickerDate.getYear(), pickerDate.getMonth(), pickerDate.getDayOfMonth(), alarm.get(0).getHour(), alarm.get(0).getMin(), 00); info.setText("\n\n*** \n" + "Alarm is set@ " + newCal.getTime() + "\n" + "***\n"); newAlarm(newCal); } } </code></pre> |
3,682,545 | 0 | <p>I followed that steps that pygorex1 posted but also replaced lines 191-195 in the <code>Select.php</code> file, because I was still getting another similar error about the <code>getPrice()</code>. I have Magento ver. 1.3.2.4. </p> <p>Original code from lines 191-195: </p> <pre><code>$result = $this->_getChargableOptionPrice( $option->getValueById($optionValue)->getPrice(), $option->getValueById($optionValue)->getPriceType() == 'percent', $basePrice ); </code></pre> <p>Here is the code I created to replace lines 191-195: </p> <pre><code>$z= $option->getValueById($optionValue); $result = is_object($z) ? $z ->getPrice() : null; $zz = $option->getValueById($optionValue); $result = is_object($zz) ? $zz ->getPriceType() == 'percent' : $basePrice; </code></pre> <p>FYI - I am NOT a PHP programmer. I just happened to figure out how to rework the code to make fix this problem based on pygorex1's code. So, there is a good chance I didn't write it correctly. However, it did fix the problem for me (which I am rather proud of :)</p> |
9,053,635 | 0 | <p>The environment listed in the question compiles fine.</p> |
16,528,284 | 0 | Karma + Rails: File structure? <p>When using the <em>karma</em> javascript test library (née Testacular) together with Rails, where should test files and mocked data go be placed?</p> <p>It seems weird to have them in /assets/ because we don’t actually want to serve them to users. (But I guess if they are simply never precompiled, then that’s not an actual problem, right?)</p> |
14,067,583 | 0 | <p>That's not as simple as you might think.</p> <p>The canvas doesn't actually "store" the text, it's just a grid of pixels. It's not aware of elements drawn on the canvas or anything. As such, the canvas can't "hyperlink" a text element.</p> <p>One of the options would be to add a <code>click</code> event listener to the canvas, get the <code>x/y</code> of the event, and if you hit the text, redirect to the url. To do this you would need to keep track of the text's position (rotation?) and size, manually.</p> <p>Another, possibly easier option, would be to simply add a element on top of the image that contains the text. Then, you can simply add a hyperlink.</p> <p><strong><a href="http://jsbin.com/udukim/1/edit" rel="nofollow">Working example of a link overlaying the canvas</a></strong></p> |
3,317,881 | 0 | How to blur 3d object? (Papervision 3d) <p>How to blur 3d object? (Papervision 3d) And save created new object as new 3d model? (can help in sky/clouds generation)</p> <p>Like in 2d picture I've turn rectangel intu some blury structure</p> <p><img src="http://superior0.narod.ru/blur2d.jpg" alt="alt text"></p> |
27,669,001 | 0 | How can I iterate through a function with for loop? <p>I want to pass the 'y' variable to okayid but there seems to be a problem with the looping. The loop works fine with the first call of 'y' on okay.item(y) but it is not looping through okayid.item(y). It seemed to me like it was a scope problem but I am not sure.</p> <pre><code>var okay = document.getElementsByClassName("Okay"); var okayid = document.getElementsByClassName("OkayID"); var numberOkays = okay.length; for(y = 0; y <= numberOkays; y++){ okay.item(y).onclick = function(){ xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ alert('vote Sent to picture with id = ' + okayid.item(y).innerHTML); } }; xmlhttp.open("GET", "ajax/vote.php", true); xmlhttp.send(); }; } </code></pre> <p>Here is the html ...</p> <pre><code><a class="Link1A Okay" href="#"><span class="OkayID">[id]</span><div class="Vote1A">Okay</div></a> </code></pre> |
26,350,839 | 0 | <p>my bad. The problem was in this.</p> <pre><code>UInt32 keySize = 32; </code></pre> <p>Changed it to</p> <pre><code>UInt32 keySize = 256; </code></pre> <p>and evrything is good</p> |
36,411,804 | 1 | this constructor takes no arguments: python <pre><code>import random import sys import os class Animal : __name="" __height=0 __weight=0 __sound=0 def __init__(self, name, height, weight, sound): self.__name=name self.__height=height self.__weight=weight self.__sound=sound def set_name(self,name): self.__name =name def get_name(self): return self.__name def set_height(self,height): self.__height =height def get_height(self): return str(self.__height) def set_weight(self,weight): self.__weight =weight def get_weight(self): return str(self.__weight) def set_sound(self,sound): self.__sound =sound def get_sound(self): return self.__sound def get_type(self): print("Animal") def toString(self): return"{} is {} cm tall and {} kilograms and say{}".format(self.__name, self.__height,self.__weight,self.__sound) cat = Animal('ruby',33,10,'meow') print(cat.toString()) </code></pre> <p>Error message:</p> <pre><code>Traceback (most recent call last): File "python", line 37, in <module> TypeError: this constructor takes no arguments </code></pre> |
17,133,315 | 0 | <p>Even though there are some basic constructs java, that are replaced by a portion of java like String concatenation where</p> <pre><code>"Colour: " + this.getColour() </code></pre> <p>means</p> <pre><code>new StringBuilder(new String(new char[] {'C', 'o'..., ' '}).intern()).append(this.getColour()); </code></pre> <p>However, I don't think this applies to any keyword. Neither super, nor this, throws, extends, and so on can be impleted by other java expressions. They build up the base of the language and are not just syntactic sugar to work efficiently with this language. Thus they build by byte codes and other basic constrcts.</p> |
21,274,132 | 0 | Produce an iCal appointment and subsequent updates via email but don't offer accept/decline options <p>We are writing a system that has a booking feature, and we are planning to have it send *.ics files via email to attendees so they can easily add appointments to their calendars. The types of events are things like training courses (e.g. 3pm in the boardroom).</p> <p>We've got this working to the point that the system sends the *.ics, and using Gmail and Outlook, the user can accept the appointment which, is then added to their calendar.</p> <p>Sometimes an event changes (e.g. a course is cancelled or delayed until the following day). Our software can send out a new *.ics file, and Gmail/Outlook correctly recognize that this is an update to the original appointment and gives the option to accept/decline again.</p> <p>The trouble is, we don't have a mechanism to receive via email the accept/decline responses that standard email clients automatically send when the user accepts/declines an appointment. Therefore, clicking the "decline" option could give them the false sense that they have cancelled the appointment when in fact our system has no idea what they've done within their calendar.</p> <p>We always want the bookings to be instigated by the user directly on the website, and the *.ics via email is merely a convenience to help them remember to attend. Similar to a flight booking, if the passenger really intends to cancel, something a little more definitive is required than clicking "decline" in Outlook. With a few flight bookings I've made, the carrier sent me a *.vcs file which contains "METHOD:PUBLISH" instead of "METHOD:REQUEST" which sounds closer to what we want, although in testing, this *.vcs file was not recognized by GMail as an appointment.</p> <p>So the question is, can we email appointments, with subsequent updates, that will be automatically be recognized by Outlook, GMail & Lotus Notes, but prevent the user from thinking they can cancel/decline the entire booking from within their own calendar tool? If so, how?</p> <p><strong>UPDATE 1</strong></p> <p>I think I found the issue with the METHOD:PUBLISH airline booking example I was experimenting with - it was for a past date. Using a future date, We can now use METHOD:PUBLISH to allow people to add events to their calendar without requiring accept/decline. Problem now is that if the event is cancelled or changed, we cannot get a new *.ics to be recognized as overriding the original. We are allocating a unique UID and incrementing the SEQUENCE field to the event, but I don't know whether the spec allows a "PUBLISH"-ed event to elegantly handle updates (date, time, location, description etc.)</p> <p><strong>UPDATE 2</strong></p> <p>Okay, well I've just been experimenting with the sample *.ics files from the <a href="http://tools.ietf.org/html/rfc5546" rel="nofollow">spec</a>. Using the examples from 4.1.1 "A Minimal Published Event" and 4.1.2 "Changing a Published Event" I am sending what I believe is a spec-compliant published event, and subsequent update. Both Outlook 2010 and GMail see the update as a NEW EVENT. So at this point I'm going to assume Outlook and GMail have only partial support for *.ics files, give up on elegant updates and simply instruct the user to delete their old calendar appointment if I send them a new one.</p> |
10,511,588 | 0 | Extjs store find all <p>Documentation of <code>Ext.data.Store</code> find method says: </p> <blockquote> <p>Finds the index of the first matching Record in this store by a specific field value.</p> </blockquote> <p>My question is how can I find indexes of all matching records in this store?</p> |
33,447,417 | 0 | <p>A macro definition cannot include preprocessor directives (anything beginning with a <code>#</code>).</p> <p>To conditionally expand to certain values requires rather involved macrology and might not always work out the way you want. The example above could be written something like this:</p> <pre><code>#define ONE_OR_TWO(...) ONE_OR_TWO_(__VA_ARGS__, 2, 1,) #define ONE_OR_TWO_(_1, _2, X, ...) X #define CAT(A, B) CAT_(A, B) #define CAT_(A, B) A ## B #define M(N) CAT(IF_, ONE_OR_TWO(CAT(IS_, N)))({\ code; \ code; \ }, N) #define IS_5 , #define IF_1(A, B) B #define IF_2(A, B) A M(5); //-> { code; code; } M(8); //-> 8 </code></pre> <p>This is incredibly fragile though. You can only use certain types of expression as the argument to <code>M</code>, for instance - they have to have a syntactic structure that allows for concatenation, and no unwrapped commas - and it only works for predetermined values (e.g. to compare against something more complicated than a simple number is not possible with this method, because you can't build a macro name out of a more complex expression).</p> <p>But in principle, it can be done. You just need thousands upon thousands of lines of macro definitions to cover a useful set of cases beyond the trivial ones like this. You can get those by using a metaprogramming library like <a href="https://github.com/VesaKarvonen/order-pp">Order-PP</a> or <a href="http://www.boost.org/doc/libs/1_59_0/libs/preprocessor/doc/index.html">Boost.Preprocessor</a>, but be prepared for obscure error messages if you slip up in the syntax even slightly.</p> |
28,470,877 | 0 | <p>This should work for you:</p> <p>(Here i just simply go trough each innerArray with <a href="http://php.net/manual/en/control-structures.foreach.php" rel="nofollow">foreach</a>. Then i get the id from the innerArray and check if it is already in the tmp array and if not i add it to the tmp array. At the end i just simply use <a href="http://php.net/manual/en/function.array-values.php" rel="nofollow"><code>array_values()</code></a>, so that the indexes are clean and starts with 0. The <a href="http://php.net/manual/en/function.array-reverse.php" rel="nofollow"><code>array_reverse()</code></a> is to get the entire arrray in the right order)</p> <pre><code><?php $a = array( array('id'=>1, 'value'=>2), array('id'=>2, 'value'=>3), array('id'=>3, 'value'=>4), array('id'=>1, 'value'=>5), array('id'=>5, 'value'=>10), array('id'=>2, 'value'=>6), ); $tmp = array(); foreach(array_reverse($a) as $v) { $id = $v['id']; isset($tmp[$id]) or $tmp[$id] = $v; } $a = array_reverse(array_values($tmp)); print_r($a); ?> </code></pre> <p>Output:</p> <pre><code>Array ( [0] => Array ( [id] => 3 [value] => 4 ) [1] => Array ( [id] => 1 [value] => 5 ) [2] => Array ( [id] => 5 [value] => 10 ) [3] => Array ( [id] => 2 [value] => 6 ) ) </code></pre> |
10,052,374 | 0 | <p>Take the substring from the place where DS occurs using the function substr, and get the data out of it. To get the data, just parse the substring keeping a count of opening brackets. When the closing brackets start, keep a count of them. When this count and previous count become equal, you have got your data. </p> |
33,929,587 | 0 | <p>If you had the some problem as I, it's very simple. When you to go save the preferences, save like:</p> <pre><code>SharedPreferences sp = getSharedPrefenreces("Preference",MODE_PRIVATE); </code></pre> <p>And no:</p> <pre><code> SharedPreferences sp = getSharedPrefenreces("Preference's name",Context.MODE_PRIVATE); </code></pre> <p>I know how so much is important the SharedPrefenrences in some cases.</p> |
3,362,117 | 0 | <p>Try to access it via the console application with no development tools installed (aka, a live environment or a development server which do not have VS2008 installed) and try again (RE: the comment posted by Heinzi). </p> <p>If you still can then check to see if your web app is running under the correct .NET framework version (and that it's installed on the server).</p> <p>Since this appears not to be an ISAPI DLL requiring 32-bit application to be switched on, but a C# Web App. My money is there is something wrong with the web app deployment on the server and not the DLL itself.</p> <p>Also remember, if the DLL is not .NET, you need to register it on the server using regsrv32 before you can access it with your web app anyway.</p> <p>Hope I helped.</p> <p><em>edit</em></p> <p>If all other attempts fail, try to re-compile the DLL you're using setting the target to X86 on the compiler and re-reference it in your web app.</p> |
32,400,941 | 0 | Cannot make filter on rich:datatable <p>I am working on a project and there are some parts which I have not developed. Right now I have to set a filter on a table, as we use rich faces, I wanted to use the filter as in the example from <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/filteringFeature.jsf?c=filtering" rel="nofollow">exadel</a>.</p> <p>However it doesn't work, I know it may be due to the <code>filterValue</code> property, because I am not sure if I am pointing to the proper bean. Everything looks good but the filter is not there.</p> <p>Any suggestions? How can I get to know what is the proper bean? This contains only the column that I want to filter.</p> <pre><code><rich:dataTable var="_project" value="#{projectController.showDeactivateEmployees? projects : projectController.getViewableProjects(projects)}" rendered="#{not empty projectController.getViewableProjects(projects)}" styleClass="simpletablestyle" sortMode="single"> <rich:column filterBy="#{_project.name}" filterValue="#{project.name}"> <f:facet name="header">#{msg.common_Name}</f:facet> <h:outputText value="#{_project.name}" style="color:#{_project.usedHours * 100 / _project.maxHours &gt;= 75 and _project.maxHours!=0? '#d20f19' : '#000000'};"> </h:outputText> </rich:column> <rich:datatable/> </code></pre> |
16,023,713 | 0 | <p>Have you thought about bucketing by problem and stream processing the input data?</p> <p>A sample approach of this type would be:</p> <pre><code>for event in new_events: # new events to be written from the RESTful service for test in tests: # known tests you need to perform increment/decrement <test.bucket>.<sensor>.<valueX> # update the bucket as necessary # e.g. seconds_since_changed.sensor1.value3 += 1 # additionally, save each record to a standard database for long-term purposes # and to be able to rebuild/redo tests as necessary. </code></pre> <p>The ideal storage mechanism for such a transaction stream is one that lends itself well to low-latency writes/updates. NoSQL solutions work very well for this sort of work (I've personally used Redis for a similar type of analysis, but you're in no ways bound to that particular solution.)</p> |
35,522,875 | 0 | <p>So based on what I understand from your question, it looks like the padding around the input is being shrunken.</p> <p>Try this: </p> <pre><code>input:active { padding: 5px; } </code></pre> <p>Mess around with the padding and see if it effects the size when active.</p> |
33,724,145 | 0 | Can I use the OR operator or AND operator between two if..else statement? <p>Can/Should I use the OR operator or AND operator between two if..else statement?</p> <pre><code>If [statement] end if OR If [statement] end if </code></pre> |
33,349,822 | 0 | Problems implementing an editable TableView<ObservableList<String> <p>So I've been trying to implement a TableView where you can edit a column just by clicking on it, and then save the edit by pressing the enter key. I've taken at lot of the code from the answer in <a href="http://stackoverflow.com/questions/27900344/how-to-make-a-table-column-with-integer-datatype-editable-without-changing-it-to">this</a> thread. This is the result:</p> <pre><code>import com.sun.javafx.collections.ObservableListWrapper; import javafx.application.Application; import javafx.application.Platform; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import javafx.stage.Stage; public class TestEditableTable extends Application { public void start(Stage stage) { TableView<ObservableList<String>> tableView = new TableView<ObservableList<String>>(); tableView.setEditable(true); // Some dummy data. ObservableList<ObservableList<String>> dummyData = FXCollections.observableArrayList(); ObservableList<String> firstRow = FXCollections.observableArrayList("Jack", "Smith"); dummyData.add(firstRow); ObservableList<String> secondRow = FXCollections.observableArrayList("Peter", "Smith"); dummyData.add(secondRow); TableColumn<ObservableList<String>, String> firstCol = new TableColumn<ObservableList<String>, String>( "First name"); firstCol.setCellValueFactory( (TableColumn.CellDataFeatures<ObservableList<String>, String> param) -> new SimpleStringProperty( param.getValue().get(0))); TableColumn<ObservableList<String>, String> secondCol = new TableColumn<ObservableList<String>, String>( "Last name"); secondCol.setCellValueFactory( (TableColumn.CellDataFeatures<ObservableList<String>, String> param) -> new SimpleStringProperty( param.getValue().get(1))); secondCol.setCellFactory(cell -> new EditableCell()); tableView.getColumns().addAll(firstCol, secondCol); tableView.getItems().addAll(dummyData); Scene scene = new Scene(tableView); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(); } class EditableCell extends TableCell<ObservableList<String>, String> { private TextField textfield = new TextField(); // When the user presses the enter button the edit is saved. public EditableCell() { setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) { commitEdit(textfield.getText()); } }); } @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (isEmpty()) { setText(null); setGraphic(null); } else { if (isEditing()) { textfield.setText(item); setGraphic(textfield); setText(null); } else { setText(item); setGraphic(null); } } } @Override public void startEdit() { super.startEdit(); textfield.setText(getItem()); setGraphic(textfield); setText(null); } @Override public void cancelEdit() { super.cancelEdit(); setGraphic(null); setText(getItem()); } @Override public void commitEdit(String value) { super.commitEdit(value); // This works. But gives me a "Discouraged access: The type 'ObservableListWrapper<String>' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_60\lib\ext\jfxrt.jar')". ObservableListWrapper<String> ob = ((ObservableListWrapper<String>) this.getTableRow().getItem()); ob.set(1, value); // I had to put this in a Platform.runLater(), otherwise the textfield remained open. Platform.runLater(() -> { setText(value); setGraphic(null); }); } } } </code></pre> <p>And this program works OK. The cell is edited when you press the enter button. But there are two main issues with this:</p> <ol> <li><p>Once I've pressed enter and a cell has been edited. I can't edit it again by clicking on it. I need to press another row to be able to edit it again. Setting to focus on the parent of the row didn't do the trick.</p></li> <li><p>The code inside <code>commitEdit()</code> works. But it is ugly and using a <code>ObservableListWrapper</code> gives me the warning "Discouraged access: The type 'ObservableListWrapper' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_60\lib\ext\jfxrt.jar')". Also the cell index is hard coded, which wont work if I use this in many different columns.</p></li> </ol> <p>None of the issues mentioned above is acceptable.</p> <p>The final implementation must support restriction of the input in the textfield. As far as I understand it this means that I need to have access to the <code>TextField</code> object displayed in the cell, as in my current implementation.</p> |
468,688 | 0 | <p>Update the class to be a partial class (might already be from the code generation) and then create another code file in your solution which won't be overridden. In there create a partial class of the same name (in the same namespace) as the generated code and add the property to this. This will have the benefit of not being overridden when the web service code is regenerated.</p> <p>When you call the generated code class you then should be able to access the property which you have added to the other part of the partial class.</p> <p>Hope this helps.</p> |
10,988,142 | 0 | <p>If you run <code>gem list -d rails</code> you'll get an output similar to this.</p> <pre><code>*** LOCAL GEMS *** rails (3.2.3) Author: David Heinemeier Hansson Homepage: http://www.rubyonrails.org Installed at: /Users/bjedrocha/.rvm/gems/ruby-1.9.3-p194@jwb Full-stack web application framework. </code></pre> <p>Note the <code>installed at</code> directive. The part after the <code>@</code> indicates the gemset. So if you've installed Rails without first creating and switching to a named gemset, chances are that it is installed under the <code>@global</code> gemset (a default for RVM). If this is your case, I would switch into the global gemset and uninstall Rails. Once its uninstalled, you can switch back to your named gemset and it will use the Rails version installed in this gemset</p> <pre><code>rvm use 1.9.3@global gem uninstall rails rvm use 1.9.3@mygemset </code></pre> <p>Hope this helps</p> |
9,076,318 | 0 | Double-click ad unit lookup for div failed (DFP error)? <p>Just added double-click DFP ads to a friend's site. Realized that only one of four ads are appearing. Although the status of all 4 ads are "active", 3 are not appearing.</p> <p>I ran the DFP debugger and got this output:</p> <pre><code>Ad unit lookup for div div-gpt-ad-1327994622973-0 failed. Div div-gpt-ad-1327994622973-0 is not mapped to a known ad unit. </code></pre> <p>It doesn't appear to be a javascript issue, but the code for these ads was taken directly from the "generated tags" and these units are active. This occurs in multiple browsers.</p> <p>Could this be a caching issue? How can a cache buster be implemented for ads only? Thanks.</p> |
9,995,114 | 0 | how to make browsers to offer password and email store after log in <p>What shall I modify on this code to make it clear to the browsers that "you can save this fields". (For that users who don't want to enter them any time)</p> <p>(browser info and resolution are hidden fields for statistics)</p> <pre><code><form id='log_in' action='/_fn/log_in.php' method=post> <ul id='m1_bal'> <!--<li><a HREF='/print' TITLE='belépés' tabindex=3><img WIDTH=32 HEIGHT=32 ALT='' SRC='/images/menu1/nyil.png'></a></li>--> <li><input type=submit value='belépés' tabindex=3></li> <li><!--[if IE]>jelszó:<![endif]--><input name='password' tabindex=2 type=password placeholder='jelszó'></li> <li><!--[if IE]>email:<![endif]--><input name='email' tabindex=1 type=text placeholder='email'></li> <input name='felbontas' type=hidden> <input name='bongeszo' type=hidden> <input name='href' type=hidden> </ul> </form> </code></pre> <p>The javascript code:</p> <pre><code>$('#log_in').submit(function(e){ //browser info var b = "?"; if( $.browser.msie)b = "IE"; if( $.browser.webkit)b = "Webkit";//Chrome/Safari if( $.browser.opera)b = "Opera"; if( $.browser.mozilla)b = "Mozilla"; var bongeszo = b+" "+$.browser.version; //resolution var felbontas = $(document).width()+"x"+$(document).height(); /* METHOD 2 $(this).find('input[name=bongeszo]').val(bongeszo); $(this).find('input[name=felbontas]').val(felbontas); $(this).find('input[name=href]').val(window.location.href); */ e.preventDefault(); $.post($(this).attr('action'),{ email: $(this).find('input[name=email]').val(), password: $(this).find('input[name=password]').val(), felbontás: felbontas, böngésző: bongeszo },function(answer){ if(answer=="1")window.location.reload();else alert(answer); }); }); </code></pre> <p>If you say: dont use ajax, I tell, that I have tired it without it too. See: METHOD 2</p> |
28,840,717 | 0 | <p>I only see two options here. Unfortunately, one of them isnt feasible and the other one doesnt exactly fit your criterions. Let's see:</p> <ol> <li>Write a PDF interpretor. Obviously, this cannot be done easily, but it is the only way to get rid of files. Why? Because typical applications are not designed to receive some .Net stream or byte array, they take file path and read them the way they want.</li> <li>Add some third party PDF reader. <a href="http://stackoverflow.com/questions/549504/net-open-pdf-in-winform-without-external-dependencies">This Q/A</a> should cover what you need. As mentionned, this solution wont be a perfect fit since it will need you to at least save the file to a temporary location. Let's say you use Acrobat or Foxit, you cannot pass a stream directly, they need a file path.</li> </ol> <p>EDIT: Why do you want to avoid writing a file? If you draw the big picture, we might be able to figure a way arround your problem.</p> |
9,127,044 | 0 | NSMutableArray as instance variable alway null <p>After many hours wasted, I officially turn to the experts for help!</p> <p>My problem lies with using a NSMutableArray as an instance variable, and trying to both add objects and return the array in a method in my class. I am obviously doing something fundamentally wrong and would be grateful for help...I have already tried all the suggestions from other similar questions on stackoverflow, read apples documentation, and basically all combinations of trial and error coding I can think of. The mutable array just alway returns (null). I've even tried creating properties for them, but still the array returns (null) and then I also am running into memory management problems due to the retain while setting the property, and the init in the init method for the class.</p> <p>Here is what I am trying to do:</p> <p>1) Loop through a series of UISwitches and if they are 'switched on', add a string to the NSMutableArray</p> <p>2) Assign this mutable array to another array in another method</p> <p>Any help much appreciated,</p> <p>Andy</p> <p>And for some code...</p> <p>fruitsViewController.h</p> <pre><code>#import <UIKit/UIKit.h> @interface fruitsViewController : UIViewController { NSMutableArray *fruitsArr; UISwitch *appleSwitch; UISwitch *orangeSwitch; } @property (nonatomic,retain) NSMutableArray *fruitsArr; // ADDED ON EDIT @property (nonatomic,retain) IBOutlet UISwitch *appleSwitch; @property (nonatomic,retain) IBOutlet UISwitch *orangeSwitch; - (IBAction)submitButtonPressed:(id)sender; @end </code></pre> <p>fruitsViewController.m</p> <pre><code>#import "fruitsViewController.h" @implementation fruitsViewController @synthesize fruitsArr; // ADDED ON EDIT @synthesize appleSwitch, orangeSwitch; /* COMMENTED OUT ON EDIT -(id)init { if (self = [super init]) { // Allocate memory and initialize the fruits mutable array fruitsArr = [[NSMutableArray alloc] init]; } return self; } */ // VIEW DID LOAD ADDED ON EDIT - (void)viewDidLoad { self.fruitsArr = [[NSMutableArray alloc] init]; } - (void)viewDidUnload { self.fruitsArr = nil; self.appleSwitch = nil; self.orangeSwitch = nil; } - (void)dealloc { [fruitsArr release]; [appleSwitch release]; [orangeSwitch release]; [super dealloc]; } - (IBAction)submitButtonPressed:(id)sender { if ([self.appleSwitch isOn]) { [self.fruitsArr addObject:@"Apple"; // 'self.' ADDED ON EDIT } if ([self.orangeSwitch isOn]) { [self.fruitsArr addObject:@"Orange"; // 'self.' ADDED ON EDIT } NSLog(@"%@",self.fruitsArr); // Why is this returning (null) even if the switches are on?! [fruitsArr addObject:@"Hello World"; NSLog(@"%@",self.fruitsArr); // Even trying to add an object outside the if statement returns (null) } @end </code></pre> |
20,969,866 | 0 | <p>This way you can set the fontSize and can handle it in just one <code>class</code>.</p> <h3>1. Created an <code>extension</code> of <code>UIButton</code> and added following code:</h3> <pre><code>- (void)awakeFromNib{ [super awakeFromNib]; [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [self.titleLabel setFont:[UIFont fontWithName:@"font" size:self.titleLabel.font.pointSize]]; [self setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter]; } </code></pre> <h3>2.1 Create <code>UIButton</code> inside Code</h3> <p>Now if you create a <code>UIButton</code> inside your code, <code>#import</code> the <code>extension of your</code>UIButton` and create the Button. </p> <h3>2.2 Create Button in <code>Interface Builder</code></h3> <p>If you create the <code>UIButton</code> inside the <code>Interface Builder</code>, select the <code>UIButton</code>, go to the <code>Identity Inspector</code> and add the created <code>extension</code> as <code>class</code> for the <code>UIButton</code>.</p> |
1,680,000 | 0 | <p>Maybe the answers to this may help you:</p> <ul> <li><a href="http://stackoverflow.com/questions/177856/how-do-i-trap-ctrl-c-in-a-c-console-app">How do I trap ctrl-c in a C# console app</a></li> </ul> |
9,415,849 | 0 | <p>Use double quotes to allow bash to perform variable substitution. Single quotes disable bash variable substitution mechanism.</p> <pre><code>ps -clx | grep "$1" | awk "{print $2}" | head -1 </code></pre> |
36,304,312 | 0 | <p>Jost Change Api level 22 or 23.</p> <p><a href="https://i.stack.imgur.com/jHxzA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jHxzA.png" alt="enter image description here"></a></p> |
24,209,681 | 0 | <p>If you would tell us that your <code>dbcursor</code> is a <code>SSCursor</code> or a <code>SSDictCursor</code>, we could tell you that this is normal behaviour: under the hood, these cursors work with <code>use_result()</code> instead of <code>store_result()</code>, and here the number of affected rows is only known at the end, after all rows have been retrieved.</p> |
16,167,228 | 0 | <p>setColumnWidth(-1) should activate auto-scaling. Though this is usually the default (even with BeanItemContainers, so I'm surprised you aren't seeing that behaviour automatically. A related concept, possibly worth you pursuing is setSizeUndefined() which is a method of the Sizeable interface.</p> |
38,099,669 | 0 | How to hide items of a combobox in WPF <p>Is there a way to hide items of a combobox in WPF? In my usercontrol there is a ListBox with checkbox-items bound to an ObservableCollection and a datagrid with a combobox.</p> <pre><code><ListBox x:Name="AvailableAttributes" Grid.Row="0" Grid.Column="2" SelectionMode="Single" > <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=OneWay}"/> </Style> </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding Name}" IsChecked="{Binding IsSelected}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> ... <DataGrid Name="datagrid" AutoGenerateColumns="False" > <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Name}" /> <DataGridComboBoxColumn SelectedValueBinding="{Binding CBID}" DisplayMemberPath="Name" SelectedValuePath="ID"> <DataGridComboBoxColumn.ElementStyle> <Style TargetType="{x:Type ComboBox}"> <Setter Property="ItemsSource" Value="{Binding Path=CBItems, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" /> </Style> </DataGridComboBoxColumn.ElementStyle> <DataGridComboBoxColumn.EditingElementStyle> <Style TargetType="{x:Type ComboBox}"> <Setter Property="ItemsSource" Value="{Binding Path=CBItems, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" /> </Style> </DataGridComboBoxColumn.EditingElementStyle> </DataGridComboBoxColumn> </DataGrid.Columns> </DataGrid> </code></pre> <p>I used <a href="http://stackoverflow.com/questions/5409259/binding-itemssource-of-a-comboboxcolumn-in-wpf-datagrid">this solution</a> to manage the combobox items and added the property 'IsSelected'</p> <pre><code>public class GridItem { public string Name { get; set; } public int CBID { get; set; } } public class CBItem { public int ID { get; set; } public string Name { get; set; } public bool IsSelected { get; set; } } </code></pre> <p>Now I want to use the 'IsSelected' property to hide/show the item in the combobox. Can someone tell me how can I achieve this?</p> |
17,521,655 | 0 | <p>Your best choice is really to fake all "not interesting" schemas. </p> <p>Or you can add your own ErrorListener and carefully analyze the errors to determine the schema they relate to. But this might not be full proof since there can be "other schema"-related errors that stop the validation.</p> |
13,876,330 | 0 | How to insert string in edit control <p>I'm going to add string at runtime in edit control,I've tried with different method and strategies but it won't inserted or if inserted but not displayed in edit control!!! How to make this!please give me solution. Thanks in advance!!</p> |
16,410,879 | 0 | wpf application could not be launched in client machine <p>I have a program developed on WPF. I'm using Blend, <code>Radcontrol</code> to do some customization on <strong>UI</strong>. The application built and run well on developer machine with <code>VS2012</code>, but could not be launched on client machine.</p> <p><strong>The application crashed on client machine and showed the error:</strong></p> <pre><code>Problem signature: Problem Event Name: CLR20r3 Problem Signature 01: dvrserver.exe Problem Signature 02: 1.0.0.0 Problem Signature 03: 517cfe34 Problem Signature 04: PresentationFramework Problem Signature 05: 4.0.30319.17929 Problem Signature 06: 4ffa7956 Problem Signature 07: 7fc6 Problem Signature 08: ee Problem Signature 09: System.Windows.Markup.XamlParse OS Version: 6.1.7601.2.1.0.256.1 Locale ID: 1033 Additional Information 1: 0a9e Additional Information 2: 0a9e372d3b4ad19135b953a78882e789 Additional Information 3: 0a9e Additional Information 4: 0a9e372d3b4ad19135b953a78882e789 </code></pre> <p>I've already installed <code>Blend</code>, <code>Radcontrol</code> to client machine but the problem still there. I don't think we need <code>VS2012</code> in client machine as developer machine. What should I proceed to solve my issue?</p> |
37,341,768 | 0 | Java + Hibernate: Using a Formula on an embedded class <p>Can I use the <code>@Formula</code> annotation on an embedded class which maps the resultset of the query in the formula?</p> <p><strong>Entity</strong></p> <pre><code>@Entity(name = "TABLE") public class SpecialEntity { ... @Embedded @Formula("SELECT PATH, SIZE FROM TABLE WHERE ID = ID') private List<EmbedProperties> properties; } </code></pre> <p><strong>Embeddable</strong></p> <pre><code>@Embeddable public class EmbedProperties { @Column("PATH") private String id; @Column("SIZE) private Long size; } </code></pre> <p>If not, what are the alternatives?</p> |
15,975,716 | 0 | <p>I solved this problem without using OData. There is a URL available that will return just the binary data. So with this URL I can use other Java classes to stream the data directly to disk.</p> <p>So with this URL:</p> <blockquote> <p>www.example.com/OData.svc/File/Data/$value</p> </blockquote> <p>(which returns just the binary data)</p> <p>We can create a URL connection and download it:</p> <pre><code>URL url = new URL(webPage); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); File file = new File(dir, fileName);//need to create a file based on your storage paths FileOutputStream out = new FileOutputStream(file); InputStream in = urlConnection.getInputStream(); byte[] buffer = new byte[1024]; int i = 0; while ((i = in.read(buffer)) > 0) { out.write(buffer, 0, i); } out.flush(); out.close(); in.close(); </code></pre> |
557,674 | 0 | <p><a href="http://www.firebirdsql.org/" rel="nofollow noreferrer">Firebird embedded</a></p> <p>About:</p> <blockquote> <p>Firebird is an open source relational database offering many ANSI SQL-99 features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, powerful language support for stored procedures and triggers.</p> </blockquote> |
26,414,114 | 0 | Does JAVA have API to access the login history from sql server management studio? <p>I want to get the historic server URL that users log into sql server from sql server management studio. Is there JAVA API to implement it? The .NET has it. </p> |
10,733,641 | 0 | What is a .pem file and How to use it? <p>I am designing a new chrome extension and when I package it then I get 2 file: a <strong>.crx</strong> file and a <strong>.pem</strong> file.</p> <p>I want to distribuite my extension on my server ( shared ) and on Chrome webstore.</p> <p>Could you tell me what is a pem file and how to use it ?</p> <p>I can't find documentation about it.</p> |
30,265,725 | 0 | <p>I might be wrong but I'm preety sure that its not possible to decrypted hashed strings. Its the reason why sha256 or sha512 are used to store passwords in databases. </p> |
23,910,232 | 0 | <p>As I see it, you have a few options, depending on exactly what you want to achieve in your tests now, and what you might want to be able to do in the future.</p> <p>1) If your test does not need the websocket configuration at all, change it to point at a custom context configuration that does not include the <code>WebSocketConfig</code>.</p> <p>2) If your test needs the websocket config, but you don't need the broker relay (I can't see why it would be required in a test), you could add another Configuration for testing that uses <code>registry.enableSimpleBroker("/topic", "/queue/")</code> instead of <code>enableStompBrokerRelay</code>. Then there will be no TCP connection to the broker. The obvious disadvantage with this approach is that you are not testing your actual config, and that you are duplicating the destination prefixes.</p> <p>3) Run an embedded STOMP broker for your tests. I'm not 100% certain such a thing exists - I know ActiveMQ has STOMP support and some support for <a href="http://activemq.apache.org/vm-transport-reference.html" rel="nofollow">running inside a VM</a>, but I haven't tried this with STOMP. If possible, the advantage of this approach is that your tests would be testing something very close to the real code.</p> <p>4) You could customise the STOMP broker relay to such an extent that you have full control over what your application receives from the broker. You can customise the <a href="https://github.com/spring-projects/spring-framework/blob/master/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java" rel="nofollow"><code>StompBrokerRelayMessageHandler</code></a> which manages the connection to the relay broker by adding a Configuration class that extends <a href="https://github.com/spring-projects/spring-framework/blob/master/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java" rel="nofollow"><code>DelegatingWebSocketMessageBrokerConfiguration</code></a> in order to override the <code>stompBrokerRelayMessageHandler()</code> method. For example, you can set the TCP client it uses to your own implementation of <code>TcpOperations</code>. Below is an example TCP client that simply does nothing, i.e. makes the Handler think it is connected, but cannot receive or send messages.</p> <pre><code>@Override public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() { AbstractBrokerMessageHandler handler = super.stompBrokerRelayMessageHandler(); if (handler instanceof StompBrokerRelayMessageHandler) { StompBrokerRelayMessageHandler stompHandler = (StompBrokerRelayMessageHandler) handler; stompHandler.setTcpClient(new TcpOperations<byte[]>() { @Override public ListenableFuture<Void> connect(TcpConnectionHandler<byte[]> connectionHandler) { return new CompletedListenableFuture<>(null); } @Override public ListenableFuture<Void> connect(TcpConnectionHandler<byte[]> connectionHandler, ReconnectStrategy reconnectStrategy) { return new CompletedListenableFuture<>(null); } @Override public ListenableFuture<Void> shutdown() { return new CompletedListenableFuture<>(null); } }); } return handler; } </code></pre> <p>Note that <code>CompletedListenableFuture</code> is just an implementation of <code>ListenableFuture</code> that is done after construction, and immediately calls any callbacks passed to <code>addCallback</code> with the value passed into the constructor.</p> <p>The point here is that you can easily customise the exact behaviour of the broker relay components, so you can control them better in your tests. I am not aware of any built-in support to make this kind of testing easier, but then again the websocket support is still pretty new. I would suggest that you look at Rossen Stoyanchev's excellent example project <a href="https://github.com/rstoyanchev/spring-websocket-portfolio" rel="nofollow"><code>spring-websocket-portfolio</code></a>, if you haven't done so already, as it includes several examples of how to test the websocket configuration at different levels (just one controller, loading the full context, running an embedded server, ...). Hopefully this is also helpful for deciding how you want to test your application, and what you might need to customise to do it.</p> |
15,831,540 | 0 | UIView animations canceling each other <p>I have a problem when playing multiple UIView animation blocks.</p> <p>What I have is a game with a lot of buttons, when you press a button it spawns an UILabel which animates to the top of the screen where is gets "added" to the total point amount, this is done by using 3 nested blocks. This works well an lets me spawn as many point labels as possible with animations on them.</p> <pre><code> //setup the label UILabel *pointIndicator = [[UILabel alloc]initWithFrame:CGRectMake(button.button.frame.origin.x, button.button.frame.origin.y, 60, 30)]; pointIndicator.backgroundColor = [UIColor clearColor]; pointIndicator.font = [UIFont boldSystemFontOfSize:25]; pointIndicator.alpha = 0; pointIndicator.layer.shadowOffset = CGSizeMake(1.0f, 1.0f); pointIndicator.layer.shadowOpacity = 0.6; pointIndicator.layer.shadowRadius = 1; [pointIndicators addObject:pointIndicator]; [self.view addSubview:pointIndicator]; CGPoint scoreLabelPosition = [self.view convertPoint:self.totalScoreLabel.frame.origin fromView:self.totalScoreLabel.superview]; CGSize scoreLabelSize = [self.totalScoreLabel.text sizeWithFont:self.totalScoreLabel.font]; [UILabel animateWithDuration:0.3 delay:0 options:UIViewAnimationCurveEaseIn animations:^{ //Make label appear and move it above button CGRect frame = pointIndicator.frame; frame.origin.y -= 30; pointIndicator.frame = frame; pointIndicator.alpha = 1; }completion:^(BOOL finished){ [UILabel animateWithDuration:0.4 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{ //Move the label next to the score label NSInteger YPosition = 0; if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){ YPosition = 15; }else{ YPosition = 2; } CGRect frame = pointIndicator.frame; frame.origin.x = scoreLabelPosition.x + self.totalScoreLabel.frame.size.width/2 + scoreLabelSize.width/2 + 5; frame.origin.y = scoreLabelPosition.y - self.totalScoreLabel.frame.size.height/2 + YPosition; pointIndicator.frame = frame; }completion:^(BOOL finished){ [UILabel animateWithDuration:0.5 animations:^{ pointIndicator.alpha = 0; }completion:^(BOOL finished){ //Animate point label to increase a bit in size CABasicAnimation *pointAnim = [CABasicAnimation animationWithKeyPath:@"transform"]; pointAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; pointAnim.duration = 0.1; pointAnim.repeatCount = 1; pointAnim.autoreverses = YES; pointAnim.removedOnCompletion = YES; pointAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.5, 1.5, 1.0)]; [self.totalScoreLabel.layer addAnimation:pointAnim forKey:nil]; [pointIndicator removeFromSuperview]; [pointIndicators removeObject:pointIndicator]; }]; }]; }]; </code></pre> <p>However, when the game is ended all the buttons animate out of the screen and an image view grows in size out of the middle, each are using 1 animation block.</p> <p>The problem is that if an UILabel is animating across the screen at the same time as the game ends it cancels the button animation AND the growing image animation. If no UILabels are spawned everything plays as it should. I tried to cancel and remove all the point labels before playing the other animations, but with no luck. It only seems to work if all the previous animations have been completed normally in advance. This is how I remove them:</p> <pre><code>for(UIView *pointView in pointIndicators){ [pointView.layer removeAllAnimations]; [pointView removeFromSuperview]; } [pointIndicators removeAllObjects]; [self.totalScoreLabel.layer removeAllAnimations]; </code></pre> <p>all the views which are animated are subviews of the same UIView. I noticed that if I make the point labels subviews of the buttons all the animations can play at the same time.</p> <p>I cant seem to figure out this behavior, is there some sort of conflict between the animations?</p> |
17,106,749 | 0 | <p>Well, actually you can. I don't care about portability, but in VS you can do it. Assuming that we are building 32-bit code with VS, the first 4 bytes at the objects address is the vtable address. By looking at the header files we know the order of methods in the vtable.</p> <p>Example:</p> <pre><code>class Base { public: virtual void printMessage() { std::cout << "Base::printMessage()" << std::endl; } }; class Derived : public Base { public: void printMessage() { std::cout << "Derived::printMessage()" << std::endl; } }; int main(int argc, char* argv[]) { Derived d; unsigned int vtblAddress = *(unsigned int*)&d; typedef void(*pFun)(void*); pFun printFun = (pFun)(*(unsigned int*)(vtblAddress)); printFun(&d); return 0; } </code></pre> <p>P.S. I'm not going to ask why are you doing it, but here you have one option :-)</p> |
19,210,671 | 0 | Android custom CursorAdapter with AsyncTask <p>I'm trying to build a list with an image that is taken from the device and a text. It turns out that taking images from the phone that was from the phone's camera is a task that takes a while so I'm trying to make it as fast as possible so the user experience won't get slower. All I got from this is that it looks like all the images are loaded in one <code>ImageView</code> and than the images spread to all the other <code>ImageViews</code> (I'm not completely sure that my implementation of the <code>ViewHolder</code> technique and Custom <code>CursorAdapter</code> is correct).</p> <pre><code>public class MyCustomCurserAdapter extends CursorAdapter { static class ViewHolder { public TextView nameText; public ImageView imageThumbnail; } Cursor cursor; public MyCustomCurserAdapter(Context context, Cursor c, int flags) { super(context, c, flags); // TODO Auto-generated constructor stub } @Override public void bindView(View view, Context arg1, Cursor cursor) { ViewHolder holder = (ViewHolder)view.getTag(); int pathCol = cursor.getColumnIndex(NewPicSQLiteHelper.COLUMN_PATH); String imageInSD = cursor.getString(pathCol); File imgFile = new File(imageInSD); if(imgFile.exists()){ int nameCol = cursor.getColumnIndex(NewPicSQLiteHelper.COLUMN_PIC_NAME); String name = cursor.getString(nameCol); if (name != null) holder.nameText.setText(name); ImageTask task = new ImageTask(holder.imageThumbnail); task.execute(imgFile); } } @Override public View newView(Context arg0, Cursor cur, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); View view = inflater.inflate(R.layout.new_pic_item, parent, false); ViewHolder holder = new ViewHolder(); holder = new ViewHolder(); holder.nameText = (TextView) view.findViewById(R.id.pic_name_entry); holder.imageThumbnail = (ImageView) view.findViewById(R.id.pic_thumbnail); // The tag can be any Object, this just happens to be the ViewHolder view.setTag(holder); return view; } private class ImageTask extends AsyncTask<File, Void, Bitmap>{ private final WeakReference <ImageView> imageViewReference; public ImageTask(ImageView imageView) { imageViewReference = new WeakReference <ImageView> (imageView); } @Override protected Bitmap doInBackground(File... params) { String path = params[0].getAbsolutePath(); return decodeSampledBitmapFromResource(path,75,75); } @Override protected void onPostExecute(Bitmap result) { if (imageViewReference != null) { ImageView imageView = imageViewReference.get(); if (imageView != null) { if (result != null) { imageView.setImageBitmap(result); imageView.setVisibility(ImageView.VISIBLE); } else { imageView.setVisibility(ImageView.INVISIBLE); } } } } private Bitmap decodeSampledBitmapFromResource(String orgImagePath, int reqWidth, int reqHeight) { } private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { } } </code></pre> |
31,039,787 | 0 | How to enable authorization with the Spring Batch Admin UI <p>I'm integrating the Spring Batch Admin UI into my batch-jobs application. The authentication to the UI is easy. But I have another requirement to ONLY authorize some users to START/STOP jobs. Anyone with feedback on how to accomplish this will be greatly appreciated.</p> |
15,879,798 | 0 | <p>When you allocate memory with <code>malloc</code> (or similar functions) it returns a <em>pointer</em>. You can't assign this pointer to an array. In other words, you can't make an array point to something else once created.</p> <p>What you should do is declare the array as a pointer instead.</p> |
32,085,756 | 0 | <p>Try <a href="https://cocoapods.org/pods/MZFormSheetPresentationController" rel="nofollow">MZFormSheetPresentationController</a> by m1entus. </p> <p>He provides a number of examples on GitHub and CocoaPods and they're ready to use.</p> |
4,803,259 | 0 | Embedded Jetty handles each message twice <p>I'm trying to use Jetty in the simplest way possible. I have started by running the walkthrough from the Jetty@Eclipse documentation, which basically looks like that:</p> <pre><code>public class Main { public class HelloHandler extends AbstractHandler { public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); baseRequest.setHandled(true); response.getWriter().println("<h1>Hello World</h1>"); } } private void run() throws Exception { Server server = new Server(8080); server.setHandler(new HelloHandler()); server.start(); server.join(); } public static void main(String[] args) throws Exception { Main m = new Main(); m.run(); } } </code></pre> <p>The problem is that <strong>the handler gets called twice on every request</strong>. I'm using Chrome with <em>http://localhost:8080</em> to simulate, if that makes any difference. Jetty is embedded as two jars:</p> <ul> <li>jetty-all-7.0.2.v20100331.jar</li> <li>servlet-api-2.5.jar</li> </ul> <p>What am I doing wrong/missing here?</p> |
25,675,055 | 0 | <p>You probably will have to do something like this:</p> <pre><code>$featureList = array(); foreach(Petition::getFeaturedPetitions() as $petition) { $featureList[$petition->id] = 'before '.$petition->call_to_action.'petition'; } </code></pre> |
26,468,737 | 0 | Cordova Build fails on iOS with iOS 3.6.3 and cordova 4.0.0 <p>I just upgraded to <code>cordova 4.0.0</code> and upgraded my iOS platform to version <code>3.6.3</code>. </p> <p>Unfortunately all my builds fail right now with the following output on <code>cordova build iOS</code>:</p> <pre><code> Ld build/emulator/App.app/App normal i386 cd /Users/user/<app>/platforms/ios export IPHONEOS_DEPLOYMENT_TARGET=7.0 export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/user/.rvm/gems/ruby-2.0.0-p451/bin:/Users/user/.rvm/gems/ruby-2.0.0-p451@global/bin:/Users/user/.rvm/rubies/ruby-2.0.0-p451/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/user/.rvm/bin:/Users/user/.adt/tools:/Users/user/.adt/platform-tools" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -L/Users/user/<app>/platforms/ios/build/emulator -L/Users/user/<app>/platforms/ios/App -L/Users/user/<app>/platforms/ios/App/Plugins/com.liyamahendra.cordova.plugins.flurry -F/Users/user/<app>/platforms/ios/build/emulator -F/Users/user/<app>/platforms/ios/HD -F/Users/user/<app>/platforms/ios/Safe -F/Users/user/<app>/platforms/ios/App/Plugins/com.phonegap.plugins.facebookconnect -filelist /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/App.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/user/<app>/platforms/ios/build/emulator/libCordova.a -ObjC -framework Lookback -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework FacebookSDK -framework AdSupport -lFlurryAds_5.3.0 -lz -framework QuartzCore -lFlurry_5.3.0 -framework CoreVideo -framework AudioToolbox -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework Lookback -framework AssetsLibrary /Users/user/<app>/platforms/ios/build/emulator/libCordova.a -framework Lookback -framework MobileCoreServices -framework CoreLocation -framework StoreKit -weak_framework iAd -Xlinker -dependency_info -Xlinker /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/App_dependency_info.dat -o /Users/user/<app>/platforms/ios/build/emulator/App.app/App duplicate symbol _OBJC_IVAR_$_CDVFilesystemURL._url in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFilesystemURL._fileSystemName in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFilesystemURL._fullPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _kCDVFilesystemURLPrefix in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _filePlugin in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile.fileSystems_ in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile.rootDocsPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile.appDocsPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile.appLibraryPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile.appTempPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile.userHasAllowed in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile._persistentPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_IVAR_$_CDVFile._temporaryPath in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_CLASS_$_CDVFilesystemURL in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_METACLASS_$_CDVFilesystemURL in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_METACLASS_$_CDVFilesystemURLProtocol in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_CLASS_$_CDVFilesystemURLProtocol in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_CLASS_$_CDVFile in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o duplicate symbol _OBJC_METACLASS_$_CDVFile in: /Users/user/<app>/platforms/ios/build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVFile-E7AB62C4A5CCC89.o ld: 19 duplicate symbols for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) ** BUILD FAILED ** The following build commands failed: Ld build/emulator/App.app/App normal i386 (1 failure) Error: /Users/user/<app>/platforms/ios/cordova/build: Command failed with exit code 65 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Process.ChildProcess._handle.onexit (child_process.js:810:5) </code></pre> <p>Any ideas where this could come from?</p> <p>I'm running Mac OS X 10.10 (Yosemite) and Xcode 6.</p> <p>Hope you can help :)</p> |
39,361,637 | 0 | <p>Bottom up merge sort without compares. while merging don't do any comparison just swap the elements.</p> |
38,351,542 | 0 | How do I collapse the categories in opencarts mega menu? <p>all Im trying to compress the categories in the mobile menu on opencart Im not seeing an option in the mega menu options to compress the categories on the mobile menu.</p> <p>Ive noticed that when clicking on the header title for the categories that the menu doesn't compress so its just for show apparently.</p> <p>I see an option in the category group settings says is group selecting yes or no makes no difference whatsoever.</p> <p>Any ideas would be greatly appreciated, my apologies for the topic its a client that we are working with.</p> <p><a href="https://i.stack.imgur.com/jUG7n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jUG7n.png" alt="enter image description here"></a></p> |
17,418,208 | 0 | update UI in Task using TaskScheduler.FromCurrentSynchronizationContext <p>I want to add some text to list box using <code>Task</code> and I simply use a button and place in click event this code:</p> <pre><code>TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { for (int i = 0; i < 10; i++) { listBox1.Items.Add("Number cities in problem = " + i.ToString()); System.Threading.Thread.Sleep(1000); } }, CancellationToken.None, TaskCreationOptions.None, uiScheduler); </code></pre> <p>but it does not work and UI locked until the end of the for loop.</p> <p>Where is the problem ?</p> <p>thanks :)</p> |
4,723,203 | 0 | <p>yourString.replaceAll("&b=52","");</p> <p><a href="http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29" rel="nofollow">String API reference</a></p> |
4,190,747 | 0 | <p>Your method Test is defined as taking a parameter of <code>Func<bool></code> which expects a method signature similar to <code>bool Something();</code></p> <p>Look at the other <code>Func<></code> options to see which match what you're trying to accomplish. At the very least you're looking at either <a href="http://msdn.microsoft.com/en-us/library/018hxwa8.aspx" rel="nofollow"><code>Action<string></code></a> or <a href="http://msdn.microsoft.com/en-us/library/bb549151.aspx" rel="nofollow"><code>Func<bool, string></code></a></p> |
9,411,266 | 0 | <p>You don't need if else block, just math :</p> <pre><code>$Start = ($CurrentPage-1)*5+1; </code></pre> |
25,662,950 | 0 | <p>If DateTimeType were an attribute, this could be done conveniently using conditional type assignment. But if it has to be a child element, you can do it using assertions, for example</p> <pre><code><xs:assertion test="not(DateTimeType = 'MONTH' and exists(DayOfWeek)"/> </code></pre> <p>By the way, they are not called tags, they are called elements. An element generally has two tags, a start tag and an end tag. Using the correct terminology has many benefits, for example you'll find that you start to understand the language used in error messages better.</p> |
36,402,029 | 0 | <p>Consider the following 'psuedo-c++'</p> <p>The code works as follows: </p> <ul> <li>take the highest, or lowest bit in the word by AND-ing with all zero's except the MSB or LSB, depending on the MSBFIRST flag</li> <li>write it to the output pin</li> <li>shift the command one step in the right direction</li> <li>pulse the clock pin</li> <li>repeat 8 times, for each bit in the command</li> </ul> <p>It is fairly trivial to expand this to an arbitrary number of bits upto 32 by adding a parameter for the number of repetitions</p> <pre><code>void shiftOut(GPIO dataPin, GPIO clockPin, bool MSBFIRST, uint8_t command) { for (int i = 0; i < 8; i++) { bool output = false; if (MSBFIRST) { output = command & 0b10000000; command = command << 1; } else { output = command & 0b00000001; command = command >> 1; } writePin(dataPin, output); writePin(clockPin, true); sleep(1) writePin(clockPin, false); sleep(1) } } </code></pre> |
36,954,450 | 0 | <p>I built a similar system several years ago using MongoDB on Amazon AWS. This year, tired of doing DevOps on AWS (nod to @AndreiVolgin), I've moved it to Google BigQuery.</p> <p>Datastore for my use case was overkill and frankly, limiting. I would have wanted to turn off indexes for most attributes anyways to save on storage cost. Limiting because it's harder to hook up datastore-based data with a visualization tool such as Tableau.</p> <p>Regarding </p> <blockquote> <p>I know there's a solution called BigQuery by Google, which I believe does what I want and allows me to serve the data I want to customers with high flexibility and efficiency, but as I understood it works only on datastore "backups", I need to serve data in real time.</p> </blockquote> <p>When my system receives a datum, page visitor data in your example, it <a href="https://cloud.google.com/bigquery/streaming-data-into-bigquery" rel="nofollow">streams it directly to BQ</a>. So no, it doesn't only work on backups. Whether you can use it to report "real time" depends on what real time means to you. My system computes aggregate statistics once every couple hours for presentation to users.</p> |
32,752,611 | 0 | <p>In HTML:</p> <pre><code><input v-model="search"> <h4 v-if="!filteredPhotos.length">No results</h4> <ul> <li v-for="photo in filteredPhotos"> <img :src="photo.src" :alt="photo.name"> </li> </ul> </code></pre> <p>In JS, you need to use computed properties like this:</p> <pre><code>computed: { filteredPhotos: function () { return this.photos.filter(function(photo){ return photo.name.indexOf(this.search) > -1; }.bind(this)); } } </code></pre> <p>Demo: <a href="http://jsfiddle.net/crswll/Lr9r2kfv/37/" rel="nofollow">http://jsfiddle.net/crswll/Lr9r2kfv/37/</a></p> |
22,818,976 | 0 | <p>SE_ERR_ACCESSDENIED = 5</p> <blockquote> <p>The operating system denied access to the specified file.</p> </blockquote> <p>The cause of problem might be lots of things. Perhaps the default browser was not installed properly but ended up putting registry keys in virtualized locations? Maybe the URL needs authentication?</p> <p><a href="http://code.google.com/p/chromium/issues/detail?id=156400" rel="nofollow">Chrome not registered correctly anymore. Can't be launched from admin apps.</a></p> |
1,585,691 | 0 | <p>After more research, apparently google does expose the <a href="http://code.google.com/apis/ajaxlanguage/documentation/#fonje" rel="nofollow noreferrer">JSON URL to make direct</a> requests - so using a server side language does seem to be an option (as long as they are cached). However, once you get that content you still need to figure out how to allow users to access it in the flow of your current app. Perhaps something like the mod_rewrite method mentioned above?</p> |
20,269,773 | 0 | <p>You can use <a href="http://docs.python.org/2/library/ast.html#ast.literal_eval" rel="nofollow"><code>ast.literal_eval</code></a>:</p> <pre><code>>>> from ast import literal_eval >>> mystr = '[[1, 2, 3], [4, 5, 6]]' >>> x = literal_eval(mystr) >>> x [[1, 2, 3], [4, 5, 6]] >>> type(x) <type 'list'> >>> </code></pre> |
38,661,616 | 0 | google cloud storage maximum objects <p>Folks, </p> <p>I'm uploading the contents of a data drive to a Google Cloud Storage bucket. After ~90% of the data successfully transferred, the bucket wouldn't accept any more date. I couldn't even create an empty folder.</p> <p>I've found a reference to object name lengths and file size but nothing about count maximums.</p> <p>It fails silently, without error message, acting like the command is being ignored.</p> <p>I'm using Google's console (no code of my own).</p> <p>Anybody have any ideas?</p> <p>Thanks!</p> |
2,578,832 | 0 | <p>MSBuild (which VS uses to do builds, from 2005/.NET2) supports parallel builds. By default VS will set the maximum degree of parallelism to your number of processors. Use Tools | Options | Projects and Solutions | Build and Run to override this default.</p> <p>Of course any one build might have more limited (or no) capacity to allow parallel builds. E.g. only one assembly in a solution provides no scope to build in parallel. Equally a large number of assemblies with lots of dependencies might block parallelism (A depends on B, C depends on A&B, D depends on C has no scope for parallel builds).</p> <p>(NB. for C++, in VS 2005 & 2008 uses its own build system, in 2010 C++ will also be built with MSBuild.)</p> |
40,715,447 | 0 | <p><strong>try:</strong></p> <pre><code> buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre> |
17,540,137 | 0 | JavaFX ScrollPane border and background <p>I'm having some problem regarding the default background and border of the ScrollPane. Using this style made the problem clearer to see.</p> <pre><code>setStyle("-fx-background-color:blue; -fx-border-color:crimson;"); </code></pre> <p><img src="https://i.stack.imgur.com/TvoFy.png" alt="Image show the background and the border"></p> <p>I've tried this style and got no luck only the red border gone and left me with the blue one.</p> <pre><code>setStyle("-fx-background-color:blue; -fx-background-insets:0; -fx-border-color:crimson; -fx-border-width:0; -fx-border-insets:0;"); </code></pre> <p><img src="https://i.stack.imgur.com/vAlTh.png" alt="Image show the background and the border after my best work around"></p> <p>I've looked at this old post <a href="http://stackoverflow.com/questions/12899788/javafx-hide-scrollpane-gray-border">JavaFX Hide ScrollPane gray border</a> and <a href="http://docs.oracle.com/javafx/2/ui_controls/editor.htm" rel="nofollow noreferrer">http://docs.oracle.com/javafx/2/ui_controls/editor.htm</a></p> <p>This line of code doesn't work neither</p> <pre><code>scrollPane.getStyleClass().add("noborder-scroll-pane"); </code></pre> <p>Thanks</p> |
22,149,025 | 0 | How to get the length of Property? <p>I am using Entity Framework code First Approach so I have the mapping model like shown below.Like this I have 40 models Now I want to know the length of column such as BC_ID as shown above programmatically.How can I get max column Length ?I think we can do it using Reflection class but do not know exactly how to do it.I am using Entity Framework 5.0</p> <pre><code>public class BusinessContactMap : EntityTypeConfiguration<BusinessContact> { public BusinessContactMap() { // Primary Key this.HasKey(t => t.BC_ID); // Properties this.Property(t => t.BC_ID) .IsRequired() .HasMaxLength(64); this.Property(t => t.BC_FirstName) .HasMaxLength(64); this.Property(t => t.BC_LastName) .HasMaxLength(64); this.Property(t => t.BC_Mobile) .HasMaxLength(64); this.Property(t => t.BC_Office) .HasMaxLength(64); this.Property(t => t.BC_Mail) .HasMaxLength(64); // Table & Column Mappings this.ToTable("BusinessContacts"); this.Property(t => t.BC_ID).HasColumnName("BC_ID"); this.Property(t => t.BC_FirstName).HasColumnName("BC_FirstName"); this.Property(t => t.BC_LastName).HasColumnName("BC_LastName"); this.Property(t => t.BC_Mobile).HasColumnName("BC_Mobile"); this.Property(t => t.BC_Office).HasColumnName("BC_Office"); this.Property(t => t.BC_Mail).HasColumnName("BC_Mail"); this.Property(t => t.Record_Instance).HasColumnName("Record_Instance"); this.Property(t =>t.Record_LastModified).HasColumnName("Record_LastModified"); } } </code></pre> |
12,448,882 | 0 | Java: wait for exec process till it exits <p>Hi I am running a java program in windows that collects log from windows events. A csv file is created on which certain operations are to be performed. The command execed is a piped one so how do i make java program to wait until the process is finished. Here is the code snippet i am using</p> <pre><code>Runtime commandPrompt = Runtime.getRuntime(); try { Process powershell = commandPrompt.exec("powershell -Command \"get-winevent -FilterHashTable @{ logname = 'Microsoft-Windows-PrintService/Operational';StartTime = '"+givenDate+" 12:00:01 AM'; EndTime = '"+beforeDay+" 23:59:59 '; ID = 307 ;} | ConvertTo-csv| Out-file "+ file +"\""); //I have tried waitFor() here but that does not seem to work, required command is executed but is still blocked } catch (IOException e) { } // Remaining code should get executed only after above is completed. </code></pre> <p>Any help on this is greatly appreciated. Thanks in advance</p> |
35,568,033 | 0 | How to end if statement in php <p>The question is pretty much self-explanatory, I am having trouble how to end if statement in php.</p> <p>For example,</p> <pre><code><?php if (argument) { // end if statement } else if (different argument) { // end if statement } else if (another different argument) { // end if statement } else { // do something } ?> </code></pre> |
14,702,050 | 0 | Valid Date Checks in Oracle <p>I have a date value (either valid date or invalid date) store in varchar format. Is it possible to check the date is valid or not in sql query. </p> |
4,154,592 | 0 | config.cache_classes messing with DateTime in model <p>Hey guys, im having some problem here due to rails class caching. I have this named_scope</p> <p>named_scope :current, :conditions => "starts_at <= '#{Time.now.utc.to_formatted_s(:db)}' and finishes_at >= '#{Time.now.utc.to_formatted_s(:db)}'"</p> <p>The condition Time is not refreshing, all requests are done with the same Time, probably the first used.</p> <p>Is there a way to work around it?</p> |
3,872,483 | 0 | <p>The DOM cannot recognize the HTML's encoding. You can try something like: </p> <pre><code>$doc = new DOMDocument(); $doc->loadHTML('<?xml encoding="UTF-8">' . $html); // taken from http://php.net/manual/en/domdocument.loadhtml.php#95251 </code></pre> |
28,840,273 | 0 | <p>I ended up havinmg to include jquery whic the links from the error told me to do this. But I was still getting an error. Make sure you alwasy load the library dependencies in the same order as your app does.</p> |
6,494,079 | 0 | How can i create django models , views , forms with different names <p>Currently i have my models, views, forms in default file. But i want to have directory structure like</p> <pre><code>articles ---------models ---------views ---------forms Books ---------models ---------views ---------forms Icecreams ---------models ---------views ---------forms </code></pre> <p>so that i keep separately but i don't want different app</p> |
30,738,152 | 0 | <p>Today I've got the similar problems (my game is restarted after admob Interstitial Ad shows). But I got it not after Ads was clicked as in your case (I also can not click ads into my game as I'm developer too), but I got it after video ads tried to show in Admob InterstitialAd. </p> <p>I connected device to PC, opened LogCat and start play the game until video ads appeared again and I catched the reason of restarting : </p> <pre><code>06-09 19:04:07.445: W/System.err(29032): java.lang.SecurityException: Neither user 10124 nor current process has android.permission.WAKE_LOCK. 06-09 19:04:07.445: W/System.err(29032): at android.os.Parcel.readException(Parcel.java:1465) 06-09 19:04:07.445: W/System.err(29032): at android.os.Parcel.readException(Parcel.java:1419) 06-09 19:04:07.445: W/System.err(29032): at android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:302) 06-09 19:04:07.445: W/System.err(29032): at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:719) 06-09 19:04:07.445: W/System.err(29032): at android.os.PowerManager$WakeLock.acquire(PowerManager.java:688) 06-09 19:04:07.455: W/System.err(29032): at android.media.MediaPlayer.stayAwake(MediaPlayer.java:1153) 06-09 19:04:07.455: W/System.err(29032): at android.media.MediaPlayer.start(MediaPlayer.java:1063) 06-09 19:04:07.455: W/System.err(29032): at com.android.org.chromium.media.MediaPlayerBridge.start(MediaPlayerBridge.java:98) 06-09 19:04:07.455: W/System.err(29032): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) 06-09 19:04:07.455: W/System.err(29032): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27) 06-09 19:04:07.455: W/System.err(29032): at android.os.Handler.dispatchMessage(Handler.java:102) 06-09 19:04:07.455: W/System.err(29032): at android.os.Looper.loop(Looper.java:136) 06-09 19:04:07.455: W/System.err(29032): at android.app.ActivityThread.main(ActivityThread.java:5038) 06-09 19:04:07.455: W/System.err(29032): at java.lang.reflect.Method.invokeNative(Native Method) 06-09 19:04:07.465: W/System.err(29032): at java.lang.reflect.Method.invoke(Method.java:515) 06-09 19:04:07.465: W/System.err(29032): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795) 06-09 19:04:07.465: W/System.err(29032): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611) 06-09 19:04:07.465: W/System.err(29032): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>I.e. it required WAKE_LOCK permission. After I added it :</p> <pre><code><uses-permission android:name="android.permission.WAKE_LOCK" /> </code></pre> <p>I play the game again, until video ads was not shown in Interstitial Ads and now it works fine!!!</p> <p>So, I think, it can also solve your problem too. </p> |
Subsets and Splits