pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
15,601,679
0
<p>If I understand you correctly, what you are looking for is this:</p> <pre><code>$(this).siblings("td[class='ms-formbody']").each(.. </code></pre>
30,042,382
0
Linux -> automatic deletion of files older than 2 days <p>I am trying to write something that runs in the background under linux (ubuntu server). I need a service of some sort that deletes files that are older than 2 days from the files system (own cloud storage folder).</p> <p>What is the best way to approach this?</p>
18,043,512
0
<p>It is almost impossible to answer your question in the scope of a SO "answer" - you will need to read up on implementation of parallel processing for the particular architecture of your machine if you want the "real" answer. Short answer is "it depends". But your program could be running on both processors, on any or all of the four cores; they key to understand here is that you can control that to some extent with the structure of your program, but the neat thing about OMP is that usually "you ought not to care". If threads are operating concurrently, they will usually get a core each; but if they need to access the same memory space that may slow you down since "short term data" likes to live in the processor's (core's) cache, and that means there is a lot of shuffling data going on. You get the greatest performance improvements if different threads DON'T have to share memory.</p>
38,514,855
0
Toolbar/Nav drawer not working with tabbed view <p>I'm having an issue getting my toolbar and navigation drawer to show on a new layout file. It's working for the whole app, except the new tabbed layout view.</p> <p>I try to activate it in the onCreate of the new java class:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.workout_days); mToolBar = activateToolbar(); setUpNavigationDrawer(); </code></pre> <p>I no longer get an error, but the toolbar still doesn't show up. I'm wondering if it's something wrong with my layout file.</p> <p>baseactivity:</p> <pre><code>public static final int HOME = 1; public static final int MY_WORKOUT = 2; public static final int MAXES = 3; public static final int PROGRESS = 4; public static final int WORKOUTS = 5; public static final int HELP = 6; private Class mNextActivity; public static String mTitle = AppConstant.SHIEKO_WORKOUT; public static int mType = HOME; protected Toolbar mToolBar; private NavigationDrawerFragment mDrawerFragment; protected Toolbar activateToolbar() { if(mToolBar == null) { mToolBar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(mToolBar); switch (mType) { case HOME: getSupportActionBar().setTitle(AppConstant.SHIEKO_WORKOUT); break; case MY_WORKOUT: getSupportActionBar().setTitle(AppConstant.MY_WORKOUT); break; case MAXES: getSupportActionBar().setTitle(AppConstant.SET_MY_MAXES); break; case PROGRESS: getSupportActionBar().setTitle(AppConstant.MY_PROGRESS); break; case WORKOUTS: getSupportActionBar().setTitle(AppConstant.WORKOUTS); break; case HELP: getSupportActionBar().setTitle(AppConstant.FEEDBACK); } } return mToolBar; } </code></pre> <p>Here is my activity: I also have 3 other fragment xml pages that are for the 3 tabs, those do not include the toolbar or nav bar as it's my understanding they are below the tabview.. correct me if I'm wrong please..</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; </code></pre> <p></p> <pre><code>&lt;android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;!--&lt;RelativeLayout--&gt; &lt;!--android:layout_width="match_parent"--&gt; &lt;!--android:layout_height="match_parent"&gt;--&gt; &lt;android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="0dp"&gt; &lt;include android:id="@+id/app_bar" layout="@layout/toolbar" /&gt; &lt;android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content"/&gt; &lt;/android.support.design.widget.AppBarLayout&gt; &lt;android.support.v4.view.ViewPager android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/&gt; &lt;!--&lt;/RelativeLayout&gt;--&gt; &lt;fragment android:name="com.bestworkouts.sheikoworkout.NavigationDrawerFragment" android:id="@+id/fragment_navigation_drawer" tools:layout="@layout/fragment_navigation_drawer" android:layout_width="280dp" android:layout_height="match_parent" android:layout_gravity="start" app:layout="@layout/fragment_navigation_drawer" /&gt; &lt;/android.support.v4.widget.DrawerLayout&gt; </code></pre> <p></p> <p>Thanks in advance! </p>
26,943,730
0
<p>ADC in AVR is in unsigned 10-bit form, not a double. And the ADC can be read as two separate bytes, ADCL and ADCH. ADCL must be read first.</p> <p>If you want to send some other <code>uint16_t val</code> use</p> <pre><code>uint8_t lo = (uint8_t)val; uint8_t hi = (uint8_t)(val &gt;&gt; 8); </code></pre> <p><code>double</code> and <code>float</code> are both 4 bytes long. If you want to send a <code>double dval</code> use this trick</p> <pre><code>uint32_t val32 = * (uint32_t *) &amp;dval; </code></pre> <p>(Create a pointer to the dval with the address operator <code>&amp;</code>. Cast that pointer to a pointer to a <code>uint32_t</code>, which is a variable taking up the same number of bytes. Then dereference the pointer to get the value, which goes into val32.</p> <p>This is not the same as simply casting the dval to a uint32_t. That would truncate the number.)</p> <p>Send <code>val32</code> in 4 pieces by shifting as above. Recover by shifting and <code>|</code>, then use a similar pointer trick to turn the result back into a double.</p>
37,505,115
0
<p>When items are added to a recycler view or a list view you need to notify the adapter that these changes have occurred which you aren't doing. </p> <p>In <code>onProgressUpdate</code> you'd want to call <code>adapter.notifyItemInserted(position)</code> to tell the RecyclerView to refresh. To do this you'd need a callback or a listener in your AsyncTask because it doesn't have a reference to your adapter, and it shouldn't.</p> <p>See here for all the notify calls you have the ability to use: <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html" rel="nofollow">https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html</a></p>
34,681,863
0
<p>Your best bet is to use unicode escape sequences (like <strong>\u2665</strong>) rather than the binary character.</p>
28,865,240
0
<p>Well, sendgrid-nodejs is a more popular repository.</p> <p>However, Nodemailer is the most popular module for sending emails with NodeJS. I've been using it for months and I'm very satisfied.</p> <p>If you're worried about the future of your app you should consider that Nodemailer is used not just with Sendgrid, but with a lot of other competitors. So if you have a problem with Sendgrid, you could easily switch to another email delivery service without having to learn a different API.</p> <p>So I suggest you to use nodemailer-sendgrid-transport, and if you find bugs, fix them with a PR :P</p>
18,989,915
0
<p>I found the issue. I am referencing JQ version 1.9 because i read in a tutorial that it should automatically pick the latest version in the 1.9 series. It works if i change it to 1.9.0 or 1.9.1. However, i still dont understand why 1.9 didnt work. it should have picked the latest 1.9.* version.</p> <p>But atleast by making it 1.9.1/0 it works from a .js file. </p>
37,909,207
1
Get distance and velocity from discrete accelerometer data <p>I know there has been a number of questions and answers on this topic, but none of them has helped me to understand how to approach the problem. So my set-up is: I have accelerometer data (clean from the gravity part), and I'd like to calculate from the given sample velocity and distance. The data is discrete, say, <code>dt = 20ms</code>, and <code>acc = [...]</code> is the array with samples. I understand that I need to integrate the array to get velocity, but the integration gives me a single values, doesn't it?</p> <pre><code>velocity = scipy.integrate.simps(acc, dx=dt) </code></pre> <p>How do I use this value to get the distance afterwards?</p>
38,255,251
0
<p>in order to show additional data you can use Grid or StackPanel or whatever suits your needs with visibility collapsed and when the user clicks the item it will be set to show. Here I demonstrated how you can do this with a simple ListView:</p> <p>This is my MainPage:</p> <pre><code>&lt;Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="using:App1" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Name="DummyPage" mc:Ignorable="d"&gt; &lt;Page.Resources&gt; &lt;local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /&gt; &lt;/Page.Resources&gt; &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt; &lt;ListView Name="lvDummyData" HorizontalAlignment="Center" VerticalAlignment="Center" IsItemClickEnabled="True" ItemClick="lvDummyData_ItemClick" SelectionMode="Single"&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock Text="{Binding FirstName}" /&gt; &lt;StackPanel Grid.Row="1" Margin="0,20,0,0" Visibility="{Binding ShowDetails, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"&gt; &lt;TextBlock Text="{Binding LastName}" /&gt; &lt;TextBlock Text="{Binding Adress}" /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; &lt;/Grid&gt; &lt;/Page&gt; </code></pre> <p>This is my code behind:</p> <pre><code>using System.Collections.ObjectModel; using System.ComponentModel; using Windows.UI.Xaml.Controls; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&amp;clcid=0x409 namespace App1 { /// &lt;summary&gt; /// An empty page that can be used on its own or navigated to within a Frame. /// &lt;/summary&gt; public sealed partial class MainPage : Page, INotifyPropertyChanged { public ObservableCollection&lt;DummyData&gt; DummyData { get; set; } private DummyData tempSelectedItem; public MainPage() { DummyData = new ObservableCollection&lt;DummyData&gt;(); DummyData.Add(new DummyData() { Adress = "London", FirstName = "Shella", LastName = "Schranz", ShowDetails = false }); DummyData.Add(new DummyData() { Adress = "New York", FirstName = "Karyl", LastName = "Lotz", ShowDetails = false }); DummyData.Add(new DummyData() { Adress = "Pasadena", FirstName = "Jefferson", LastName = "Kaur", ShowDetails = false }); DummyData.Add(new DummyData() { Adress = "Berlin", FirstName = "Soledad", LastName = "Farina", ShowDetails = false }); DummyData.Add(new DummyData() { Adress = "Brazil", FirstName = "Cortney", LastName = "Mair", ShowDetails = false }); this.InitializeComponent(); lvDummyData.ItemsSource = DummyData; } private void lvDummyData_ItemClick(object sender, ItemClickEventArgs e) { DummyData selectedItem = e.ClickedItem as DummyData; selectedItem.ShowDetails = true; if (tempSelectedItem != null) { tempSelectedItem.ShowDetails = false; selectedItem.ShowDetails = true; } tempSelectedItem = selectedItem; } public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChangeEvent(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } public class DummyData : INotifyPropertyChanged { public string FirstName { get; set; } public string LastName { get; set; } public string Adress { get; set; } private bool showDetails; public bool ShowDetails { get { return showDetails; } set { showDetails = value; RaisePropertyChangeEvent(nameof(ShowDetails)); } } public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChangeEvent(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } </code></pre> <p>In my code-behind I have a variable tempSelectedItem which holds the previous clicked item so that you can hide its information.</p> <p>In order to display and hide the information accordingly we need a simple BoolToVisibilityConverter:</p> <pre><code>using System; using Windows.UI.Xaml; using Windows.UI.Xaml.Data; namespace App1 { public class BoolToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { bool boolValue = (bool)value; return boolValue ? Visibility.Visible : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } } </code></pre> <p>Hope this helps.</p>
6,743,850
0
<p>Yes is the answer but it's only the string.</p> <p>You can use <code>&lt;input name="test[]" /&gt;</code></p> <p>and you will receive an array of all inputs with name "test[]" in an array with name "test"</p> <p>You can read for all this in <a href="http://www.razzed.com/2009/01/30/valid-characters-in-attribute-names-in-htmlxml/" rel="nofollow">here</a></p>
22,195,255
0
<p>That's normal as your object is a <code>reference type</code>. You should make a <code>deep copy</code> in order to reflect the changments in your history list </p> <p>try something like this </p> <pre><code>private void Employee_PropertyChanged(object sender, PropertyChangedEventArgs e) { var empCloned = DeepClone(this); History.Add(empCloned); //throw new NotImplementedException(); } </code></pre> <p><strong>Deep Copy</strong> </p> <pre><code>private T DeepClone&lt;T&gt;(T obj) { using (var ms = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(ms, obj); ms.Position = 0; return (T) formatter.Deserialize(ms); } } </code></pre>
13,682,668
0
sql query to count two columns with same values <p>I've got a table with 2 columns with keywords, and I need to count the occurrence of them. I can do that separately, one column at the time, and add the totals later, with a regular count,</p> <pre><code>select count (id), kw1 from mytable group by kw1 </code></pre> <p>and the same for kw2, but I need to get the info straight from the db.</p> <p>So the table is something like:</p> <pre><code>id kw1 kw2 1 a b 2 c d 3 b 4 e a </code></pre> <p>so the idea is to get how many times has been used each keyword, so the result should be something like:</p> <pre><code>'a' 2 'b' 2 'c' 1 'd' 1 'e' 1 </code></pre> <p>Thanks in advance</p> <p>PS: Sorry, I forgot, but just in case, I'm working on Oracle 10g</p>
19,485,803
0
<p>Heroku runs a case-sensitive filesystem, whereas your OS may not be case-sensitive. Try changing that require to this instead:</p> <pre><code> require 'card' </code></pre> <hr> <p>As a general rule of thumb, most files within Ruby are required using lowercase letters with underscores serving as a word separator, like this:</p> <pre><code> require 'card_shuffler' </code></pre>
29,203,094
0
<p>Though it's a bit outdated, it may be helpful to read <a href="http://stackoverflow.com/questions/26705201/whats-the-difference-between-apaches-mesos-and-googles-kubernetes">What's the difference between Apache's Mesos and Google's Kubernetes</a>, to get some of the basics right. Also, note that Mesos operates on a different level than Kubernetes/Marathon/Chronos. Last but not least, see <a href="https://speakerdeck.com/tnachen/docker-swarm-plus-mesos" rel="nofollow">Docker Swarm + Mesos</a> by Timothy Chen, keeping in mind that Marathon and Swarm can operate simultaneously on the same Mesos cluster.</p>
30,531,045
0
<p>After the upload you can simply call <code>delete_transient( 'wc_attribute_taxonomies' );</code></p> <p>That's where the transients are created: <a href="http://oik-plugins.eu/woocommerce-a2z/oik_api/wc_get_attribute_taxonomies/" rel="nofollow">http://oik-plugins.eu/woocommerce-a2z/oik_api/wc_get_attribute_taxonomies/</a></p> <p>See also: <a href="http://wordpress.stackexchange.com/questions/119729/create-attribute-for-woocommerce-on-plugin-activation">http://wordpress.stackexchange.com/questions/119729/create-attribute-for-woocommerce-on-plugin-activation</a></p>
9,098,029
0
Latest version of JSON-Framework <p>I am looking for the latest version of JSON-Framework for ios 5.0. I like this becouse is very easy to use (you can see <a href="http://blog.zachwaugh.com/post/309924609/how-to-use-json-in-cocoaobjective-c" rel="nofollow">here</a>) I have found this but in the oficial web, all is deprecated. (<a href="http://i.stack.imgur.com/m1VBe.png" rel="nofollow">Here is an image</a>, i can post any image yet)</p> <p>Any idea?</p>
34,449,301
0
postgresql function insert multiple rows which values are represented by array <p>I have the table:</p> <pre><code>--------------------------------------- id (integer) | name (character varying) --------------------------------------- </code></pre> <p>I want to insert multiple rows represented by array of character varying. I have the function code:</p> <pre><code>create or replace function add_task_state( TEXT ) returns void as $$ declare _str_states character varying[]; begin _str_states = string_to_array($1,','); insert into task_states (name) values ???; end; $$ language plpgsql; </code></pre> <p>How I can do this?</p>
5,732,159
0
<p>You can do exactly the same thing in C++:</p> <pre><code>std::ifstream reader( xmlInputStream.c_str() ); if ( !reader.is_open() ) { // error handling here... } std::string xml; std::string line; while ( std::getline( reader, line ) ) { xml += line + '\n'; } </code></pre> <p>It's probably not the best solution, but it's already fairly good. I'd probably write something like:</p> <pre><code>std::string xml( (std::istringstream_iterator&lt;char&gt;( reader )), (std::istringstream_iterator&lt;char&gt;()) ); </code></pre> <p>(Note that at least one set of the extra parentheses are needed, due to an anomaly in the way C++ would parse the statement otherwise.)</p> <p>Or even:</p> <pre><code>std::string readCompleteFile( std::istream&amp; source ) { return std::string( std::istringstream_iterator&lt;char&gt;( source ), std::istringstream_iterator&lt;char&gt;() ); } </code></pre> <p>(Look ma, no variables:-)!) Both of these solutions preserve the newlines in the original file, so you don't need to put them back in after reading.</p>
33,188,783
0
<p>Your script is working fine. You have to check some points</p> <ol> <li><p>Upload your scripts in your server. Do not run in localhost.</p></li> <li><p>Check the action and script name is same.</p></li> <li><p>Check mail to address is correct.</p></li> <li><p>Check you are running your script in a php installed server.</p></li> </ol>
14,088,631
0
<p>Decorator pattern might come in handy</p> <pre><code> class S2 extends S { S s; S2(S s) { this.s = s; } // delegate method calls to wrapped B1-B5 instance @Override void oldMethod1() { s.oldMethod1(); } ... // add new methods void newMetod1() { ... } } </code></pre> <p>then use it as </p> <pre><code>new S2(new B1()); </code></pre> <p>or on an existing instance of B1 </p> <pre><code>new S2(b1); </code></pre>
7,095,848
0
indenting Java source files using Eclipse <p>I'm using an UML tool that generates Java classes from the UML class diagram. Unfortunately the code inside is not indented.</p> <p>How to solve this? How can I indent a file using Eclipse? </p>
32,438,463
0
Android programming use of alarmmanger <p>I want to show toast at a specific time using AlarmManger but my toast is not shown at given time? Help me. My code is as follows:</p> <pre><code>private void startAlarm() { Calendar cal=Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH,9); cal.set(Calendar.MONTH,7); cal.set(Calendar.YEAR,2015); cal.set(Calendar.HOUR_OF_DAY,2); cal.set(Calendar.MINUTE,55); cal.set(Calendar.AM_PM,Calendar.PM); Intent intent = new Intent(this, WelcomActivity.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, 0); AlarmManager alarmManager = (AlarmManager)getApplicationContext().getSystemService(ALARM_SERVICE); alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); Toast.makeText(this, "Alarm worked.", Toast.LENGTH_LONG).show(); } </code></pre>
19,723,628
0
<p>you cannot do that</p> <blockquote> <p>private ImageView[][] gameField = {{(ImageView)findViewById(R.id.enemy1_1),(ImageView)findViewById(R.id.enemy1_2),(ImageView)findViewById(R.id.enemy1_3)}, {(ImageView)findViewById(R.id.enemy2_1),(ImageView)findViewById(R.id.enemy2_2),(ImageView)findViewById(R.id.enemy2_3)}, {(ImageView)findViewById(R.id.enemy3_1),(ImageView)findViewById(R.id.enemy3_2),(ImageView)findViewById(R.id.enemy3_3)}};</p> </blockquote> <p>you should save only the id , R.id.XXX and when query the view use findViewById.</p> <p>you cannot query view by id if the view doesnt yet exists.</p>
11,929,402
0
QAbstractTableModel is a class in Qt for models that represent their data as a two-dimentional array of items.
295,684
0
<p><code>svn diff</code>, even when you're offline and might think diff:ing is not possible.</p>
30,335,945
0
<p>Do you need all of this data present on the Windows machine? Or are you going to be accessing it intermittently? </p> <p>You might try just mounting your S3 bucket. </p> <p>It will still be remote but will act like a normal mounted drive in Windows. If you need to do some data crunching then copy just the files you need at that moment to the local disk. You can mount S3 with S3browser,Cloudberry, or a hundred other S3 clients. </p>
37,395,447
0
Service-based security with Java EE <p>All Java EE authorisation techniques I've seen so far are for the view layer only - mostly based on JSF. You basically restrict access to certain URL patterns or JSF components.</p> <p>However, I'd prefer to have my security layer on the services. My layers are looking something like this:</p> <ul> <li>View (XHTML + JSF Backing Beans / RESTful web services)</li> <li>Services</li> <li>Entities and Business Logic</li> <li>DAOs</li> </ul> <p>Since the services are a proxy to my business logic and contain no logic by themselves, I'd like to use them for access control. This way I wouldn't need to implement the security for each view technology separately or watch out for URL patterns (which are terrible to maintain).</p> <p>My preferred solution would be annotations for classes or methods on the services. If some view code tries to access them without permission, it gets an exception (which is handled and should forward to a login form).</p> <p>Is there anything like this I could use?</p>
8,881,069
0
<p>The only way to use 2 different version of the same class is to laod them through 2 different classloaders. That is you have to load <strong>owls.jar__and __jena.jar</strong> with one class loader and <strong>envy.jar</strong> and <strong>jena2.jar</strong> with another. This solution has its own pitfalls, you should probably right custom code that will be able to use another classloader when it's necessary, maybe you will end up with writing your own class loader.</p> <p>As far as I know there is no built in solution for such situation. May be, it is easier to use older version of one the jar's above that can support the same version of <strong>jena.jar</strong> This is much easier solution.</p>
25,214,643
1
Python - Rounding floating integers defined as variables and displaying them <p>I am trying to get this to calculate a number based on user input. While displaying it I want it to round to 2 digits. It refuses too! So confused. Any advice?</p> <pre><code>def calc(user_id): numbers = {'A': 4, 'B': 3, 'C': 2, 'D': 1, 'F': 0} user = User.objects.get(pk=user_id) user_profile = UserProfile.objects.get(user=user) outs = Out.objects.filter(user=user) counter = 0 total_number = 0 for out in outs: if out.data['type'] != 'panel': continue else: print out.data total_number += numbers[out.data['level']] counter += 1 x = round(float(total_number/float(counter)), 2) user_profile.average = x user_profile.save() </code></pre>
3,414,877
0
<p>Next to reseting the counter for the figures:</p> <pre><code>\setcounter{figure}{0} </code></pre> <p>You can also add the "S" by using:</p> <pre><code>\makeatletter \renewcommand{\thefigure}{S\@arabic\c@figure} \makeatother </code></pre>
19,311,651
0
send mail using mail() in php <p>Hello I am learning php where i came to know mail() function i have tried this code</p> <pre><code>function sendMail() { $to = 'Sohil Desai&lt;[email protected]&gt;'; $from = 'Sohil Desai&lt;[email protected]&gt;'; $subject = 'Test Mail'; $headers = 'MIME-Version: 1.0'. "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: '.$from . "\r\n"; $headers .= 'X-Mailer: PHP/'.phpversion(); $message = 'This mail is sent for testing.'; $mail = mail($to, $subject, $message, $headers); if (!$mail) { return 'Error occured sending mail.'; } return 'Mail successfully sent.'; } echo sendmail(); </code></pre> <p>I have tested only for gmail, ymail and hotmail.</p> <p>This function sends mail in a spam for gmail &amp; hotmail and it won't send mail to ymail.</p> <p>why it happens??</p> <p>I am using Ubuntu 12.04 &amp; php version 5.3.10.</p> <p>Can anyone help me?? Thanks to halpers in advance..</p>
5,781,483
0
<p>Is this just an example, or the real application?</p> <p>In trading room environments, market data applications are extremely sensitive to delays of even a few milliseconds, and a lot of time and money is invested to minimise delays.</p> <p>This makes the set of technologies you're talking about completely inappropriate; C/C++/Java apps communicating over raw TCP sockets or through a high performance middleware are the only way to get the necessary performance. Internet distribution has unpredictable delays.</p> <p>Of course, if you're talking about the low-end of the market, where 'realtime' means the user won't get bored waiting for a response, as opposed to liveness of data, then there are many possible technologies. AJAX may be suitable, using either XML or JSON payload.</p> <p>What type of data source do the quotes come from? Is it's a database, XML/JSON AJAX makes sense; if it's message-orientated middleware, then sockets are much better.</p> <p>Do you need to have real-time updates, and is it acceptable for individual updates to get aggregated?</p>
9,715,113
0
<p>To start with, I'd suggest using <a href="http://msdn.microsoft.com/en-us/library/system.datetime.parseexact.aspx" rel="nofollow"><code>DateTime.ParseExact</code></a> or <code>TryParseExact</code> - it's not clear to me whether your sample is meant to be December 2nd or February 12th. Specifying the format may well remove your <code>FormatException</code>.</p> <p>The next problem is working out which time zone you want to convert it with - are you saying that 11:58 is a <em>local</em> time in some time zone, or it's <em>already</em> a UTC time?</p> <ul> <li>If it's a local time in the time zone of the code which is running this, you can use <code>DateTimeStyles.AssumeLocal | DateTimeStyles.AdjustToUniversal</code> to do it as part of parsing.</li> <li>If it's already a universal time, use <code>DateTimeStyles.AssumeUniversal</code></li> <li>If it's a local time in a different time zone, you'll need to use <a href="http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx" rel="nofollow"><code>TimeZoneInfo</code></a> to perform the conversion.</li> </ul> <p>Also, if it's a local time you'll need to consider two corner cases (assuming you're using a time zone which observes daylight saving time):</p> <ul> <li>A local time may be <em>skipped</em> due to DST transitions, when the clocks go forward. So if the clocks skip from 1am to 2am, then 1:30am doesn't exist at all.</li> <li>A local time may be <em>ambiguous</em> due to DST transitions, when the clocks go back. So if the clocks go back from 2am to 1am, then 1:30am occurs <em>twice</em> at different UTC times - which occurrence are you interested in?</li> </ul> <p>You should decide how you want to handle these cases, and make sure they're covered in your unit tests.</p> <p>Another option is to use my date and time library, <a href="http://noda-time.googlecode.com" rel="nofollow">Noda Time</a>, which separates the concepts of "local date/time" and "date/time in a particular time zone" (and others) more explicitly.</p>
9,800,647
0
<p><a href="http://www.modernizr.com/" rel="nofollow">Modernizr</a> will make HTML5 elements work (and by work, I mean the browser will recognise them and you can apply styles to them) in browsers that do not support them, such as old versions of IE</p> <p>Another good one is <a href="http://selectivizr.com/" rel="nofollow">selectivizr</a>, which adds a bunch of unsupported CSS3 selectors to old IE, although a JS library also needs to be used</p>
38,218,640
0
Is it possible to write an extension for a specific swift Dictionary ... [String : AnyObject]? <p>I am trying to write an extension for this:</p> <pre><code>extension [String : AnyObject] { } </code></pre> <p>It throws and error. I was also trying to come up with something similar as this:</p> <pre><code>extension Dictionary: [String : AnyObject] { } </code></pre> <p>It also fails.</p> <p>Is there a solution that works similar as this (I can't remember proper syntax)?</p> <pre><code>extension Dictionary where ?? is [String : AnyObject] { } </code></pre>
22,278,111
0
<p>Try following approach, is from <a href="http://www.vntweb.co.uk/no_pubkey-e585066a30c18a2b/" rel="nofollow">there</a></p> <blockquote> <p>The error <code>NO_PUBKEY E585066A30C18A2B</code> is the key for the Opera web browser. To correct the error, run the following code.</p> <p><code>wget -O - http://deb.opera.com/archive.key | apt-key add</code></p> </blockquote>
38,123,587
0
Extract username from forward slash separated text <p>I need to extract a username from the log below via regex for a log collector. </p> <p>Due to the nature of the logs we're getting its not possible to define exactly how many forward slashes are going to be available and I need to select a specific piece of data, as there are multiple occurances of similar formatted data.</p> <p>Required data:</p> <pre><code>name="performedby" label="Performed By" value="blah.com/blah/blah blah/blah/**USERNAME**"| </code></pre> <p>&lt;46>Jun 23 10:38:49 10.51.200.76 25113 LOGbinder EX|3.1|success|2016-06-23T10:38:49.0000000-05:00|Add-MailboxPermission Exchange cmdlet issued|name="occurred" label="Occurred" value="6/23/2016 10:38:49 AM"|name="cmdlet" label="Cmdlet" value="Add-MailboxPermission"|name="performedby" label="Performed By" value="blah.com/blah/blah blah/blah/<strong>USERNAME</strong>"|name="succeeded" label="Succeeded" value="Yes"|name="error" label="Error" value="None"|name="originatingserver label="Originating Server" value="black"|name="objectmodified" label="Object Modified" value="blah/blah/USERNAME"|name="parameters" label="Parameters" value="Name: Identity, Value: [blah]Name: User, Value: [blah/blah]Name AccessRights, Value: [FullAccess]Name: InheritanceType, Value: [All]"|name="properties" label="Modified Properties" value="n/a"|name="additionalinfo" label="Additional Information"</p> <p>I've tried a few different regex commands but I'm not able to extract the necessary information without exactly stating how many / there will be.</p> <pre><code>blah\.com[.*\/](.*?)"\|name </code></pre>
30,222,530
0
iOS: Check if user is already logged in using Facebook? <p>I have started working on an iOS app on Xcode using Swift and storyboards. I have a requirement where on click of a button I will show a user's Facebook profile info on the screen (only if user is signed in using Facebook), but if he is not signed in it will automatically go to login screen and on successful login again the profile view will be shown.</p> <p>How can I do this?</p>
34,562,508
0
<p>Use <a href="https://codex.wordpress.org/Template_Tags" rel="nofollow">get_the_post_thumbnail</a> function.<br> In this case it is better use The Loop fundamentals of WordPress.<br> References:<br> <a href="https://codex.wordpress.org/The_Loop" rel="nofollow">https://codex.wordpress.org/The_Loop</a><br> <a href="https://codex.wordpress.org/The_Loop_in_Action" rel="nofollow">https://codex.wordpress.org/The_Loop_in_Action</a></p>
11,846,110
0
<p>Also you may want to select show updates/new packages and show installed packages.</p> <p>Btw. I think it is called Google Play now instead of Google Market.</p>
9,824,683
0
Android 4.0 - problems <p>I have 3 problems with android 4.0 (Galaxy tab 10.1). The first one is getting local IP: I use the method:</p> <pre><code>public static String getLocalIpAddress() { try { for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress().toString(); } } } } catch (SocketException ex) { ex.printStackTrace(); } return null; } </code></pre> <p>It works great on android v2.1-2.3. But some customers who have Android 4.0 complain me that it doesn't work! It returns something like mac-address: fe80::fad0:bdff:fe4d:4871 Can anyone explain what's happened?</p> <p>The second problem is about WiFi checking state. I use function below to check connection to WiFi hotspot point:</p> <pre><code> public boolean IsWiFiConnected(){ List&lt;WifiConfiguration&gt; wifiConfigList = wifiManager.getConfiguredNetworks(); boolean retVal=false; for(WifiConfiguration wifiConf : wifiConfigList){ if(wifiConf.status==WifiConfiguration.Status.CURRENT){ retVal=true; break; } } return retVal; } </code></pre> <p>In android 4.0 it always returns false. </p> <p>And the third problem is getting device's information (it happens on ASUS Transformer Prime): I get information about device by using function below:</p> <pre><code>public static String GetDeviceInfo(Context context){ TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); return Build.BRAND.toString()+"~|~"+Build.DEVICE.toString()+"~|~"+telephonyManager.getDeviceId().toString()+"~|~"+Build.VERSION.RELEASE; } </code></pre> <p>It throws NULLPointerExeption. I think it happens because of TelephonyManager can not be initialized. I have all permissions in manifest. These all functions work fine on the previous versions. </p> <p>Could anyone tell me what's going on? Thank you.</p>
39,671,829
0
<p>found two ways of achieving my problem </p> <p>1.from @trevjonez(trevor jones)</p> <pre><code>Where&lt;SomeModel&gt; query = SQLite.select() .from(SomeModel.class) .where(SomeModel_Table.date_field.greaterThan(someValue)); if(someCondition) { query = query.and(SomeModel_Table.other_field.eq(someOtherValue)); } else { query = query.and(SomeModel_Table.another_field.isNotNull()); } Cursor cursor = query.query(); //do stuff with cursor and close it — </code></pre> <p>2.from @zshock using ConditionalGroup</p> <pre><code>ConditionGroup conditionGroup = ConditionGroup.clause(); conditionGroup.and(YourTable_Table.id.eq(someId); if (someCondition) { conditionGroup.and(YourTable_Table.name.eq(someName); } return SQLite.select() .from(YourTable.class) .where(conditionGroup) .queryList(); </code></pre>
13,172,659
0
<p>Get it as </p> <pre><code>$total = 0 $avg = 0 foreach ($users as $user) { $user_avg = ($user['reliable'] + $user['communication'] + ($user['experience']/3) * 5) / 3; $total += $user_avg; } if (sizeof($users) &gt; 0) { $avg = $total/sizeof($users); $avg = round($avg, 2) } </code></pre>
8,885,586
0
jTidy returns nothing after tidying HTML <p>I have come across a very annoying problem when using jTidy (on Android). I have found jTidy works on every HTML Document I have tested it against, except the following:</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;!-- Always force latest IE rendering engine &amp; Chrome Frame Remove this if you use the .htaccess --&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /&gt; &lt;title&gt;templates&lt;/title&gt; &lt;meta name="description" content="" /&gt; &lt;meta name="author" content="" /&gt; &lt;meta name="viewport" content="width=device-width; initial-scale=1.0" /&gt; &lt;!-- Replace favicon.ico &amp; apple-touch-icon.png in the root of your domain and delete these references --&gt; &lt;link rel="shortcut icon" href="/favicon.ico" /&gt; &lt;link rel="apple-touch-icon" href="/apple-touch-icon.png" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;header&gt; &lt;h1&gt;Page Heading&lt;/h1&gt; &lt;/header&gt; &lt;nav&gt; &lt;p&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="/contact"&gt;Contact&lt;/a&gt;&lt;/p&gt; &lt;/nav&gt; &lt;div&gt; &lt;/div&gt; &lt;footer&gt; &lt;p&gt;&amp;copy; Copyright&lt;/p&gt; &lt;/footer&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But after tidying it, jTidy returns nothing (as in, if the String containing the Tidied HTML is called result, result.equals("") == true)</p> <p>I have noticed something very interesting though: if I remove everything in the body part of the HTML jTidy works perfectly. Is there something in the &lt;body&gt;&lt;/body&gt; jTidy doesn't like?</p> <p>Here is the Java code I am using:</p> <pre><code> public String tidy(String sourceHTML) { StringReader reader = new StringReader(sourceHTML); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Tidy tidy = new Tidy(); tidy.setMakeClean(true); tidy.setQuiet(false); tidy.setIndentContent(true); tidy.setSmartIndent(true); tidy.parse(reader, baos); try { return baos.toString(mEncoding); } catch (UnsupportedEncodingException e) { return null; } } </code></pre> <p>Is there something wrong with my Java? Is this an error with jTidy? Is there any way I can make jTidy not do this? (I cannot change the HTML). If this absolutely cannot be fixed, are there any other good HTML Tidiers? Thanks very much!</p>
15,484,503
0
How to create Quadtree Copy constructor with Recursion <p>I am working on a copy constructor for a Quadtree. Here's what I have so far:</p> <pre><code> //Copy Constructor Quadtree :: Quadtree(const Quadtree &amp; other) { root = copy(other.root); resolution = other.resolution; } //Copy Constructor helper function Quadtree::QuadtreeNode *Quadtree :: copy (const QuadtreeNode* newRoot) { if (newRoot != NULL) { QuadtreeNode *node = new QuadtreeNode(newRoot-&gt;element); node-&gt;nwChild = copy(newRoot-&gt;nwChild); node-&gt;neChild = copy(newRoot-&gt;neChild); node-&gt;swChild = copy(newRoot-&gt;swChild); node-&gt;seChild = copy(newRoot-&gt;seChild); return node; } else return NULL; } </code></pre> <p>I'm not sure where I am going wrong, but I am receiving memory leaks and Valgrind is pointing out that I have uninitialized values. Help please?</p> <p>Attached, is my buildTree function - where I actually create the tree. I may be doing something wrong here?</p> <pre><code> void Quadtree :: buildTree (PNG const &amp; source, int theResolution) { buildTreeHelp (root, 0, 0, theResolution, source); } void Quadtree :: buildTreeHelp (QuadtreeNode * &amp; newRoot, int xCoord, int yCoord, int d, PNG const &amp; image) { if (d == 1) { RGBAPixel pixel = *image(xCoord, yCoord); newRoot = new QuadtreeNode(pixel); return; } newRoot = new QuadtreeNode (); newRoot = NULL; buildTreeHelp(newRoot-&gt;nwChild, xCoord, yCoord, d/2, image); buildTreeHelp(newRoot-&gt;neChild, xCoord + d/2, yCoord, d/2, image); buildTreeHelp(newRoot-&gt;swChild, d/2, yCoord + d/2, d/2, image); buildTreeHelp(newRoot-&gt;seChild, d/2 + xCoord, d/2 + yCoord, d/2, image); } </code></pre>
10,980,181
0
<blockquote> <p>iv.setImageURI(@"C:\Users\SONY\Downloads\slide.butcher.home.jpg");</p> </blockquote> <p>You are trying pass Uri of image which is stored on your Computer!!!!</p> <p>Copy that file on your device SD Card. Suppose you copied it under <code>/sdcard/home.jpg</code></p> <p>Then use below code to display it in ImageView.</p> <pre><code>imageView.setImageUri(Uri.parse("/sdcard/home.jpg")); </code></pre>
27,256,363
0
<p>To disable the "required" on the field you need...</p> <p>On your javascript document ready you can use this code:</p> <pre><code>$('#category_slug').removeAttr('required'); </code></pre>
22,372,128
0
<blockquote> <p>How is a getting incremented?</p> </blockquote> <p><code>a</code> is increased by the <code>a++</code> in <code>while(a++&lt;=2);</code>.</p> <p><code>a++</code> will return the value of <code>a</code> and add one to it, so when <code>a</code> is 3, <code>a++&lt;=2</code> will be false, but <code>a</code> still get added by one.</p>
13,467,796
0
Display text when MySQL Column is 1 <p>So here is what I have... the issue is it is giving me errors and I cant get it to work for the life of me!</p> <pre><code>&lt;?php $link = mysql_connect($hostname, $username, $password); mysql_select_db($database); if (!$link) { die('Could not connect: ' . mysql_error()); } $result = mysql_query("SELECT * FROM messages WHERE reciever=$user"); while($row = mysql_fetch_assoc($result)) { if($row['recieved'] == '1') { echo '&lt;a class="new-message" title="New Message"&gt;New&lt;/a&gt;'; } else { echo '&amp;nbsp;'; } } ?&gt; </code></pre> <p>$user is the SESSION Username (comes from a different code page)</p> <p>What I want is for it to just show the New Message when it has not been read yet (=0) and show a space (or nothing) if the message has been read (=1).</p>
21,417,981
0
<p>The VM Template system also lets you create additional view templates for categories and products. To override the default categories, category, or productdetails view, simple use the standard Joomla template override method. Copy <strong>/components/com_virtuemart/views/[categories, category, or productdetails]/default.php</strong> to <strong>/templates/[Your Template]/html/com_virtuemart/[categories, category, or productdetails]/default.php</strong> and make your changes to the template version of default.php.</p> <p>To create additional views that can be set on a per category/product basis, simply copy <strong>/templates/[Your Template]/html/[categories, category, or productdetails]/default.php</strong> to a new file name like <strong>/templates/[Your Template]/html/[categories, category, or productdetails]/myView.php</strong> and make the desired changes. In the Virtuemart category or product configuration, you will find <strong>myView</strong> in the drop down list of alternatives views that can be used.</p>
25,250,270
0
<h2>Initial note</h2> <p>A lot of indeed <strong>smart</strong> man*years has been burnt on reverse-engineered efforts to tap into <strong><code>MT4/Server</code></strong> &lt;--> <strong><code>MT4/Terminal</code></strong> C/S communication.</p> <p>Some have died by themselves.</p> <p>Some have failed to survive the next change introduced by just another Build XYZ.</p> <p>Some have even made their way up to the court suits from MetaQuotes, Inc., for violation or infringements of the rights to protect one´s intellectual property.</p> <p>So, one shall rather really know, what is going to follow.</p> <h2>How it works?</h2> <p>Recent <strong><code>MT4/Terminal</code></strong> Build 670+ uses several regular streaming connections to <strong><code>MT4/Server</code></strong></p> <p>It does not take much time or efforts to employ a port-scanner of whatever brand to map, decode and analyse further internals. Nevertheless, do not rather forget the warning, [<strong>Initial note</strong>] rulez.</p> <p>There are <strong>no direct ways</strong> to "update" OHLC-candle / Volume objects of the <strong><code>MT4/Terminal</code></strong> graph</p> <p>There are <strong>many ways</strong> to add and control additional visual objects into the MT4 graphs, incl. but not limited to, compose a fully-fledged new, layered, augmented GUI, where user-defined &lt;<em><strong>application-code</strong></em>> retains the full real-time control of both the <strong><code>MVC-GUI</code></strong>-elements and the <strong><code>TradingExecutionEngine</code></strong>.</p> <h2>Can a current Metatrader proprietary architecture get extended?</h2> <p><strong>Yes.</strong></p> <p>Historically some three principal epochs / approaches were used.</p> <ol> <li><p>3rd party DLL based communications</p></li> <li><p>Windows O/S services based communications</p></li> <li><p>MetaQuotes, Inc., "new"-MQL4 ( post Build 600+ ) language extensions for socket communications</p></li> </ol> <p>User-defined &lt;<em><strong>application-code</strong></em>> can safely deploy rather a thread-safe external messaging infrastructure, to better "escape" from a (fragile, namely in post Build 670+ epoch) MT4 internalities and retain a full control over the "own" messaging / streaming layer.</p> <h2>Examples</h2> <p><strong><code>MT4/Terminal</code></strong> with socket/remote <strong><code>python</code></strong>-based CLI terminal &amp; add-on pseudo-language for both trading and scripted test-case batteries´ automated runs</p> <p><strong><code>MT4/Terminal</code></strong> with socket/remote external integrated RSS-feed service</p> <p><strong><code>MT4/Terminal</code></strong> with socket/remote GPU-hosted numerical solver for AI/ML decision making</p> <p><strong><code>MT4/Terminal</code></strong> with socket/remote cloud-based peer-to-peer community messaging</p>
13,686,635
0
<p>Your <code>label</code> which contains the image is being replaced with <code>label123</code> in the <code>BorderLayout.CENTER</code> position, which <em>doesnt</em> have any image attached. You could use:</p> <pre><code>label123.setIcon(ii); </code></pre> <p>If you want the 2 labels to be shown, you could place the text-based <code>label123</code> in the <code>SOUTH</code> location:</p> <pre><code>jframe.add(label123, BorderLayout.SOUTH); </code></pre> <p>Note: Use <code>JLabel</code> instead of <code>Label</code>.</p>
35,446,324
0
<p>One of the "old school" approaches before linq saved all our butts from this kind of thing. Uncompiled as I'm on mobile atm (doing code on a mobile is hard, just so you know).</p> <pre><code>private List&lt;int&gt; test() { var intResults = new List&lt;int&gt;(); var file = File.ReadLines("blah"); foreach (var line in file) { var lineSplit = line.Split( new char[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in lineSplit) { var result = 0; if (int.TryParse(item, out result)) intResults.Add(result); } } return intResults; } </code></pre> <p>I don't expect this to be the answer as the linq option is much more elegant but it's just showing other ways of achieving the same goal :)</p> <p>Edit: Method wasn't returning anything -_-</p>
3,846,389
0
Super simple java swing jlist question that I just can't figure out! <p>Ok, so I am working on a homework assignment, and I am using SWING to make a GUI for a Java project, and I am running into troubles with JList.</p> <p>I have a customer object that I have made and set attributes to, and I want to add the object into a TreeMap. I want to hook up the Treemap so that any and all objects that are in the map will populate (the name attribute anyway) inside of the JList.</p> <p>I have done a lot of looking around, and am seeing a lot about coding these things from scratch but little dealing with Swing implementation. I put my customer object into my map and then I would like for my JList to reflect the map's contents, but I don't know how to hook it up.</p> <pre><code> customers.put(c.getName(), c); this.customerList.(What can I do here? add Customer object?? I can't find what I need); </code></pre> <p>Thanks for your help!!!</p>
9,261,833
0
<p>Like stated in <a href="http://facebook.stackoverflow.com/questions/7653095/unexpected-error-when-posting-photos-to-test-users">this answer</a> the problem can be caused when your application is in Sandbox mode.</p>
30,663,649
0
Initializing a static class member array with a non-trivial expression in C++11 <p>I would like to benchmark the performance of using a const cache for some static function inside a cache. So I have something like that:</p> <pre><code>class Foo { static double cost(int factor) { &lt;moderately complex function&gt; }; // Other stuff using the cost() function }; </code></pre> <p>And I would like to benchmark against an alternative version like this one:</p> <pre><code>class Foo { private: static double _cost(int factor) { &lt;same function as before&gt; }; static const double cost_cache[MAX_FACTOR] = ???; public: static double cost(int factor) { return cost_cache[factor]; }; // Other stuff } </code></pre> <p>With a way to initialize my cost_cache array in a way equivalent to</p> <pre><code>for (int idx = 0; i &lt; MAX_FACTOR; ++i) cost_cache[idx] = _cost(idx); </code></pre> <p>In a high-level functional language I would use a map primitive. How do I properly initialize that in C++11 (or C++14 ?) I saw other posts addressing similar questions, like <a href="http://stackoverflow.com/questions/27569249/">Initializing private member static const array</a>, but its solution is inapplicable in my case, I can't put the 10k values verbatim in source.</p> <p>I'm using <code>clang++</code></p>
11,355,608
0
php ajax reload webpage every 1 second constant database connection <p>i was wondering how can i reload a .php website containing a table every second with ajax? is it fine if i use javascript, but a quick php script would do just fine, does a loop for reload method work?</p> <p>I tried ajax with javascript but every time i used jquery load method it didnt load anything, and i see all ajax examples only deal with php websites that accept queries with get. I just need my webpage to reload and check for changes in the database as quick as possible. i tried the following code but nothing:</p> <p>$("#newnav").load("polling.php");</p>
20,295,442
0
<p>I don't know why PhoneCallListener stops execution, however I solved this by putting "phoneListener = new PhoneCallListener();" in the onCreate method.</p>
33,762,072
0
Exclude a class depedency in compile, but include in testCompile for gradle <p>I'm having an issue where I have an old version of library Foo as a transitive dependency in one of my included libs. I want to use a newer version of library Foo in my testCompile, but it's causing a conflict when I run tests in intelliJ, as intelliJ is defaulting to using the older Foo lib.</p> <p>I've tried excluding Foo, and then explicitly including it in testCompile, but it seems the exclude overrides the include in testCompile. </p> <p>I'm currently using the below to force a resolution, but I would prefer I don't force compile dependencies to a specific version. </p> <pre><code>configurations.all { resolutionStrategy { force 'org.foo:bar:1.0' } } </code></pre>
34,196,694
0
Can't get test through the end with protractor <p>I have simple test doing login and trying to check if it's success:</p> <pre><code>describe('My Angular App', function () { describe('visiting the main homepage', function () { beforeEach(function () { browser.get('/'); element(By.id("siteLogin")).click(); }); it('should login successfully', function() { element(By.name("login_username")).sendKeys("[email protected]"); element(By.name("login_password")).sendKeys("testpass"); element(By.id("formLoginButton")).click().then(function() { browser.getCurrentUrl().then(function(url){ expect(url).toContain("profile"); }); }); }); }); }); </code></pre> <p>It goes well until that last part where I'm checking URL, and in <strong>Selenium Server</strong> I get:</p> <pre><code>INFO - Executing: [execute async script: try { return (function (rootSelector, callback) { var el = document.querySelector(rootSelector); try { if (window.getAngularTestability) { window.getAngularTestability(el).whenStable(callback); return; } if (!window.angular) { throw new Error('angular could not be found on the window'); } if (angular.getTestability) { angular.getTestability(el).whenStable(callback); } else { if (!angular.element(el).injector()) { throw new Error('root element (' + rootSelector + ') has no injector.' + ' this may mean it is not inside ng-app.'); } angular.element(el).injector().get('$browser'). notifyWhenNoOutstandingRequests(callback); } } catch (err) { callback(err.message); } }).apply(this, arguments); } catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body]]) </code></pre> <p>and also I get:</p> <pre><code>Failures: 1) My Angular App visiting the main homepage should login successfully Message: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. </code></pre> <p>My <strong>protractor-conf.js</strong>:</p> <pre><code>exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', baseUrl: 'http://localhost:8080/Mysite', capabilities: { 'browserName': 'firefox' // muste use firefox because I can't get .click() to work in Chrome }, specs: [ 'spec-e2e/*.js' ], framework: 'jasmine2', jasmineNodeOpts: { isVerbose: true, showColors: true, defaultTimeoutInterval: 30000 } }; </code></pre> <p>I appreciate any help on this one. Thanks</p>
18,319,295
0
How to disable chunked encoding in Mule cxf:proxy-client <p>I'm using <code>Mule 3.3.2</code> <code>cxf:proxy-client</code> to call third-party Soap service this way:</p> <pre><code>&lt;outbound-endpoint address="https://www.xyz.biz/Dms/Call.aws" mimeType="text/xml" connector-ref="https.connector" responseTimeout="100000"&gt; &lt;cxf:proxy-client payload="envelope" enableMuleSoapHeaders="false"&gt; &lt;cxf:inInterceptors&gt; &lt;spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" /&gt; &lt;/cxf:inInterceptors&gt; &lt;cxf:outInterceptors&gt; &lt;spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" /&gt; &lt;/cxf:outInterceptors&gt; &lt;/cxf:proxy-client&gt; &lt;/outbound-endpoint&gt; </code></pre> <p>By default, the message is transmitted as <code>chunked</code> which is good but unfortunately server cannot handle that. How can I disable chunking in <code>proxy-client</code> so that instead of <code>Transfer-Encoding: chunked</code>, <code>Content-Length</code> header is passed.</p>
29,847,824
0
<p>This works for me </p> <pre><code>.directive('updateinfo',['$compile', function($compile) { function link(scope, element, attrs) { function update(){ var str = '&lt;input type="text" ng-model="log1" /&gt;'; element.html(str); } update(); element.replaceWith($compile(element.html())(scope)); } return { link: link }; }]); </code></pre>
34,391,012
0
<p>I'm sure this will help:</p> <pre><code>DirectoryInfo DirInfo = new DirectoryInfo(@"C:/PCRequestFiles"); var files = from f in DirInfo.EnumerateFiles() where f.CreationTimeUtc &lt; EndDate &amp;&amp; f.CreationTimeUtc &gt; StartDate select f; </code></pre>
34,428,958
0
<p>@Luksprog answer is correct but not working for me. After some experimentation, I found out that removing the android namespace from editTextStyle made it work for me.</p> <pre><code>&lt;style name="App_Theme" parent="@android:style/Theme.Holo"&gt; &lt;item name="editTextStyle"&gt;@style/App_EditTextStyle&lt;/item&gt; &lt;/style&gt; </code></pre> <p>and make your custom style to extend <code>Widget.EditText</code> or if using the AppCompat theme <code>Widget.AppCompat.EditText</code>:</p> <pre><code>&lt;style name="App_EditTextStyle" parent="@android:style/Widget.EditText"&gt; &lt;item name="android:background"&gt;@drawable/filled_roundededges_box_dark&lt;/item&gt; &lt;item name="android:textColor"&gt;#808080&lt;/item&gt; &lt;item name="android:layout_height"&gt;45dip&lt;/item&gt; &lt;/style&gt; </code></pre>
28,819,316
0
<p>The MSDN documentation from the link you provided indicates that the new syntax for the DOM L4 event constructor pattern:</p> <blockquote> <p>Applies to Internet Explorer for Windows 10 Technical Preview and later.</p> </blockquote> <p>which is a different version of IE from what you are using. So it's expected that IE11 does not support this feature</p>
6,516,638
0
Loading different views into a custom view dynamically <p>I've an application that performs a multi-step process. Each step is implemented as a <code>NSView</code> subclass and I want to navigate between the different views. I'm trying this by implementing a custom view and then loading different views into the custom view I made. Is this the right way to do it? What is the best approach to implement this?</p>
28,701,159
0
confusion about .html() and .append() when I'm trying to overwrite elements in a loop <p>Sorry about the gory title. Effectively I'm trying to loop through a 2 dimensional array and I'm using autocomplete to output every time a single character is changed. If I use <code>.append</code> or <code>.prepend</code> then I have a long list of characters and that's not quite what I want, I'd like to overwrite every character change so that I'm not stuck with 50 results. I tried using <code>.html</code> and while it works to some extent (it overwrites) it only outputs the last element in the 2 dimensional array, which isn't quite what I want since I'd like to output all elements in the array.</p> <p>Here is my code: </p> <pre><code>for(var i = 0, len = data[1].length; i &lt; len; i++) { var currentDesc = data[2][i]; if(currentDesc.indexOf("may refer to:") &lt;= -1) { $('#results').append('&lt;div id="allResults"&gt;&lt;a href="'+ data[3][i] +'"&gt;'+ data[1][i] +'&lt;/a&gt;&lt;div id="descResults"&gt;'+ data[2][i] +'&lt;/div&gt;&lt;/div&gt;'); } } </code></pre> <p>Any ideas? I've just tried <code>.html()</code>, <code>.append</code>, and <code>.prepend</code></p>
36,239,903
0
What's the difference between Remove and Exclude when refactoring with PyCharm? <p>The <a href="https://www.jetbrains.com/help/pycharm/2016.1/refactoring-source-code.html?origin=old_help" rel="nofollow">official PyCharm docs</a> explain <code>Exclude</code> when it comes to refactoring: One can, say, rename something with refactoring (Shift+F6), causing the Find window to pop up with a Preview. Within, it shows files which will be updated as a result of the refactor. One can right-click on a file or folder in this Preview and choose <code>Remove</code> or <code>Exclude</code>. What's the difference? </p>
40,414,462
0
<p>Here's an alternative using a ChartWrapper instead of a chart.</p> <pre><code>var opts = { "containerId": "chart_div", "dataTable": datatable, "chartType": "Table", "options": {"title": "Now you see the columns, now you don't!"} } var chartwrapper = new google.visualization.ChartWrapper(opts); // set the columns to show chartwrapper.setView({'columns': [0, 1, 4, 5]}); chartwrapper.draw(); </code></pre> <p>If you use a ChartWrapper, you can easily add a function to change the hidden columns, or show all the columns. To show all the columns, pass <code>null</code> as the value of <code>'columns'</code>. For instance, using jQuery, </p> <pre><code>$('button').click(function() { // use your preferred method to get an array of column indexes or null var columns = eval($(this).val()); chartwrapper.setView({'columns': columns}); chartwrapper.draw(); }); </code></pre> <p>In your html,</p> <pre><code>&lt;button value="[0, 1, 3]" &gt;Hide columns&lt;/button&gt; &lt;button value="null"&gt;Expand All&lt;/button&gt; </code></pre> <p>(Note: <code>eval</code> used for conciseness. Use what suits your code. It's beside the point.)</p>
33,889,128
0
<p>its just missing its outer container.</p> <p>try this:</p> <pre><code>return new JsonResponse( array( array( "id" =&gt; 288, "title" =&gt; "Titanic", "year" =&gt; "1997" )) ); </code></pre> <p>this should output as:</p> <pre><code>[{"id":288,"title":"Titanic","year":"1997"}] </code></pre>
41,030,411
0
<p>can you format your data in question. I am not sure whether I get youe point?</p> <pre><code> CREATE TABLE #tt([name] VARCHAR(10),[date] DATE,skill INT,seconds INT, calls int ) INSERT INTO #tt SELECT 'bob','9/2/2016',706,12771,56 UNION all SELECT 'bob','9/2/2016',707,4061,16 UNION all SELECT 'bob','9/2/2016',708,2577,15 UNION all SELECT 'bob','9/2/2016',709,2156,6 SELECT * FROM ( SELECT t.name,t.date,c.* FROM #tt AS t CROSS APPLY(VALUES(LTRIM(t.skill)+'sec',t.seconds),(LTRIM(t.skill)+'calls',t.seconds)) c(t,v) ) AS A PIVOT(MAX(v) FOR t IN ([706sec],[706calls],[707sec],[707calls],[708sec],[708calls],[709sec],[709calls])) p </code></pre> <pre> name date 706sec 706calls 707sec 707calls 708sec 708calls 709sec 709calls ---------- ---------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- bob 2016-09-02 12771 12771 4061 4061 2577 2577 2156 2156 </pre> <p>if the count of skill is not fix, you can use dynamic script:</p> <pre><code> DECLARE @col VARCHAR(max),@sql VARCHAR(max) SELECT @col=ISNULL(@col+',[','[')+LTRIM(skill)+'sec],['+LTRIM(skill)+'calls]' FROM #tt GROUP BY skill SET @sql=' SELECT * FROM ( SELECT t.name,t.date,c.* FROM #tt AS t CROSS APPLY(VALUES(LTRIM(t.skill)+''sec'',t.seconds),(LTRIM(t.skill)+''calls'',t.seconds)) c(t,v) ) AS A PIVOT(MAX(v) FOR t IN ('+@col+')) p' EXEC (@sql) </code></pre>
40,786,489
0
<p>try this one</p> <pre><code>self.textField.backgroundColor = [UIColor redColor]; </code></pre>
41,043,440
0
Excel MDX linked server fails connection test <p>My first post after 2 years of learning to write SQL and using SQL Server, most of my questions have been answered researching on this website, however I cannot find the answer to my question below:</p> <p>I am creating a new linked server, grabbing data from Excel using an MDX query in my SQL script. For example:</p> <pre><code>SELECT * into raw.example FROM openquery( Test1, 'MDX CODE/etc etc' </code></pre> <p>I clicked on my database > Server Objects > Linked Servers > New Linked Server > </p> <pre><code>Linker Server: TESTEXAMPLE Server Type: other data source Provider: Microsoft OLE DB Provider for Analysis Services 10.0 Product Name: Test1 Data Source: Name of server Provider String: Location: Catalog: OLAP </code></pre> <p>After I click "ok" to create this linked server this message comes up:</p> <blockquote> <p>The linked server has been created but failed a connection test. Do you want to keep the linked server?</p> <p>OLE DB provider 'MSOLAP' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. (Microsoft SQL Server, Error: 7308)</p> </blockquote> <p>I am not sure why it isn't connecting. Is it a server issue where I have to ask for permission to access it? Or do I somehow need to revert away from the provider being configured to run in a single-threaded apartment mode?</p> <p>I am doing this on my local SQL Server Express Edition machine. Whereas before my script and <code>OPENQUERY/MDX</code> query worked on a remote desktop server etc.</p> <p>I have looked at other posts but those solutions do not solve my problem.</p>
20,171,842
0
<p>This issue is due to that Ant can not find the tools.jar file.</p> <p>You need to copy the tools.jar file and put it in the lib folder for the ant to work.</p> <p>Do a search for tools.jar file in the lib folders from other sdk libraries and put that in the above path in error.</p>
24,489,067
0
<p>There is no GDI/canvas implementation built into Unity. Drawing these in rastered 2D would be quite hard in Unity (basically putpixel level, or finding some third party library).</p> <p>You have an alternative, though - you can draw these shapes in 3D, ignoring the third dimension. You have a few methods for this:</p> <ol> <li><p><a href="http://docs.unity3d.com/Manual/class-LineRenderer.html" rel="nofollow">Line renderers</a> - this one will be the easiest, but forget about anything else than just drawing the outline, no fill etc.</p></li> <li><p><a href="http://docs.unity3d.com/ScriptReference/Mesh.html" rel="nofollow">Make your own mesh</a> - This will let you use the geometry with your scene. It's an retained mode API (you init your geometry once)</p></li> <li><p><a href="http://docs.unity3d.com/ScriptReference/GL.html" rel="nofollow">Use the GL namespace</a> - This will be only rendered on the screen, no interaction with the scene. It's an immidiate mode API (draw everything on every frame)</p></li> </ol>
35,316,888
0
<p>It depends when you start from (0,0) or at a random location in the matrix.</p> <p>If it is (0,0) ; use Depth First to go until the end of one branch then the others. Use Breadth First to iterate through all neigbouring nodes at a step. Check only down and right nodes.</p> <p>If it is at a random location in the matrix, you need to trace all 4 neighbouring nodes.</p>
1,757,169
0
<p>Absolutely yes. There is no real ideal approach for everyone, however -- after much practice you will find that it will depend on what you're most comfortable with. Some of the ways we have used Virtualization:</p> <ul> <li>Virtualized complete .NET development environment in Windows XP, including VS 2008, IIS, MS SQL Server</li> <li>Virtualized complete PHP + RoR development environment in CentOS</li> <li>Virtualized multiple complete Java environments in Windows XP, including Eclipse, Tomcat / Jboss, MySQL and Apache</li> <li>Virtualized multiple complete server environments (with GUI's) in Server 2003, Server 2008, Ubuntu, CentOS, Red Hat, and openSUSE.</li> </ul> <p>In your case, I would say virtualize the entire desktop, then clone it so you can run multiple instances on which you can try your different variations of gem packages, plugins, and configurations. If your host machine has enough RAM -- at least 4GB, you should be able to run at least 3 instances needing 1GB of RAM each. Rule of thumb is to always reserve 1GB for host OS.</p> <p>Also, if your machine is fast enough, you should notice little to no lag when you're running in the virtual instance GUI, except possibly when running a build script or starting a server :)</p> <p>By the way, our virtualization client of choice is <a href="http://www.virtualbox.org/" rel="nofollow noreferrer">VirtualBox</a>.</p>
5,666,040
0
<p>You may want to check out <a href="http://www.sencha.com/products/touch/demos/" rel="nofollow">Sencha Touch</a>, they provide a full HTML5 version of many common UI components for mobile web site development, including tab bars.</p>
11,881,861
0
<p>It's because the file permissions are not the only protection you're encountering.</p> <p>Those aren't just regular text files on a file system, <code>procfs</code> is a window into process internals and you have to get past both the file permissions <em>plus</em> whatever other protections are in place.</p> <p>The maps show potentially dangerous information about memory usage and where executable code is located within the process space. If you look into ASLR, you'll see this was a method of preventing potential attackers from knowing where code was loaded and it wouldn't make sense to reveal it in a world-readable entry in <code>procfs</code>.</p> <p>This protection was added <a href="http://lwn.net/Articles/225589/">way back in 2007</a>:</p> <blockquote> <p>This change implements a check using "ptrace_may_attach" before allowing access to read the maps contents. To control this protection, the new knob /proc/sys/kernel/maps_protect has been added, with corresponding updates to the procfs documentation.</p> </blockquote> <p>Within <code>ptrace_may_attach()</code> (actually within one of the functions it calls) lies the following code:</p> <pre><code>if (((current-&gt;uid != task-&gt;euid) || (current-&gt;uid != task-&gt;suid) || (current-&gt;uid != task-&gt;uid) || (current-&gt;gid != task-&gt;egid) || (current-&gt;gid != task-&gt;sgid) || (current-&gt;gid != task-&gt;gid)) &amp;&amp; !capable(CAP_SYS_PTRACE)) return -EPERM; </code></pre> <p>so that, unless you have the same real user/group ID, saved user/group ID and effective user/group ID (i.e., no sneaky <code>setuid</code> stuff) and they're the same as the user/group ID that owns the process, you're not allowed to see inside that "file" (unless your process has the <code>CAP_SYS_PTRACE</code> capability of course).</p>
1,706,135
0
<p>If your web server is <a href="http://blog.thinkphp.de/archives/136-Make-the-download-of-large-files-with-PHP-and-lighty-very-easy.html" rel="nofollow noreferrer">lighttpd</a> or <a href="http://www.adaniels.nl/articles/how-i-php-x-sendfile/" rel="nofollow noreferrer">Apache with mod_xsendfile</a>, then you can send the file by specifying a special <code>X-Sendfile</code> header. This allows the web server to make a <code>sendfile</code> call, which can be very, very fast. </p> <p>The reason is <code>sendfile</code> is usually an optimized kernel call which can take bits from the file system and directly put them on a TCP socket. </p>
13,336,097
0
<p>The problem was solved by adding MAYSCRIPT to the applet tag in the html.</p> <p>Like this:</p> <pre><code>&lt;applet code="com.example.MyApplet.class" name="myapplet" codebase="http://localhost:8080/example/classes" align="baseline" width="200" height="200" MAYSCRIPT&gt; &lt;PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"&gt; alt="Your browser understands the &amp;lt;APPLET&amp;gt; tag but isn't running the applet, for some reason." Your browser is completely ignoring the &amp;lt;APPLET&amp;gt; tag! &lt;/applet&gt; </code></pre>
29,048,191
0
<p>You mean:</p> <ol> <li>How to capture the card number from the returning data. see this <a href="http://www.markhagan.me/Samples/CreditCardSwipeMagneticStripProcessing" rel="nofollow">code</a>.</li> <li>How to interact with the Device, if USB Device see this <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ff468895(v=vs.85).aspx" rel="nofollow">code</a>,or serial Device use system.windows.IO.serial port class.</li> </ol>
33,729,876
0
how to send data http://localhost/someproject/editid/1 instead of http://localhost/someproject/editid=1 <p>how to send data <code>http://localhost/someproject/editid/1</code> instead of <code>http://localhost/someproject/client_list.php?editid=1</code> </p> <p>please let me know how the above url works,we need to use any api or webservices to pass above url parameters in php </p>
10,060,484
0
<p>To check if two strings are the same in Java, use <code>.equals()</code>:</p> <pre><code>"1" == new String("1") //returns false "1".equals(new String("1")) //returns true </code></pre> <p>EDIT: Added new String("1") to ensure we are talking a new string.</p>
14,627,247
0
<p>Jim, may I know what Operating System do you use? If you're using Windows Server OS, there should be no problem with the number of users that can access your application. But if you're using Windows client OS like XP, Vista, 7 then you have limits with simultaneous connections to your web server. </p>
16,941,136
0
<p>Have a look at the Doctrine documentation to see what you can get in the <code>preUpdate</code> lifecycle callback: <a href="http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate" rel="nofollow">http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate</a> </p> <p>You have direct access to the original and changed values, so you don't have to query the database.</p> <p>And to answer your question, why the two values are the same: I'm not 100% sure on that but most probably the <code>EntityManager</code> actually understands that you want to retrieve the same object as you already have, so it returns it without querying the database. To actually query the DB again you would have to somehow refresh the object in the EM (which will probably end up in loosing your changes).</p>
7,649,018
0
Parser replace pattern <p>I have problems with pattern. I need to process some text for example:</p> <pre><code>&lt;div&gt;{text1}&lt;/div&gt;&lt;span&gt;{text2}&lt;/span&gt; </code></pre> <p>After the process I need to get in place of {text1} and {text2} some words from dictionary. I'm preparing ui interface for diffrent languages. This is in PHP. For now I have something like this but this doesn't work:</p> <pre><code>function translate_callback($matches) { global $dict; print_r($matches); return 'replacement'; } function translate($input) { return preg_replace_callback('/(\{.+\})/', 'translate_callback', $input); } echo translate('&lt;div&gt;{bodynum}&lt;/div&gt;&lt;span&gt;{innernum}&lt;/span&gt;'); </code></pre> <p>This is test scenarion but I can't find the way to define pattern because this one in code match</p> <pre><code>{bodynum}&lt;/div&gt;&lt;span&gt;{innernum} </code></pre> <p>but I want pattern that will match</p> <pre><code>{bodynum} and then {innernum} </code></pre> <p>Can somebody help me with this. Thanks.</p> <p>The Solution:</p> <p>To match any character between { and }, but don't be greedy - match the shortest string which ends with } (the ? stops + being greedy).</p> <p>So the pattern now looks like: '/{(.+?)}/' and is exacly what I want.</p>
4,957,005
0
<p>Looks like you can't just pass touches in and have it respond to them :(</p> <p>You would have to use the [UIScrollView setContentOffset:animated:] method to move the scrollview yourself.</p> <hr> <p>A better way of intercepting the touches might be to put a view in front of the scrollview - grab any touches you want to listen to and then pass it to the next responder in the chain.</p> <p>You would make a subclass of UIView that overrode the touch handling methods, something like :</p> <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (scrollViewShouldGetThisTouch) [self.nextResponder touchesBegan:touches withEvent:event]; } </code></pre> <p>and just make this view have the same frame as your scrollview but be infront of it in the ui (transparent of course!).</p> <p>OR</p> <p>You could subclass UIScrollView - though this might result in odd errors if Apple ever change the implementation of a UIScrollView. I'd choose the other option!</p>
13,633,534
0
How to check if entity framework 5 is running with .net framework 4.5 <p>I am confusing if entity framework 5 is based on .net framework 4.5 or .net framework 4.0 in my project, because when I added ef5 to my project from nuget, it shows the run time version is v4.0.30319 as in attached image. (I assume it should be v4.5.50709?)</p> <p>In the project settings, the targeted framework is correctly set to .Net Framework 4.5 and I am using visual studio 2012.</p> <p>If it is not using .net framework 4.5. How I can do to make sure it is using .net framework 4.5? Thanks for your help. </p> <p><img src="https://i.stack.imgur.com/cLfNL.png" alt="here"></p>
21,407,481
0
Angulars $httpBackend not pure unit testing? <p>Angular advocates the use of <a href="http://docs.angularjs.org/api/ngMock.%24httpBackend" rel="nofollow">$httpBackend</a> to test your service. Doesn't that break the principle of unit testing since it also tests angular internals? </p> <p>Shouldn't we rather test with a mocked $resource (or $http if that's what you use)?</p> <p>Is this just for convenience?</p>
29,930,601
0
<p>You can use <a href="http://imperavi.com/redactor/docs/callbacks/image/#callback-imageUploadCallback" rel="nofollow">imageUploadCallback</a> for editing image tag.</p>
25,674,365
0
<p>I solved my own problem with the following steps: 1. Deleted MSCOMCTL.OCX from \Windows\Syswow64 2. Opened the Access form that was giving me a problem, and Access reinstalled MSCOMCTL.OCX automatically. 3. Opened a command window with the "Run As Administrator" option 4. Navigated to \Windows\Syswow64 5. Ran "regsvr32 /u MSCOMCTL.OCX" 6. Ran "regsvr32 MSCOMCTL.OCX" 7. Reopened Access and it worked! <strong>Note: You will need to do this in System32, NOT Syswow64 for 64-bit office. Dumb naming standard, I know.</strong></p> <p>@t_m , Thanks for your help!</p>
40,329,448
0
<p>In the <code>WebApiConfig</code> class add the following:</p> <pre><code> public static void Register(HttpConfiguration config) { config.EnableCors(); config.MapHttpAttributeRoutes(); // Web API routes below } </code></pre>
12,982,138
0
<p>You only have to change the client.</p> <p>Change its Naming.lookup() string, from "localhost" to the server's hostname or IP address. The server's Naming string in the bind() or rebind() call does not change from "localhost", because the server and its Registry are always on the same host.</p> <p>If you are using Registry instead of Naming, again you only have to change the client's LocateRegistry.getRegistry() call.</p>
34,503,110
0
cmocka malloc testing OOM and gcov <p>I'm having a hard time finding an answer to a nitch case using cmocka, testing malloc for failure (simulating), and using gcov</p> <p>Update about cmocka+gcov: I noticed I get empty gcda files as soon as I mock a function in my cmocka tests. Why? Googling cmocka and gcov gives results where people talk about using the two together. It seems most people are using CMake, something I will look at later but there should be no reason (that I can think of) that would require me to use cmake. Why can't I just use cmocka with the --coverage/-lgcov flags?</p> <p>Orignal question:</p> <p>I've tried a myriad combinations mostly based off of two main ideas:</p> <p>I tried using -Wl,--wrap=malloc so calls to malloc are wrapped. From my cmocka tests I attempted to use will_return(__wrap_malloc, (void*)NULL) to simulate a malloc failure. In my wrap function I use mock() to determine if I should return __real_malloc() or NULL. This has the ideal effect, however I found that gcov fails to create gcda files, which is part of the reason with wrapping malloc, so I can test malloc failing AND get code coverage results. I feel I've played dirty games with symbols and messed up malloc() calls called form other compilation units (gcov? cmocka?).</p> <p>Another way I tried was to us gcc -include using a #define for malloc to call "my malloc" and compile my target code to be tested with mymalloc.c (defining the "my malloc"). So a #define malloc _mymalloc helps me call only the "special malloc" from the target test code leaving malloc alone anywhere else it is called (i.e., leave the other compilation unites alone so they just always call real malloc). However I don't know how to use will_return() and mock() correctly to detect failure cases vs success cases. If I am testing malloc() failing I get what I want, I return NULL from "malloc" based on mock() returning NULL- this is all done in a wrapping function for malloc that is only called in the targeted code. However if I want to return the results of the real malloc than cmocka will fail since I didn't return the result from mock(). I wish I could just have cmocka just dequeue the results from the mock() macro and then not care that I didn't return the results since I need real results from malloc() so the code under test can function correctly.</p> <p>I feel it should be possible to combine malloc testing, with cmocka and get gcov results.</p> <p>whatever the answer is I'd like to pull of the following or something similar.</p> <pre><code>int business_code() { void* d = malloc(somethingCalculated); void* e = malloc(somethingElse); if(!d) return someRecovery(); if(!e) return someOtherRecovery(); return 0; } </code></pre> <p>then have cmocka tests like</p> <pre><code>cmocka_d_fail() { will_return(malloc, NULL); int ret = business_code(); assert_int_equal(ret, ERROR_CODE_D); } cmocka_e_fail() { will_return(malloc, __LINE__); // someway to tell wrapped malloc to give me real memory because the code under test needs it will_return(malloc, NULL); // I want "d" malloc to succeed but "e" malloc to fail int ret = business_code(); assert_int_equal(ret, ERROR_CODE_E); } </code></pre> <p>I get close with some of the #define/wrap ideas I tried but in the end I either mess up malloc and cause gcov to not spit out my coverage data or I don't have a way to have cmocka run malloc cases and return real memory i.e., not reeturn from mock() calls. On one hand I could call real malloc from my test driver but and pass that to will_return but my test_code doesn't know the size of the memory needed, only the code under test knows that.</p> <p>given time constraints I don't want to move away from cmocka and my current test infrastructure. I'd consider other ideas in the future though if what I want isn't possible. What I'm looking for I know isn't new but I'm trying to use a cmocka/gcov solution.</p> <p>Thanks</p>
28,298,873
0
<p>You can also do something like this:</p> <pre><code>grails.project.war.file = "target/${appName}${grails.util.Environment.current.name == 'development' ? '-dev' : ''}.war" </code></pre>
25,924,639
1
python idle how to create username? <p>Write a function called getUsername which takes two input parameters, firstname (string) and surname (string), and both returns and prints a username made up of the first character of the firstname and the first four characters of the surname. Assume that the given parameters always have at least four characters. </p>
27,669,584
0
Remove any kind of url from string in php? <p>I am having below data.</p> <p>Example 1</p> <pre><code>From : http://de.example.ch/biz/barbar-vintage-z%C3%BCrich I want: /biz/barbar-vintage-z%C3%BCrich </code></pre> <p>And also if there is</p> <pre><code>http://www.example.ch/biz/barbar-vintage-z%C3%BCrich </code></pre> <p>Then I also want</p> <pre><code> /biz/barbar-vintage-z%C3%BCrich </code></pre>