pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
26,294,033 | 0 | .htaccess RewriteCond %{REQUEST_FILENAME} !-d not working <p><code>.htaccess</code> code is,</p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^p/([A-Za-z0-9-_]+)/?$ redirect.php?url=$1 [NC,L] # RewriteRule ^[A-Za-z0-9-_]+/([A-Za-z0-9-_]+)/?$ product.php?seo_id=$1 [NC,L] # RewriteRule ^([A-Za-z0-9-_]+)/?$ catalog.php?seo_id=$1 [NC,L] # </code></pre> <p>I'm trying to access <code>http://example.com/directory/</code> which is already exist in server but i can't access it. There is no any error occuring but, if there is a request for already existant directory, rules after <code>RewriteCond %{REQUEST_FILENAME} !-d</code> should not be applied.</p> <p>But in this case one of the 3 rules are applying.</p> <p><code>RewriteCond %{REQUEST_FILENAME} !-d</code> is seems not working.</p> |
28,157,816 | 0 | <p>See <a href="http://stackoverflow.com/questions/20495302/transparent-background-with-three-js">Transparent background with three.js</a> for transparent background rendering and then you can apply CSS gradients <a href="http://www.w3schools.com/Css/css3_gradients.asp" rel="nofollow">http://www.w3schools.com/Css/css3_gradients.asp</a> however it won't move with your scene unless you get really tricky.</p> |
35,626,058 | 0 | <p>There's no built-in way to get INSERTs for all the rows in a result set using SQL Assistant. </p> <p>There's an ugly workaround using the <code>CSV</code>-UDF like:</p> <pre><code>WITH cte AS ( -- put your select here SELECT * FROM dbc.tablesV ) SELECT * FROM TABLE (CSV(NEW VARIANT_TYPE( -- you need to list each column of your table cte.DataBaseName ,cte.TABLENAME ,cte.Version ,cte.TableKind ,cte.ProtectionType ,cte.JournalFlag ,cte.CreatorName ,cte.RequestText ,cte.CommentString ,cte.ParentCount ,cte.ChildCount ,cte.NamedTblCheckCount ,cte.UnnamedTblCheckExist ,cte.PrimaryKeyIndexId ,cte.RepStatus ,cte.CreateTimeStamp ,cte.LastAlterName ,cte.LastAlterTimeStamp ,cte.RequestTxtOverflow ,cte.AccessCount ,cte.LastAccessTimeStamp ,cte.UtilVersion ,cte.QueueFlag ,cte.CommitOpt ,cte.TransLog ,cte.CheckOpt ,cte.TemporalProperty ,cte.ResolvedCurrent_Date ,cte.ResolvedCurrent_Timestamp ,cte.SystemDefinedJI ,cte.VTQualifier ,cte.TTQualifier ,cte.PIColumnCount ,cte.PartitioningLevels ,cte.LoadProperty ,cte.CurrentLoadId ,cte.LoadIdLayout ,cte.DelayedJI ), ',', '"') RETURNS (op VARCHAR(32000) CHARACTER SET UNICODE) ) AS dt; </code></pre> <p>Otherwise you must use a different tool...</p> |
9,135,181 | 0 | <p>an activity is not finished / destroyed on back pressed.</p> <p>Use </p> <pre><code> @Override public void onBackPressed() { finish(); } </code></pre> |
21,386,882 | 0 | <p>I think you must ask google about the way they get their results, but I don't think that maps.google.com is a simple implementation of the Maps-API/Services.</p> <p>However, <a href="https://developers.google.com/places/documentation/search#TextSearchRequests" rel="nofollow">textSearch</a> will give you the result: <a href="https://maps.googleapis.com/maps/api/place/textsearch/json?key=yourKey&sensor=false&radius=50000&location=40.338254%2C-74.585292&query=storybook+land" rel="nofollow">https://maps.googleapis.com/maps/api/place/textsearch/json?key=yourKey&sensor=false&radius=50000&location=40.338254%2C-74.585292&query=storybook+land</a></p> |
23,519,427 | 0 | <p>I finally found a solution.</p> <p>the command <strong><code>vdir -lib $lib -prop dpnd $entity</code></strong> returns you something like this:</p> <pre><code> data: ENTITY E1 # Depends on: P ieee std_logic_unsigned RYmj:=TK`k=k>D@Cz`zoB3 # Depends on: P ieee std_logic_arith 4`Y?g_lldn;7UL9IiJck01 # Depends on: P std textio 5>J:;AW>W1[[dW0I6EN1Q0 # Depends on: P ieee std_logic_1164 5=aWaoGZSMWIct0i^f`XF1 # ARCHITECTURE BODY rtl # Depends on: E L2 E2 3B3>6RbjY07ohgTgj<M4r0 # Depends on: E L3 E3 5?a[d8Ikz7>zWX`U97gNE2 # Depends on: P ieee std_logic_unsigned RYMj;=TK`k=k>C@Cz`zoB3 # Depends on: P ieee std_logic_arith 7`F?g_lkdn;7UL9IiJck01 # Depends on: P std textio 5>J:;AW>w0[[dW0I6EN1Q0 # Depends on: P ieee std_logic_1164 5=aWboGZSMlIcH0i^f`XF1 # Depends on: E work E1 ;4e7E?eQ@DHPeB>5WUDQK3 </code></pre> <p>P stands for package and E for Entity. So you can use regular expressions (like me in the extracting function) to extract the data you want.</p> <pre><code> proc get_dependency_list_of_entity { lib entity } { set vdir_data [ vdir -lib $lib -prop dpnd $entity ] set match [extracting $vdir_data "^ *Depends on: (.+)"] ... } ... } </code></pre> <p>As I mentioned already in the question: There are ways to get the library of an entity with vdir and also with <code>write report -tcl</code></p> |
13,888,765 | 0 | Liking my page on Facebook shows the wrong image <p>I've just updated my site to include og: tags and add Facebook like buttons, twitter buttons, etc. However, when I click the Like button and then go look at my Facebook profile, the image used is wrong.</p> <p>This is the page on my site I'm referring to: <a href="http://www.inadaydevelopment.com/app/android/10bii-financial-calculator" rel="nofollow noreferrer">http://www.inadaydevelopment.com/app/android/10bii-financial-calculator</a></p> <p>My <code><head></code> tag includes the following <code>og:image</code> tags:</p> <pre><code><meta property="og:image" content="http://www.inadaydevelopment.com/sites/default/files/app-10biiFinancialCalculator-Android-1-AmortizationSchedule.png"> <meta property="og:image" content="http://www.inadaydevelopment.com/sites/default/files/app-10biiFinancialCalculator-Android-2-CashFlowDiagram-Landscape.png"> <meta property="og:image" content="http://www.inadaydevelopment.com/sites/default/files/app-10biiFinancialCalculator-Android-4-Equation.png"> <meta property="og:image" content="http://www.inadaydevelopment.com/sites/default/files/app-10biiFinancialCalculator-Android-6-UnevenCashflowsNPV.png"> <meta property="og:image" content="http://www.inadaydevelopment.com/sites/default/files/app-10biiFinancialCalculator-Icon.png"> </code></pre> <p>However, the image being shown on my Facebook profile is the little twitter icon I have in the sidebar which links to my twitter account:</p> <p><img src="https://i.stack.imgur.com/pHny7.png" alt="enter image description here"></p> <p>When I look at the Facebook Debugger for my url, it shows the images that I have listed above in the og:image tags:</p> <p><img src="https://i.stack.imgur.com/iV4Cu.png" alt="enter image description here"></p> <p>Why is Facebook grabbing the twitter icon out of my sidebar instead of using the og:image tags? </p> |
33,397,365 | 0 | android duplicate provider authority on apps that don't have provider <p>I have 7 apps on store, but when I try to install 3 of them I get duplicate provider authority error on the second of these 3 that I try to install.</p> <p>none of my apps have provider in manifest...</p> <p>any idea?</p> |
9,521,567 | 0 | convert a Matlab code into C code <p>I'm trying to understand and learn the C language, and since I used to work in Matlab, I'm interested in knowing how this code would be converted into C. </p> <pre><code>for j=1:n v=A(:,j); for i=1:j-1 R(i,j)=Q(:,i)'*A(:,j); v=v-R(i,j)*Q(:,i); end R(j,j)=norm(v); Q(:,j)=v/R(j,j); end </code></pre> |
35,908,551 | 0 | <p>The answer was increadibly simple, thanks for the reference to <code>ICollectionViewLiveShaping.IsLiveSortin</code> from @KornMuffin. </p> <p><a href="https://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionviewliveshaping.islivesorting(v=vs.110).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionviewliveshaping.islivesorting(v=vs.110).aspx</a></p> <p>Here were my steps to implement and resolve this.</p> <p>In my AlarmView.xaml code behind I added a static variable that contains the instance of the AlarmView that is created.</p> <p>Here is the constructor of the AlarmView</p> <pre><code>public partial class AlarmsView : UserControl { public static AlarmsView View; public AlarmsView() { InitializeComponent(); View = this; this.DataContext = new ViewModel.AlarmsViewModel(); } } </code></pre> <p>I created the static view because I need access to the datagrid from the ViewModel for an event (will get to this in a moment)</p> <p>In the AlarmViewModel.cs there is the <code>ObservableCollection</code></p> <pre><code> public CollectionViewSource ViewSource { get; set; } public ObservableCollection<Model.AlarmItem> Collection { get; set; } </code></pre> <p>Then, in the constructor of the <code>AlarmViewModel</code>, I instantiated the <code>ObservableCollection</code> and using <code>ICollectionViewLiveShaping</code> set the <code>.IsLiveSorting</code> to true. Here, I also make use of the static variable created in the AlarmView code behind to gain access to the datagrid so we can hook into the <code>.Sorting</code> event.</p> <pre><code> public AlarmsViewModel() { if (_alarmItemRepository == null) _alarmItemRepository = new AlarmItemRepository(); this.Collection = new ObservableCollection<Model.AlarmItem>(_alarmItemRepository.GetAlarmItems()); ICollectionView collectionView = CollectionViewSource.GetDefaultView(this.Collection); collectionView.SortDescriptions.Add(new SortDescription("NextSpawn", ListSortDirection.Ascending)); var view = (ICollectionViewLiveShaping)CollectionViewSource.GetDefaultView(this.Collection); view.IsLiveSorting = true; // Bind to the sorting event of the datagrid in the AlarmView AlarmsView.View.dgAlarms.Sorting += DgAlarms_Sorting; // Other code // ... // ... } </code></pre> <p>Then, in the sorting event handling, we update the sort description when a user clicks a column header to sort the column.</p> <pre><code> private void DgAlarms_Sorting(object sender, DataGridSortingEventArgs e) { ICollectionView collectionView = CollectionViewSource.GetDefaultView(this.Collection); collectionView.SortDescriptions.Add(new SortDescription(e.Column.SortMemberPath, e.Column.SortDirection.GetValueOrDefault())); } </code></pre> |
5,800,039 | 0 | <p>It's so easy, just call <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.readxml.aspx" rel="nofollow">DataTable.ReadXml</a></p> |
2,576,426 | 0 | <p>On the irony side, I am currently updating the SCSF documentation for ClickOnce deployment for .NET 4.0, and now I know exactly what the problem it. </p> <p>First, you want to publish to a disk location, not directly to the webserver. So do that, and then copy the dll's you want to add to the deployment into the version folder with the application manifest (.manifest). Rename them yourself -- just add .deploy on the end.</p> <p>Bring up MageUI and open the application manifest in that folder, then uncheck the box that says "add .deploy to the file names". Click "populate". </p> <p>Then remove the deployment manifest from the list; it's called something like appname.application. You don't want it to be included in the manifest's list of files. </p> <p>Now you can save and sign the application manifest. Then without exiting mageUI, open the deployment manifest that is in the root folder (<em>NOT</em> the one in the version folder). Click on "Application Reference", then click Select Manifest. Dig down to the application manifest in the version folder that you just signed and select it. Then just save and sign the deployment manifest. It puts a relative path in there, so if you modify the .application file in the version folder, it won't work right when deployed. </p> <p>Now take that .application file from the root folder and copy it into the version folder (replacing the one that's there) so you have the right copy for that version in case you need it later. </p> <p>Now copy the whole shebang out to the webserver. it should work.</p> |
15,785,214 | 0 | <p>I found a compatibility <a href="https://github.com/BoD/android-switch-backport" rel="nofollow">solution</a> that you could try.</p> |
7,528,341 | 0 | xsel for windows equivalent API or command line? <p>Is there an API or command line utility that returns the currently selected text from either active window or even globally, like the linux utility "xsel" ?</p> <ul> <li>I don't mind getting less than 100% success.</li> <li>i know that each window can have its own text selection, but it's negligible for now.</li> <li>For now the only solution/workaround i have is to sendkeys "ctrl+c" and read from clipboard, but that's bad solution for 2 obvious reasons. </li> <li>I know how to do it on MS-Word, but that's 1% of the cases.</li> </ul> <p>thanks</p> <p><strong>edit</strong></p> <p>From <a href="http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Controls/Q_21607824.html" rel="nofollow">this discussion</a> i learn that there are too many technologies to select text. so i'll fall back to using clipboard. thanks anyway. </p> <p>i'm leaving this question open for a while in case somebody have a miracle.</p> |
8,961,558 | 0 | unable to get the value of the text field with the help of respective checkboxes. please help <p>I've a doubt. I've 3 textboxes and each is having checkboxes next to it. I want to display the values of only those textboxes whose respective checkboxes are clicked. Following is the attached HTML and PHP codes:</p> <pre><code><html> <head> </head> <body> <form name="f" method="post" action="4.php"> <table> <tr> <th> Facility </th> </tr> <tr> <td><input type="text" name="a1" value="a"></td><td><input type="checkbox" id="facility[]" name="facility[]" value="Hostel"></td> </tr> <tr> <td><input type="text" name="b1" value="b"></td><td><input type="checkbox" id="facility[]" name="facility[]" value="Transport"></td> </tr> <tr> <td><input type="text" name="c1" value="c"></td><td><input type="checkbox" id="facility[]" name="facility[]" value="Food"></td> </tr> <tr> <td colspan="3"><input type="submit" value="submit" /></td> </tr> </table> </form> </body> </html> </code></pre> <p>and below is the PHP part.</p> <pre><code><?php $a=$_POST['a1']; $b=$_POST['b1']; $c=$_POST['c1']; $facilityArray = $_POST['facility']; $facility = ""; if(count($facilityArray) > 0) { foreach($facilityArray as $fac) { $facility .= " " . $fac; } } echo $facility; echo "<br>"; echo $a; echo "<br>"; echo $b; echo "<br>"; echo $c; ?> </code></pre> <p>With the help of following codes I am able to display all the values of checked checkboxes. I am also able to display the values of all the textboxes. But I actually want to display the values of only those textboxes whose respective checkboxes are clicked. I know it may be a very basic question but please help me grow in PHP. Thanks in advance... :(</p> |
28,138,577 | 0 | <p>If I understand correctly, you can do this with conditional aggregation. Just find the minimum and maximum prices in a subquery, and then pull the data out for those:</p> <pre><code> SELECT b.brand_name, minmax.price_max, max(case when m.price = minmax.price_max then m.product_id end) as max_product_id, max(case when m.price = minmax.price_max then m.name end) as max_name, minmax.price_min, max(case when m.price = minmax.price_min then m.product_id end) as min_product_id, max(case when m.price = minmax.price_min then m.name end) as min_name FROM model m INNER JOIN series s ON s.series_id = m.series_id INNER JOIN brand b ON b.brand_id = s.brand_id INNER JOIN (SELECT m.product_id, m.name, MIN(m.price) AS price_min, MAX(m.price) AS price_max FROM model m ) minmax ON m.price IN (minmax.price_min, minmax.proc_max) AND minmax.product_id = m.product_id GROUP BY b.brand_id </code></pre> <p>Note if there are multiple products with the same minimum or maximum price, this pulls out an arbitrary one. You can get all of them by using <code>group_concat()</code> instead of <code>max()</code>.</p> |
22,931,813 | 0 | <p>I guess you need this one,</p> <pre><code>UPDATE [Table] SET Active = 1, Subscribed = 1, RenewDate = GETDATE(), EndDate = DATEADD(mm,1,getdate()) OUTPUT INSERTED.TABLE_PrimaryKeyID WHERE SC = @SC AND Service = @Ser </code></pre> <p>Main source: <a href="http://stackoverflow.com/questions/1610509/getting-the-id-of-a-row-i-updated-in-sql-server">here</a></p> |
40,189,478 | 0 | Training Time for Eigenfaces using Opencv c++ <p>I'm currently training a database of Eigenfaces using Opencv. I have 50 persons in my database with 250 pictures each, and I use all Eigenfaces and its been 2 days since I started training and it still is not finished. How long should I still wait? and is 250 for each person too much? </p> <p>Any information will be much appreciated! Thanks!</p> |
37,923,173 | 0 | <p>I came across the same issue when I did all the setup and run for django with Python3 but ran the following command:</p> <pre><code>$ python manage.py migrate </code></pre> <p>fixed the issue by using a consistent version of Python:</p> <pre><code>$ python3 manage.py migrate Operations to perform: Apply all migrations: sessions, auth, admin, contenttypes Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying sessions.0001_initial... OK </code></pre> <p>Other commands I ran before this were:</p> <pre><code>python3 -m pip install django django-admin startproject learning_site python3 manage.py runserver 0.0.0.0:8000 </code></pre> |
4,548,504 | 0 | <p>You can use this function to get query string value:</p> <pre><code>function getParameterByName( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } </code></pre> <p><strong>Example:</strong></p> <pre><code>var param = getParameterByName('yourVar'); </code></pre> |
32,541,629 | 0 | <p>You could do it either inside the controller itself:</p> <pre><code>public function update(Request $request) { // Get the current users IP address and add it to the request $request->merge(['ip_address' => $_SERVER['REMOTE_ADDR']]); // Validate the IP address contained inside the request $this->validate($request, [ 'ip_address' => 'required|ip' ]); } </code></pre> <p>The <code>$request->merge()</code> method will allow you to add items to the form request, and then you can just make a simple validate request on the IP only.</p> <p>Alternatively, you could move all this to it's own Request class and inject that into the method.</p> |
20,131,248 | 0 | How to edit header.tpl in CMS Made Simple <p>I am new in CMS Made Simple and I need to edit header.tpl file. I found the file location here tmp/templates/header.tpl but when I do any change in this file, it does not affect anything at frontend.</p> <p>I need the help to edit header.tpl file. </p> |
8,367,728 | 0 | iphone : How to keep 3G/GPRS preferred network in presence of Wifi? <p>I am developing an application that communicates (UDP communication) with our server remotely through 3G/GPRS. As we have to establish serial communication with a digital device and our application through Wifi.</p> <p>Now the problem is that when application connects with wifi it rejects 3G/GPRS and tries to find internet connectivity on wifi which it could not and as a result it lost connection with server.</p> <p>Now I want to know that how can I keep my connection with 3G/GPRS and as well as with Wifi so that I could communication both with the server through internet (3G/GPRS) and with the device through wifi.</p> <p>(Wifi does not have Internet at the moment as the application is using remotely in a Cab/Taxi)</p> |
39,120,995 | 0 | Some problems with android listview <p>I am trying to make some practice about android <code>ListView</code>. Code bellow is in a<br> <code>listfragment</code>:</p> <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ View view= inflater.inflate(R.layout.frag_getfriends,container,false); friendsListView=(ListView)view.findViewById(android.R.id.list); infoTextView=(TextView)view.findViewById(android.R.id.empty); swipe=(SwipeRefreshLayout)view.findViewById(R.id.swipe_refresh); swipe.setOnRefreshListener(this); arrayAdapter=new DataListAdapter(getActivity(),R.layout.userinfo_list_config,null); friendsListView.setAdapter(arrayAdapter); friendsListView.setOnItemClickListener((parent,itemView,position,id)->{ if(friends!=null){ User friend=friends.get(position); Toast.makeText(getActivity(),friend.getName(),Toast.LENGTH_SHORT).show(); } }); presenter.startQuery(true); return view; } </code></pre> <p><code>Adapter</code> constructor is:</p> <pre><code> public DataListAdapter(Context context, int itemLayoutResoureId, ArrayList<User>friends){ super(context,itemLayoutResoureId,friends); this.context=context; this.users=new ArrayList<>(); users.addAll(friends); } </code></pre> <p>At the beginning,the <code>listview</code> has no data to display until this app fetches some data online:</p> <pre><code>@Override public void setDataList(ArrayList<User> friendsList) { this.friends=friendsList; arrayAdapter.clear(); arrayAdapter.addAll(friendsList); arrayAdapter.notifyDataSetChanged(); friendsListView.setAdapter(arrayAdapter); } </code></pre> <p>Later I can do some refresh.And each refresh happenes,the callback</p> <pre><code>setDataList </code></pre> <p>is fired and <code>listview</code> get updated. However,the app crashed. Logcat shows:</p> <pre><code> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mrdreamer.iknow/com.example.mrdreamer.iknow.Social.GetFriends}: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference at java.util.ArrayList.addAll(ArrayList.java:188) at com.example.mrdreamer.iknow.Social.DataListAdapter.<init>(DataListAdapter.java:35) at com.example.mrdreamer.iknow.Social.GetFriendsFrag.onCreateView(GetFriendsFrag.java:42) at android.app.Fragment.performCreateView(Fragment.java:2220) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148) at android.app.BackStackRecord.run(BackStackRecord.java:793) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535) at android.app.FragmentController.execPendingActions(FragmentController.java:325) at android.app.Activity.performStart(Activity.java:6252) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) </code></pre> <p>The problem is that in:</p> <pre><code>arrayAdapter=new DataListAdapter(getActivity(),R.layout.userinfo_list_config,null); </code></pre> <p>the last parameter cannot be null,which I understand. Now should I change to SimpleCursorAdapter or just make some change to current code? :) Thank you in advance.I am new to android developement.I am be very gratefull.:)</p> |
38,693,408 | 0 | <p>Just make the average of the percentages:</p> <pre><code>=AVERAGE(B1:B7) </code></pre> |
32,834,646 | 0 | <p>You can use <code>NOT EXISTS</code> to exclude holidays:</p> <pre><code>SELECT * FROM time_dimension ti WHERE NOT EXISTS(SELECT 1 FROM tbl_holidays WHERE startdate = ti.db_date) AND day_name IN ('Monday','Tuesday','Wednesday','Thursday','Friday'); </code></pre> |
33,270,235 | 0 | <p>Let me try a few suggestions in hopes that you can let us know what you are experiencing...</p> <blockquote> <p>On the template are you using an inline macro (i.e. - calling the content using <code>@Model.bodyContent</code>) or,</p> <p>Are you calling the umbraco field with <code><umbraco:Item field="bodyContent" runat="server" /></code></p> <p>If you are calling the value from within a macro, try wrapping the output in <code>@Html.Raw(bodyContent)</code></p> <p>Secondly, try using the form picker datatype that comes with Contour. Add it to your doctype and render the form using the RenderMacroContent method. If you need the full script to get this working let me know in reply, but this link (<a href="https://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent" rel="nofollow">https://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent</a>) should help.</p> </blockquote> <p>Finally, check the contour files and edit the <em>ContourForm.cshtml</em> file. Try using <code>@Html.Raw()</code> around the <code>@f.Caption</code> output within the <code><label></code> tag.</p> <p>It is hard to be too specific without some additional clues and troubleshooting, but this is where I would start. Any additional information you can provide will allow me to edit my answer and provide more assistance.</p> |
974,644 | 0 | <p>I haven't tried it yet, but <a href="http://www.svnmonitor.com/" rel="nofollow noreferrer">SVN-Monitor</a> might be useful. You will need ToirtoiseSVN client mentioned above to work with it.</p> |
2,059,665 | 0 | Why can't I forward-declare a class in a namespace like this? <pre><code>class Namespace::Class; </code></pre> <p>Why do I have to do this?:</p> <pre><code>namespace Namespace { class Class; } </code></pre> <p>Using VC++ 8.0, the compiler issues:</p> <blockquote> <p>error C2653: 'Namespace' : is not a class or namespace name</p> </blockquote> <p>I assume that the problem here is that the compiler cannot tell whether <code>Namespace</code> is a class or a namespace? But why does this matter since it's just a forward declaration?</p> <p>Is there another way to forward-declare a class defined in some namespace? The syntax above feels like I'm "reopening" the namespace and extending its definition. What if <code>Class</code> were not actually defined in <code>Namespace</code>? Would this result in an error at some point?</p> |
6,064,943 | 0 | Nuget package not adding reference on custom package <p>I created a nuspec file:</p> <pre><code><?xml version="1.0"?> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <id>MyPackage.dll</id> <version>3.5</version> <authors>Me</authors> <owners>Me</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>The description</description> <tags>tag1</tags> </metadata> </package> </code></pre> <p>In a directory with the file strucutre</p> <blockquote> <ul> <li>MyPackage <ul> <li>Assemblies <ul> <li>MyPackage.dll</li> </ul></li> <li>MyPackage.nuspec</li> </ul></li> </ul> </blockquote> <p>I created my package using <code>nuget.exe pack myPackage.nuspec</code> and placed it in my local sources. I can find and install it from visual studio at which point </p> <ul> <li>The dll is copied into the packages directory</li> <li>But the reference is not added to the project</li> <li>No repositories.config is created</li> <li>No packages.config is created</li> </ul> <p>What am I missing?</p> |
32,911,844 | 0 | <p>I made some assumptions on your UI. Rather than placing the items as radio buttons in a <code>ComboBox</code>, I placed all of the doughnuts and coffees into a respective <code>GroupBox</code>. The concepts of this answer will still apply, however you'll just have to be mindful that this is not directly drop-in and go. </p> <p>Here's the way I laid out the UI:</p> <p><a href="https://i.stack.imgur.com/DyIQs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DyIQs.png" alt="UI Layout"></a></p> <p>I have placed the <code>RadioButton</code>s for the items inside a <code>FlowLayoutPanel</code> inside of a <code>GroupBox</code>. I also placed labels into a TableLayoutPanel to provide the total amounts. </p> <p>The most important part is how I named the <code>RadioButton</code> controls for the items being listed. In the code behind file I used the names of the <code>RadioButton</code> controls to check which Item was being modified. I could have populated the <code>RadioButton</code> controls at run time to ensure that everything lined up, but that was more work and it's not difficult to do if you use <code>GetType(MyEnum).GetNames()</code> in the <code>Me.Load</code> event of the form to create new <code>RadioButtons</code> with the correct name, text, and adding the proper event handlers to the radio buttons.</p> <p>If you'd like to see how this works, add a new form to your Project and call it DoughnutsAndCoffee. Here is the designer file and the Code behind:</p> <p>Code Behind:</p> <pre><code>Public Class DoughnutsAndCoffee Private SelectedItems As New List(Of Items) Public Event ItemsChanged() Public Sub UpdateTotal() Handles Me.ItemsChanged Dim subTotal As Decimal = 0D For Each item As Items In SelectedItems subTotal += Prices.GetPrice(item) Next Dim TaxTotal As Decimal = subTotal * Prices.Tax_Rate Dim total As Decimal = subTotal + TaxTotal Me.SubTotal_Label.Invoke(Sub() Me.SubTotal_Label.Text = subTotal.ToString("C2")) Me.Tax_Label.Invoke(Sub() Me.Tax_Label.Text = TaxTotal.ToString("C2")) Me.Total_Label.Invoke(Sub() Me.Total_Label.Text = total.ToString("C2")) End Sub Private Sub RadioButton_CheckedChanged(sender As Object, e As EventArgs) Handles Cappuccino_RadioButton.CheckedChanged, Chocolate_RadioButton.CheckedChanged, Filled_RadioButton.CheckedChanged, Glazed_RadioButton.CheckedChanged, Regular_RadioButton.CheckedChanged, Sugar_RadioButton.CheckedChanged Dim senderRB As RadioButton = DirectCast(sender, RadioButton) Dim selectedItem As String = (From item As String In GetType(Items).GetEnumNames Where senderRB.Name.Contains(item) Select item).FirstOrDefault If selectedItem <> String.Empty Then Dim Item As Items = DirectCast([Enum].Parse(GetType(Items), selectedItem), Items) If senderRB.Checked Then Me.SelectedItems.Add(Item) RaiseEvent ItemsChanged() Else If Me.SelectedItems.Contains(Item) Then Me.SelectedItems.Remove(Item) RaiseEvent ItemsChanged() End If End If End If End Sub Private Sub DoughnutsAndCoffee_Shown(sender As Object, e As EventArgs) Handles Me.Shown RaiseEvent ItemsChanged() End Sub End Class Public Structure Prices Public Const Tax_Rate As Decimal = 0.03D Public Const Glazed As Decimal = 0.65D Public Const Sugar As Decimal = 0.65D Public Const Chocolate As Decimal = 0.85D Public Const Filled As Decimal = 1D Public Const Regular As Decimal = 1D Public Const Cappuccino As Decimal = 2.5D Public Shared Function GetPrice(item As Items) As Decimal Dim itemStr As String = [Enum].GetName(GetType(Items), item) Return GetType(Prices).GetField(itemStr).GetValue(Nothing) End Function End Structure Public Enum Items Glazed Sugar Chocolate Filled Regular Cappuccino End Enum </code></pre> <p>Designer File:</p> <pre><code><Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class DoughnutsAndCoffee Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Glazed_RadioButton = New System.Windows.Forms.RadioButton() Me.Sugar_RadioButton = New System.Windows.Forms.RadioButton() Me.Chocolate_RadioButton = New System.Windows.Forms.RadioButton() Me.Filled_RadioButton = New System.Windows.Forms.RadioButton() Me.Regular_RadioButton = New System.Windows.Forms.RadioButton() Me.Cappuccino_RadioButton = New System.Windows.Forms.RadioButton() Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel() Me.Total_Label = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.Tax_Label = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.SubTotal_Label = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label() Me.FlowLayoutPanel2 = New System.Windows.Forms.FlowLayoutPanel() Me.FlowLayoutPanel1 = New System.Windows.Forms.FlowLayoutPanel() Me.Coffee_GroupBox = New System.Windows.Forms.GroupBox() Me.Doughnuts_GroupBox = New System.Windows.Forms.GroupBox() Me.TableLayoutPanel1.SuspendLayout() Me.FlowLayoutPanel2.SuspendLayout() Me.FlowLayoutPanel1.SuspendLayout() Me.Coffee_GroupBox.SuspendLayout() Me.Doughnuts_GroupBox.SuspendLayout() Me.SuspendLayout() ' 'Glazed_RadioButton ' Me.Glazed_RadioButton.AutoSize = True Me.Glazed_RadioButton.Location = New System.Drawing.Point(3, 3) Me.Glazed_RadioButton.Name = "Glazed_RadioButton" Me.Glazed_RadioButton.Size = New System.Drawing.Size(58, 17) Me.Glazed_RadioButton.TabIndex = 9 Me.Glazed_RadioButton.Text = "Glazed" Me.Glazed_RadioButton.UseVisualStyleBackColor = True ' 'Sugar_RadioButton ' Me.Sugar_RadioButton.AutoSize = True Me.Sugar_RadioButton.Location = New System.Drawing.Point(3, 26) Me.Sugar_RadioButton.Name = "Sugar_RadioButton" Me.Sugar_RadioButton.Size = New System.Drawing.Size(53, 17) Me.Sugar_RadioButton.TabIndex = 10 Me.Sugar_RadioButton.Text = "Sugar" Me.Sugar_RadioButton.UseVisualStyleBackColor = True ' 'Chocolate_RadioButton ' Me.Chocolate_RadioButton.AutoSize = True Me.Chocolate_RadioButton.Location = New System.Drawing.Point(3, 49) Me.Chocolate_RadioButton.Name = "Chocolate_RadioButton" Me.Chocolate_RadioButton.Size = New System.Drawing.Size(73, 17) Me.Chocolate_RadioButton.TabIndex = 11 Me.Chocolate_RadioButton.Text = "Chocolate" Me.Chocolate_RadioButton.UseVisualStyleBackColor = True ' 'Filled_RadioButton ' Me.Filled_RadioButton.AutoSize = True Me.Filled_RadioButton.Location = New System.Drawing.Point(3, 72) Me.Filled_RadioButton.Name = "Filled_RadioButton" Me.Filled_RadioButton.Size = New System.Drawing.Size(49, 17) Me.Filled_RadioButton.TabIndex = 12 Me.Filled_RadioButton.Text = "Filled" Me.Filled_RadioButton.UseVisualStyleBackColor = True ' 'Regular_RadioButton ' Me.Regular_RadioButton.AutoSize = True Me.Regular_RadioButton.Location = New System.Drawing.Point(3, 3) Me.Regular_RadioButton.Name = "Regular_RadioButton" Me.Regular_RadioButton.Size = New System.Drawing.Size(62, 17) Me.Regular_RadioButton.TabIndex = 13 Me.Regular_RadioButton.Text = "Regular" Me.Regular_RadioButton.UseVisualStyleBackColor = True ' 'Cappuccino_RadioButton ' Me.Cappuccino_RadioButton.AutoSize = True Me.Cappuccino_RadioButton.Location = New System.Drawing.Point(3, 26) Me.Cappuccino_RadioButton.Name = "Cappuccino_RadioButton" Me.Cappuccino_RadioButton.Size = New System.Drawing.Size(82, 17) Me.Cappuccino_RadioButton.TabIndex = 14 Me.Cappuccino_RadioButton.Text = "Cappuccino" Me.Cappuccino_RadioButton.UseVisualStyleBackColor = True ' 'TableLayoutPanel1 ' Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.TableLayoutPanel1.AutoSize = True Me.TableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.TableLayoutPanel1.ColumnCount = 2 Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!)) Me.TableLayoutPanel1.Controls.Add(Me.Total_Label, 1, 2) Me.TableLayoutPanel1.Controls.Add(Me.Label5, 0, 2) Me.TableLayoutPanel1.Controls.Add(Me.Tax_Label, 1, 1) Me.TableLayoutPanel1.Controls.Add(Me.Label3, 0, 1) Me.TableLayoutPanel1.Controls.Add(Me.SubTotal_Label, 1, 0) Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0) Me.TableLayoutPanel1.Location = New System.Drawing.Point(67, 133) Me.TableLayoutPanel1.Name = "TableLayoutPanel1" Me.TableLayoutPanel1.RowCount = 3 Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333!)) Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333!)) Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333!)) Me.TableLayoutPanel1.Size = New System.Drawing.Size(140, 57) Me.TableLayoutPanel1.TabIndex = 9 ' 'Total_Label ' Me.Total_Label.Anchor = System.Windows.Forms.AnchorStyles.Left Me.Total_Label.AutoSize = True Me.Total_Label.Location = New System.Drawing.Point(80, 41) Me.Total_Label.Margin = New System.Windows.Forms.Padding(10, 3, 10, 3) Me.Total_Label.Name = "Total_Label" Me.Total_Label.Size = New System.Drawing.Size(39, 13) Me.Total_Label.TabIndex = 5 Me.Total_Label.Text = "Label6" ' 'Label5 ' Me.Label5.Anchor = System.Windows.Forms.AnchorStyles.Left Me.Label5.AutoSize = True Me.Label5.Location = New System.Drawing.Point(10, 41) Me.Label5.Margin = New System.Windows.Forms.Padding(10, 3, 10, 3) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(31, 13) Me.Label5.TabIndex = 4 Me.Label5.Text = "Total" ' 'Tax_Label ' Me.Tax_Label.Anchor = System.Windows.Forms.AnchorStyles.Left Me.Tax_Label.AutoSize = True Me.Tax_Label.Location = New System.Drawing.Point(80, 22) Me.Tax_Label.Margin = New System.Windows.Forms.Padding(10, 3, 10, 3) Me.Tax_Label.Name = "Tax_Label" Me.Tax_Label.Size = New System.Drawing.Size(39, 13) Me.Tax_Label.TabIndex = 3 Me.Tax_Label.Text = "Label4" ' 'Label3 ' Me.Label3.Anchor = System.Windows.Forms.AnchorStyles.Left Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(10, 22) Me.Label3.Margin = New System.Windows.Forms.Padding(10, 3, 10, 3) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(25, 13) Me.Label3.TabIndex = 2 Me.Label3.Text = "Tax" ' 'SubTotal_Label ' Me.SubTotal_Label.Anchor = System.Windows.Forms.AnchorStyles.Left Me.SubTotal_Label.AutoSize = True Me.SubTotal_Label.Location = New System.Drawing.Point(80, 3) Me.SubTotal_Label.Margin = New System.Windows.Forms.Padding(10, 3, 10, 3) Me.SubTotal_Label.Name = "SubTotal_Label" Me.SubTotal_Label.Size = New System.Drawing.Size(39, 13) Me.SubTotal_Label.TabIndex = 1 Me.SubTotal_Label.Text = "Label2" ' 'Label1 ' Me.Label1.Anchor = System.Windows.Forms.AnchorStyles.Left Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(10, 3) Me.Label1.Margin = New System.Windows.Forms.Padding(10, 3, 10, 3) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(50, 13) Me.Label1.TabIndex = 0 Me.Label1.Text = "SubTotal"%0 </code></pre> |
17,673,912 | 0 | <p>Use can u create service using broadcast reciever on device boot up</p> <pre><code> <receiver android:enabled="true" android:name=".YourReceiver" <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> </code></pre> <p>Permission:</p> <pre><code> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> </code></pre> |
17,021,394 | 0 | <p>You can use a span element inside parapragh elements so it would look like this:</p> <pre><code><p class="top_dr_profle"> <span class="my_doc_pic"> <img src="images/profile_img.png" /> </span> </p> </code></pre> |
10,230,062 | 0 | Hibernate flush method <p>I have the following piece of code that inserts or updates a bean in the database. I have a static function in the <code>HibernateUtil</code> that returns a singleton instance from the Hibernate session.</p> <pre><code>hibSession = HibernateUtil.currentSession(); hibSession.saveOrUpdate(bean); hibSession.flush(); </code></pre> <p>This is existing code, I am wondering if there is any reason that make the programmer use flush instead of simply committing and what flush does exactly.</p> |
10,317,784 | 0 | <p>Yes, you are doing this correct. Ignore the singleton comment, singletons are a good thing to avoid.</p> <p>Although I do want to make a suggestion:</p> <p>I'm going to assume BD is some kind of database. The power of OOP is the ability to subclass things, and replace objects without changing behaviour.</p> <p>So it <em>may</em> be better to just pass your $bd object in the constructor. Just something to keep in mind. This is called 'dependency injection' or 'inversion of control'.</p> |
31,329,158 | 1 | Manipulating validated data in Colander SchemaNode <p>I have a set of Colander SchemaNodes used with Pyramid/Cornice in an API. For some querystring args, a range is passed (ie <code>time=X-Y</code> means a time range from X to Y where X and Y are integers representing epochs). I currently validate this with a <code>RegEx()</code> validator to ensure an epoch or epoch range is passed in:</p> <pre><code>class TimeOrRange(SchemaNode): schema_type = String location = "querystring" description = 'Time (or range) in epochs: ssssssssss(-ssssssssss)' validator = Regex("^[0-9]{10}\-{0,1}[0-9]{0,10}$") </code></pre> <p>I then use this in a MappingSchema which is then tied to my Cornice view with <code>@view(schema=TimedThingGet)</code>:</p> <pre><code>class TimedThingGet(MappingSchema): time = TimeOrRange(missing=drop) </code></pre> <p>What I would like to do is update the return value in my <code>TimeOrRange</code> SchemaNode code so <code>time</code> in <code>TimedThingGet</code> is a tuple of time ranges. In other words, if <code>time=X-Y</code> is passed in to a <code>TimedThingGet</code> instance, then <code>time=(x, y)</code> is returned in the validated data. Similarly, if only <code>X</code> is passed in, then I want <code>Y</code> to be set to the epoch of <code>now()</code>. </p> <p>It looks like <code>set_value()</code> is the way to go, and here's where the problem get's some extra credit: </p> <ol> <li>Does <code>set_value</code> get called before or after validation?</li> <li>Does <code>set_value</code> have access to the validator such that a <code>RegEx</code> validator which creates regex groups could then be used to set my tuple: <code>time=(validated.match.group[1], validated.match.group[2])</code>?</li> </ol> |
32,384,750 | 0 | Function not printing after running <pre><code>*EDITED* </code></pre> <p>I fixed some issues but i'm still calling it wrong. Somehow when i don't declare with int the GetRand function more than once i get more error messages.</p> <p>What i want as a final result is to print the array i created and also print the maximum and average of the values of it (only counting every number > -1).</p> <p>I'm calling the maxavg() function wrong and i'm getting an error message "Error] expected identifier or '(' before '{' token" at the beginning of maxavg which i haven't been able to fix.</p> <pre><code>#include <stdio.h> #include <stdlib.h> #include <time.h> #include <limits.h> int GetRand(int min, int max); int maxavg(); int main () { int a[21][21], i , j, average, maximum; for (i = 0; i < 21; i++) { for ( j = 0; j < 21; j++) { a[i][j] = GetRand(0, 100); printf("%3d" , a[i][j]); } a[2][15] = -1; a[10][6] = -1; a[13][5] = -1; a[15][17] = -1; a[17][17] = -1; a[19][6] = -1; printf("\n"); } average = maxavg(); maximum = maxavg(); printf("average = %d \n maximum = %d", average, maximum); return 0; } // random seed int GetRand(int min, int max); int get () { int i, r; for (i = 0; i < 21; i++) { r = GetRand(0, 100); printf("Your number is %d \n", r); } return(0); } int GetRand(int min, int max) { static int Init = 0; int rc; if (Init == 0) { srand(time(NULL)); Init = 1; } rc = (rand() % (max - min +1) +min); return (rc); } // max and average int maxavg(); { int max=INT_MIN, sum=0, count=0, avg, n, m, current; current = a[i][j]; avg = sum/count; for(n = 0; n < 21; n++){ for(m =0; m < 21; m++){ if(current > -1){ sum = sum + current; count = count + 1; if(current > max){ max = current; } } } } return(0); } </code></pre> |
18,460,919 | 0 | SQL Order By not working properly <p>I have a table like this</p> <pre><code> CREATE TABLE [dbo].[tbl_LandRigs]( [ID] [int] IDENTITY(700000,1) NOT NULL, [Company] [nvarchar](500) NULL, [Rig] [nvarchar](500) NULL, [RigType] [nvarchar](200) NULL, [DrawWorks] [nvarchar](500) NULL, [TopDrive] [nvarchar](200) NULL, [RotaryTable] [nvarchar](500) NULL, [MudPump] [nvarchar](500) NULL, [MaxDD] [nvarchar](50) NULL, [Operator] [nvarchar](500) NULL, [Country] [nvarchar](200) NULL, [Location] [nvarchar](500) NULL, [OPStatus] [nvarchar](200) NULL, [CreatedDate] [datetime] NULL, [CreatedByID] [int] NULL, [CreatedByName] [nvarchar](50) NULL, CONSTRAINT [PK_tbl_LandRigs] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] </code></pre> <p>And I am trying to get data from MaxDD column in Descending order</p> <pre><code>SELECT distinct "MaxDD" FROM [tbl_LandRigs] ORDER BY "MaxDD" Desc </code></pre> <p>But this returns data in following order <img src="https://i.stack.imgur.com/J2mSM.png" alt="enter image description here"> According to my calculation 4000 must be the first value followed by others.But this results astonished me.Can any one help me out in this?</p> |
20,713,604 | 0 | <p>First of all, for capabilities, if it's a fixed list of capabilities you're working with, you're probably better off with having a number of booleans on the roles table, e.g. <code>can_create_projects</code>, <code>can_create_users</code>, etc., which encode the abilities of each role.</p> <p>Then your CanCan Ability class might have something like the following,</p> <pre><code>class Ability include CanCan::Ability def initialize(user) can(:create, Project) do |project| user.roles.any?(&:can_create_projects) end end end </code></pre> |
34,416,942 | 0 | <p>You can handle PreviewMouseDown Event of the ScrollViewer. In your xaml:</p> <pre><code><Grid> <!--Button is removed as it will be not used--> <ScrollViewer Background="{x:Null}" Margin="20" PreviewMouseDown="ScrollViewer_MouseDown"> <StackPanel Orientation="Horizontal" Background="{x:Null}"> <Rectangle Fill="Red" Width="100" Margin="50"></Rectangle> <Rectangle Fill="Red" Width="100" Margin="50"></Rectangle> <Rectangle Fill="Red" Width="100" Margin="50"></Rectangle> <Rectangle Fill="Red" Width="100" Margin="50"></Rectangle> </StackPanel> </ScrollViewer> </Grid> </code></pre> <p>As It is PreviewMouseDown (Tunneling) Event. So Wherever you click on scrollviewer, Event will be fired Whether it is Rectangle or ScrollViewer itself.</p> <p>In your code behind, You can handle it by e.Source Parameter. PreviewMouseDown Event in .cs file is:</p> <pre><code>private void ScrollViewer_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (e.Source.GetType() == typeof(ScrollViewer)) { //Code which you want to perform on that Button click will be here. } if (e.Source.GetType() == typeof(Rectangle)) { //Code which you want to perform on rectangle will be here. } } </code></pre> <p>I hope it will help you.</p> |
13,268,023 | 0 | <p>Apart from rectForRowAtIndexPath you need to consider the scrolling.</p> <p>Try this code:</p> <pre><code> // Get the cell rect and adjust it to consider scroll offset CGRect cellRect = [tableView rectForRowAtIndexPath:indexPath]; cellRect = CGRectOffset(cellRect, -tableView.contentOffset.x, -tableView.contentOffset.y); </code></pre> |
26,453,980 | 0 | <p>The generic method would be to use <code>left join</code> and aggregation:</p> <pre><code>select count(distinct d1.user) as NumEvent1, count(distinct d2.user) as NumEvent2, count(distinct d3.user) as NumEvent3 from data d1 left join data d2 on d2.user = d1.user and d2.time > d1.time and d2.event = 'event2' left join data d3 on d3.user = d2.user and d3.time > d2.time and d3.event = 'event3' where d1.event = 'event1' ; </code></pre> |
4,643,006 | 0 | <p>I have a method that adds model state to temp data. I then have a method in my base controller that checks temp data for any errors. If it has them, it adds them back to ModelState.</p> |
23,659,154 | 0 | <pre><code>def transcript_search(search_parameter,files): for line in files: if search_parameter in line: return line else: print('Invalid entry') files = open('/Users/labadmin/Desktop/example.gtf', 'r') gene_id = input("Enter the gene_id:") transcript_search(gene_id,files) </code></pre> <p>Don't use file. As that is a python keyword. You also need to pass in the file to the function.</p> <p>Also are you sure when it's invalid you want to print but not return anything? The return type would be <code>None</code>. Could be what you want so I didn't change it.</p> <p>To print invalid only once:</p> <pre><code>def transcript_search(search_parameter,files): for line in files: if search_parameter in line: return line #In this way invalid will only print after it has gone through all the lines and never returned. print('Invalid entry') </code></pre> <p>As for saving:</p> <pre><code>saved_lines = [] files = open('/Users/labadmin/Desktop/example.gtf', 'r') gene_id = input("Enter the gene_id:") #Append to list the saved entries. saved_lines.append(transcript_search(gene_id,files)) </code></pre> <p>After which you write all of the list to a line using <code>files.writelines(list)</code> or print them to screen or whatever you want.</p> <p>This adds all the lines with ur search_parameter to a list and returns the list</p> <pre><code>def transcript_search(search_parameter,files): toreturn = [] for line in files: if search_parameter in line: toreturn.append(line) if len(toreturn)>0: #Notice at how this returns an array of strings instead of one string. return toreturn print('Invalid entry') </code></pre> |
29,631,795 | 0 | TSQL: Prevent Nulls update over existing data <p>I have 2 tables:</p> <ol> <li><p>Orders (Table I update and want keep existing data, and prevent overwriting with nulls)</p></li> <li><p>WRK_Table (This table is identical to <em>Orders</em> but can not guarantee all columns will have data when running update)</p></li> </ol> <p>PK column 'Master_Ordernum' There are many columns in the tables, the WRK_Table will have the PK, but data in other columns can not be counted on.</p> <p>I want the WRK_Table to update Orders only with actual data and not Nulls. I was thinking along this line:</p> <pre><code>UPDATE [Orders] SET [Status] = CASE WHEN S.[Status] IS NOT NULL THEN S.[Status] END FROM [WRK_TABLE] S WHERE [Orders].[Master_Ordernum] = S.[Master_Ordernum] </code></pre> <p>The existing data in Orders is being updated with nulls</p> |
28,646,766 | 0 | <p>In my case what solved the problem was the folowing:</p> <pre><code>USE [master] GO CREATE DATABASE [AdventureWorks2008R2] ON ( FILENAME = 'C:\Program Files\Microsfot SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\AdventureWors2008R2_Data.mdf') FOR ATTACH_REBUILD_LOG </code></pre> |
2,323,639 | 0 | <p><strong>C++</strong></p> <p>This would work in C++ because the function signature for <code>get()</code> is probably this:</p> <pre><code>void get(char& a); // pass-by-reference </code></pre> <p>The <code>&</code> symbol after <code>char</code> denotes to the compiler than when you pass in a <code>char</code> value, it should pass in a <em>reference</em> to the <code>char</code> rather than making a copy of it.</p> <p>What this essentially means is that any changes made within <code>get()</code> will be reflected in the value of <code>a</code> outside the method.</p> <p>If the function signature for <code>get()</code> was this:</p> <pre><code>void get(char a); // pass-by-value </code></pre> <p>then <code>a</code> would be passed by <em>value</em>, which means a copy of <code>a</code> is made before being passed into the method as a parameter. Any changes to <code>a</code> would then only be local the method, and lost when the method returns.</p> <p><strong>C</strong></p> <p>The reason why this wouldn't work in C is because C only has <em>pass-by-value</em>. The only way to emulate <em>pass-by-reference</em> behaviour in C is to pass its pointer by value, and then de-reference the pointer value (thus accessing the same memory location) when modifying the value within the method:</p> <pre><code>void get(char* a) { *a = 'g'; } int main(int argc, char* argv[]) { char a = 'f'; get(&a); printf("%c\n", a); return 0; } </code></pre> <p>Running this program will output:</p> <pre><code>g </code></pre> |
11,146,235 | 0 | <p>Well, your migration obviously did not complete successfully, based on the traceback. So I would focus on figuring out why it failed, rather than working around things like the broken RAMCache which are likely a result of the migration not having run.</p> <p>The traceback indicates that it broke while trying to <em>abort</em> the transaction...so you'll probably need to do some debugging to determine what caused it to <em>try</em> to abort, since that's not indicated in the logs you pasted.</p> |
38,087,735 | 0 | <p>You have to define <code>obj</code>.<br> Write something like:<br> <code>var obj = document.getElementById(pCent);</code><br> At the top of <code>load_Sim</code></p> |
11,562,165 | 0 | MYSQL PHP - get float LIKE $float <p>I want to get rows with floats like my <code>$float</code>.</p> <p>I used this code:</p> <pre><code>$float = $_GET['float']; $requst = mysql_fetch_array(mysql_query("SELECT * FROM floats WHERE float LIKE'$float.%%%%%%%'")); </code></pre> <p>then I echoed all the rows with while:</p> <pre><code>while ($r = $request) { echo $a['float']; } </code></pre> <p>but the page doesn't show anything. (YES, I typed in the address bar <code>?float=34</code> and there are floats like <code>34.******</code> in the table.)</p> <p>What is the problem?</p> <p>(PHP version 5.2, MYSQL version 5.0)</p> |
23,583,912 | 0 | Android facebook sdk import error <p>i had download facebook skd import it in my eclipse add v4 jar file and change complier to 1.6 but yet it give me error in class FacebookAppLinkResolver </p> <p><code>import bolts.AppLink; import bolts.AppLinkResolver; import bolts.Continuation; import bolts.Task;</code></p> <p><img src="https://i.stack.imgur.com/RXIp4.png" alt="enter image description here"> above are not import</p> |
30,871,275 | 0 | stored procedure cannot loop an array of string <pre><code>$StupidArray = "Boys, are, not, smiling, at, all,"; if (!$db->query(" SET @msg = ''; SET @Stringarray = '\' $StupidArray '\'; " ) || !$db->query(" CALL StupidProcedure (@Stringarray, @msg)") ) { echo "CALL to StupidProcedure failed:".print_r($db->errorInfo()); } else { $res = $db->query("SELECT @msg as _p_out"); $row = $res->fetch(); print_r($row['_p_out']); } </code></pre> <p>I have this mysql stored procedure that should loop through an arbitrary array of strings.</p> <pre><code>CREATE PROCEDURE StupidProcedure (INOUT Stringarray VARCHAR(100), IN msg VARCHAR (100) ) BEGIN /*Table loop variable*/ DECLARE indx INT; DECLARE len INT; DECLARE valu INT; SET @indx = 0; SET @len = 0; WHILE LOCATE(',', @Stringarray , @indx + 1) > 0 DO SET @len = LOCATE(',', @Stringarray , @indx + 1) - @indx; SET @valu = SUBSTRING(@Stringarray , @indx, @len); SELECT CONCAT(@msg, @valu) INTO msg; /* For Debugging purpose*/ SET @indx = LOCATE(',', @Stringarray , @indx + @len) + 1; /*increment loop*/ END WHILE; END </code></pre> <p>Now, I needed to be sure that concatenated <code>@msg</code> has received all data in <code>@Stringarray</code> after the loop. Using php, I simply did this:</p> <pre><code>$StupidArray = "Boys, are, not, smiling, at, all,"; if (!$db->query(" SET @msg = ''; SET @Stringarray = '\' $StupidArray '\'; " )) { echo "CALL to StupidProcedure failed:".print_r($db->errorInfo()); } else { $res = $db->query("SELECT @msg as _p_out"); $row = $res->fetch(); print_r($row['_p_out']); } </code></pre> <p>What I got in return was <code>all</code>, the last is <code>$StupidArray</code>. What am I doing wrong? OR is it my loop that is failing?</p> |
2,288,353 | 0 | <p>What about this one:</p> <p><a href="http://rads.stackoverflow.com/amzn/click/0321166094" rel="nofollow noreferrer">The Rational Unified Process Made Easy: A Practitioner's Guide to the RUP</a></p> <p>Hope that helps</p> |
35,725,923 | 0 | Is there a disadvantage if I keep completed tasks in a job while using Azure Batch <p>I am planning to use Azure Batch Service. I will add several permanent jobs (in a permanent pool), and add new tasks to job now and then. Therefore number of completed (and incomplete) tasks will be increased over time. Should I delete the completed tasks? Does keeping these cause any problems?</p> |
12,393,457 | 0 | How can I check if dll is .net library "The module was expected to contain an assembly manifest." <p>How can I verify if dll was wrote in .net? I'm using code as below:</p> <pre><code>Assembly assembly = null; try { foreach (string fileName in Directory.GetFiles(Environment.CurrentDirectory.ToString(), "*.dll", SearchOption.TopDirectoryOnly)) { try { assembly = Assembly.LoadFrom(fileName); Console.WriteLine(fileName); } catch (Exception ex) { ... } finally { ... } } } catch (ReflectionTypeLoadException ex) { .. } </code></pre> <p>When I want to load <code>assembly = Assembly.LoadFrom(fileName)</code> non-.net dll, an exception will appear:</p> <blockquote> <p>Could not load file or assembly 'file:///...' or one of its dependencies. The module was expected to contain an assembly manifest.</p> </blockquote> <p>I want to use verify in if-else clause. Can you help me? </p> |
15,946,762 | 0 | <p>From C++03, 14.2.4</p> <blockquote> <p>When the name of a member template specialization appears after <code>.</code> or <code>-></code> in a <em>postfix-expression</em>, or after <em>nested-name-specifier</em> in a <em>qualified-id</em>, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template.</p> </blockquote> <p>In your example, <code>rcss::conf::Builder</code> does not depend explicitly on a template-parameter, which makes the <code>template</code> keyword useless (VC allows it).</p> |
2,848,783 | 0 | <p>In the first edition of "XP explained", there was twelve practices. </p> <p>In the second edition, the practices have been reorganized: some have been renamed or merged, some have been removed (Metaphor), and there now are: thirteen primary and eleven corollary practices.</p> <p>Under the "First Edition Practices" topic in the page you mentioned, one can find the original list of twelve practices and how they appear in the update.</p> <p>While reading, you'll certainly will people differentiating XP and XP2e (XP second edition).</p> <p>Likely, there was four principles in the first edition and a fifth one (Respect) was introduced with the second edition. </p> |
15,219,799 | 0 | Saved State progressbar status and button click event in android listview <p>i have <code>listview</code>.in row item <code>progressbar</code> ,2 button and one image view when i click download button then downloading process start but when i scroll up down then application crash and how to save state in <code>listview</code> row item when i scroll up down?my code below:::</p> <pre><code>public class TestHopeDownload extends Activity { private ListView lstView; private ImageAdapter imageAdapter; private Handler handler = new Handler(); ArrayList<Url_Dto> list = new ArrayList<Url_Dto>(); File download; public static final int DIALOG_DOWNLOAD_THUMBNAIL_PROGRESS = 0; String strDownloaDuRL; ArrayList<HashMap<String, Object>> MyArrList = new ArrayList<HashMap<String, Object>>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test_hope_download); new LoadContentFromServer().execute(); } public void ShowThumbnailData() { // ListView and imageAdapter lstView = (ListView) findViewById(R.id.listView1); lstView.setClipToPadding(false); list = DBAdpter.getUrl_Detail(); imageAdapter = new ImageAdapter(getApplicationContext()); lstView.setAdapter(imageAdapter); } public void startDownload(final int position) { Runnable runnable = new Runnable() { int Status = 0; public void run() { // String urlDownload = list.get(position).url_video; String urlDownload = MyArrList.get(position) .get("VideoPathThum").toString(); Log.v("log_tag", "urlDownload ::: " + urlDownload); int count = 0; try { URL url = new URL(urlDownload); URLConnection conexion = url.openConnection(); conexion.connect(); int lenghtOfFile = conexion.getContentLength(); Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile); InputStream input = new BufferedInputStream( url.openStream()); // Get File Name from URL String fileName = urlDownload.substring( urlDownload.lastIndexOf('/') + 1, urlDownload.length()); download = new File( Environment.getExternalStorageDirectory() + "/download/"); if (!download.exists()) { download.mkdir(); } strDownloaDuRL = download + "/" + fileName; OutputStream output = new FileOutputStream(strDownloaDuRL); byte data[] = new byte[1024]; long total = 0; while ((count = input.read(data)) != -1) { total += count; Status = (int) ((total * 100) / lenghtOfFile); output.write(data, 0, count); // Update ProgressBar handler.post(new Runnable() { public void run() { updateStatus(position, Status); } }); } output.flush(); output.close(); input.close(); } catch (Exception e) { } } }; new Thread(runnable).start(); } private void updateStatus(int index, int Status) { View v = lstView.getChildAt(index - lstView.getFirstVisiblePosition()); // Update ProgressBar ProgressBar progress = (ProgressBar) v.findViewById(R.id.progressBar); progress.setProgress(Status); // Update Text to ColStatus TextView txtStatus = (TextView) v.findViewById(R.id.ColStatus); txtStatus.setPadding(10, 0, 0, 0); txtStatus.setText("Load : " + String.valueOf(Status) + "%"); // Enabled Button View if (Status >= 100) { Button btnView = (Button) v.findViewById(R.id.btnView); btnView.setTextColor(Color.RED); btnView.setEnabled(true); } } class LoadContentFromServer extends AsyncTask<Object, Integer, Object> { protected void onPreExecute() { super.onPreExecute(); } @Override protected Object doInBackground(Object... params) { HashMap<String, Object> map; String url = "***** url******"; String result = ""; InputStream is = null; ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); // http post try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch (Exception e) { Log.e("log_tag", "Error in http connection " + e.toString()); } try { BufferedReader reader = new BufferedReader( new InputStreamReader(is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } try { JSONObject json_obj = new JSONObject(result); JSONArray j_Arr_fn = json_obj.getJSONArray("children"); for (int i = 0; i < j_Arr_fn.length(); i++) { JSONObject json_objs = j_Arr_fn.getJSONObject(i); Url_Dto proDto = new Url_Dto(); proDto.url_video = json_objs.getString("videoUrl"); map = new HashMap<String, Object>(); map.put("VideoPathThum", proDto.url_video); MyArrList.add(map); } } catch (JSONException e) { Log.e("log_tag", "Error parsing data " + e.toString()); } return null; } @Override protected void onPostExecute(Object result) { ShowThumbnailData(); } } class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context context) { mContext = context; } public int getCount() { return MyArrList.size(); } public Object getItem(int position) { return MyArrList.get(position); } public long getItemId(int position) { return position; } public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = inflater.inflate(R.layout.activity_column, null); } // ColImage ImageView imageView = (ImageView) convertView .findViewById(R.id.ColImgPath); imageView.getLayoutParams().height = 110; imageView.getLayoutParams().width = 110; imageView.setPadding(10, 10, 10, 10); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); try { imageView.setImageResource(list.get(position).images[position]); } catch (Exception e) { // When Error imageView.setImageResource(android.R.drawable.ic_menu_report_image); } // ColStatus TextView txtStatus = (TextView) convertView .findViewById(R.id.ColStatus); txtStatus.setPadding(10, 0, 0, 0); txtStatus.setText("..."); // btnDownload final Button btnDownload = (Button) convertView .findViewById(R.id.btnDownload); btnDownload.setTextColor(Color.RED); btnDownload.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Download btnDownload.setEnabled(false); btnDownload.setTextColor(Color.GRAY); startDownload(position); pbs.setDl(1); } }); // btnView Button btnView = (Button) convertView.findViewById(R.id.btnView); btnView.setEnabled(false); btnView.setTextColor(Color.GRAY); btnView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ViewVideoDelete(position); } }); // progressBar ProgressBar progress = (ProgressBar) convertView .findViewById(R.id.progressBar); progress.setPadding(10, 0, 0, 0); return convertView; } } public void ViewVideoDelete(int position) { String urlDownload = MyArrList.get(position).get("VideoPathThum") .toString(); String fileName = urlDownload.substring( urlDownload.lastIndexOf('/') + 1, urlDownload.length()); download = new File(Environment.getExternalStorageDirectory() + "/download/"); String strPath = download + "/" + fileName; Log.v("log_tag", "fileNameDElete :: " + strPath); File delete = new File(strPath); delete.delete(); } } </code></pre> <p>then i click download button then i scroll up down then application crash .my error in below::</p> <pre><code>03-05 14:39:15.301: E/AndroidRuntime(4481): FATAL EXCEPTION: main 03-05 14:39:15.301: E/AndroidRuntime(4481): java.lang.NullPointerException 03-05 14:39:15.301: E/AndroidRuntime(4481): at com.example.testhopedownload.TestHopeDownload.updateStatus(TestHopeDownload.java:142) 03-05 14:39:15.301: E/AndroidRuntime(4481): at com.example.testhopedownload.TestHopeDownload.access$1(TestHopeDownload.java:137) 03-05 14:39:15.301: E/AndroidRuntime(4481): at com.example.testhopedownload.TestHopeDownload$1$1.run(TestHopeDownload.java:119) 03-05 14:39:15.301: E/AndroidRuntime(4481): at android.os.Handler.handleCallback(Handler.java:587) 03-05 14:39:15.301: E/AndroidRuntime(4481): at android.os.Handler.dispatchMessage(Handler.java:92) 03-05 14:39:15.301: E/AndroidRuntime(4481): at android.os.Looper.loop(Looper.java:130) 03-05 14:39:15.301: E/AndroidRuntime(4481): at android.app.ActivityThread.main(ActivityThread.java:3683) 03-05 14:39:15.301: E/AndroidRuntime(4481): at java.lang.reflect.Method.invokeNative(Native Method) 03-05 14:39:15.301: E/AndroidRuntime(4481): at java.lang.reflect.Method.invoke(Method.java:507) 03-05 14:39:15.301: E/AndroidRuntime(4481): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 03-05 14:39:15.301: E/AndroidRuntime(4481): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 03-05 14:39:15.301: E/AndroidRuntime(4481): at dalvik.system.NativeStart.main(Native Method) </code></pre> |
39,168,946 | 0 | How to improve performance on static HTML, UIWebView content <p>I have <code>UIWebViews</code> as cells for my <code>UITableView</code>. However, it lags while scrolling due to nature of <code>UIWebView</code> being really slow. However, I only use static HTML string as content of <code>UIWebView</code>, so it shouldn't have difference with an Image once its loaded, but thats not the case.</p> <p>Is there any way to improve <code>UIWebView</code> performance when using a static HTML string as content?</p> |
38,810,345 | 0 | <p>Keep in mind that the format of neo4j query output is designed for rows with columns, not your desired output format, so this makes things a little tricky.</p> <p>I would highly recommend just outputting your food items on each row, with boolean columns for membership in each distinct simple trait, then in your application code, insert the food objects into sets for each trait. Then using application logic you can calculate all possible combinations of traits you need, and perform set intersection to generate them.</p> <p>This would make the neo4j query very easy:</p> <pre><code>MATCH (f:Food) WITH f RETURN f.name, EXISTS((f)-[:IS]->(:Trait{name:'tangy'})) AS tangy, EXISTS((f)-[:IS]->(:Trait{name:'sweet'})) AS sweet, EXISTS((f)-[:IS]->(:Trait{name:'sour'})) AS sour, EXISTS((f)-[:IS]->(:Trait{name:'spicy'})) AS spicy </code></pre> <p>That said, if you're determined to do the entire thing with a neo4j query, it's going to be messy, since you'll need to track and generate all the combinations you need yourself. For intersection operations, you'll want to install the <a href="https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_included_procedures_overview" rel="nofollow">APOC procedures library</a>.</p> <p>Seems to me that the best start is to create sets of food nodes according to each individual trait.</p> <pre><code>MATCH (f:Food)-[:IS]->(:Trait{name:'spicy'}) WITH COLLECT(f) AS spicyFood MATCH (f:Food)-[:IS]->(:Trait{name:'sour'}) WITH COLLECT(f) AS sourFood, spicyFood MATCH (f:Food)-[:IS]->(:Trait{name:'sweet'}) WITH COLLECT(f) AS sweetFood, sourFood, spicyFood MATCH (f:Food)-[:IS]->(:Trait{name:'tangy'}) WITH COLLECT(f) AS tangyFood, sweetFood, sourFood, spicyFood </code></pre> <p>Now that you have these, you can do your intersections with every combination you're interested in.</p> <pre><code>CALL apoc.coll.intersection(tangyFood, sweetFood) YIELD value AS tangySweetFood CALL apoc.coll.intersection(tangyFood, sourFood) YIELD value AS tangySourFood CALL apoc.coll.intersection(tangyFood, spicyFood) YIELD value AS tangySpicyFood CALL apoc.coll.intersection(tangySweetFood, sourFood) YIELD value AS tangySweetSourFood CALL apoc.coll.intersection(tangySweetFood, spicyFood) YIELD value AS tangySweetSpicyFood CALL apoc.coll.intersection(tangySourFood, spicyFood) YIELD value AS tangySourSpicyFood CALL apoc.coll.intersection(tangySweetSourFood, spicyFood) YIELD value AS tangySweetSourSpicyFood CALL apoc.coll.intersection(sweetFood, sourFood) YIELD value AS sweetSourFood CALL apoc.coll.intersection(sweetFood, spicyFood) YIELD value AS sweetSpicyFood CALL apoc.coll.intersection(sweetSourFood, spicyFood) YIELD value AS sweetSourSpicyFood CALL apoc.coll.intersection(sourFood, spicyFood) YIELD value AS sourSpicyFood RETURN tangyFood, sweetFood, sourFood, spicyFood, tangySweetFood, tangySourFood, tangySpicyFood, tangySweetSourFood, tangySweetSpicyFood, tangySourSpicyFood, tangySweetSourSpicyFood, sweetSourFood, sweetSpicyFood, sweetSourSpicyFood, sourSpicyFood </code></pre> |
9,126,857 | 0 | <p>I corrected this by doing what Roman said, with the code:</p> <pre><code> Camera.Parameters parameters = camera.getParameters(); List<Camera.Size> sizes = parameters.getSupportedPreviewSizes(); Camera.Size cs = sizes.get(0); parameters.setPreviewSize(cs.width, cs.height); camera.setParameters(parameters); </code></pre> |
30,371,033 | 0 | <p>Store the tile in the array and print it - </p> <pre><code><?php $video_array = array( array('url' => 'http://www.youtube.com/embed/rMNNDINCFHg', 'title' => 'ABC'), array('url' => 'http://www.youtube.com/embed/bDF6DVzKFFg', 'title' => 'DSF'), array('url' => 'http://www.youtube.com/embed/bDF6DVzKFFg', 'title' => 'RYUY') ); shuffle($video_array); $video = $video_array[0]; ?> <iframe width='1006' height='421' src='<?php echo $video['url']; ?>' title='<?php echo $video['title']; ?>' frameborder='0' allowfullscreen></iframe> </code></pre> |
4,537,217 | 0 | <p>Rather than having the user refresh the entire page, you might consider using <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="nofollow">AJAX</a> and provide your own refresh button. It likely will make refreshing quicker as well because the entire page does not have to be reloaded.</p> |
25,475,590 | 0 | <p>The tricky bit is getting both related records at one time:</p> <pre><code>delete a1 from a a1 where ( a1.pub_cde = 'RTF' and exists ( select 'x' from a a2 where a2.ctm_nbr = a1.ctm_nbr and a2.pub_cde = 'CTR' and a2.itg = 2 * a1.itg ) ) or ( a1.pub_cde = 'CTR' and exists ( select 'x' from a a2 where a2.ctm_nbr = a1.ctm_nbr and a2.pub_cde = 'RTF' and a2.itg * 2 = a1.itg ) ); </code></pre> <p><a href="http://sqlfiddle.com/#!3/10f7e/3" rel="nofollow">Example SQL Fiddle</a></p> |
8,148,629 | 0 | Intent filter to download attachment from gmail apps on Android <p>I have android application with intent filter (ACTION_VIEW) to open file and import it into my application. I wish to download file attachment from gmail app into my application. Some of file type (i.e. jpg, png, txt) are saved correctly, but some are not (i.e doc, xls, ppt). I believe I have the correct intent filter for my activity since it works from other app (i.e. dropbox), but not gmail app. Is there any solution for this ? </p> |
12,012,058 | 0 | <p>Yes, the question sets used for both exams are identical and the Sierra/Bates book is good preparation material. In order to prepare even better, I would advise to take some mock tests first. There is a large number of free ones on the net.</p> <p>EDIT: as to the naming ambiguities - the certificate was issued by Sun Microsystems and called <a href="http://en.wikipedia.org/wiki/SCJP#Sun_Certified_Java_Programmer_.28SCJP.29">SCJP - <strong>Sun Certified Java Programmer</strong></a>. After Oracle acquired Sun in early 2010 (the agreement has been signed in 2009), the certificate has been officially renamed to <strong>Oracle Certified Professional Java SE Programmer</strong> or OCPJP. Many people continue to call it SCJP though.</p> |
5,698,592 | 0 | <p>You're probably getting that error because you are calling the theme file directly </p> <p>OR</p> <p>because you aren't incuding the header and footer of the page.</p> <p>Easy Solve:</p> <p>Make sure the page loads as wanted. If you dont want to include the header and all that junk, you can load a fragment with jQuery doing something like this:</p> <pre><code> .load('wp-content/themes/theme/reloadhomeposts.php #postWrapper', function() { $(this).removeClass('loading') }); </code></pre> |
23,793,046 | 0 | Pixelate images when hovering over parent div using javascript <p>Searching around for ways to do this, I found a couple good explanations out there, and ended up combining them. I had everything working fine when I was just doing the hover effect when mousing over the image itself, but when trying to make it work when hovering over the "profile" div seems to have caused some problems. Currently, it will sometimes also be pixelated when not over the div, so it remains somewhere between the mouseover and mouseout states.</p> <h2>HTML</h2> <p>In the HTML, I'm creating a filterable directory of people using isotope that contains a bunch of blocks like this:</p> <pre><code><div class="item profile p-1 undergrad research"> <div class="profile-image"> <img src="img.jpg"> </div> <div class="profile-text"> <h1>Name</h1> <h2>Position</h2> <p> Email:email@gmail.com<br> Phone: 123.345.6567<br> Office: 2818 </p> </div> </div> </code></pre> <h2>Javascript</h2> <p>I'm using javascript to handle the pixelation stuff right now, but to be honest I'm a lot more familiar and comfortable with Jquery, so this has been a struggle and learning experience. Below is the whole code, but I'll explain what I changed that started my issues.</p> <p>Originally, "items" in setup was taking <em>.profile-image</em> objects, and I changed that to <em>.profile</em> objects so I could use the ".profile" div as the object with the mouseover event listener. At this point I introduced <em>"block"</em>, which i switched the event listeners to from <em>"element"</em>. </p> <pre><code>// Most of the structure taken from Noel Delgado // @pixelia_me => http://codepen.io/noeldelgado/pen/FmEBh // The actual pixelation taken from Ken Fyrstenberg Nilsen // http://jsfiddle.net/AbdiasSoftware/QznT7/ // http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ /* ** ======================================================================= ** Animation ** ======================================================================= */ var lastTime = 0; var vendors = ['webkit', 'moz']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function(){callback(currTime + timeToCall);}, timeToCall); lastTime = currTime + timeToCall; return id; }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; /* ** ======================================================================= ** Pixelation ** ======================================================================= */ /*============================="Setup"===============================*/ var PIXELATION = 36,//The value when hovering. Lower numbers are more pixelated, while 100 is not at all speed = 4,//How quickly it animates. play = false;//Is the animation "playing"? var items = document.querySelectorAll('.profile'),//The parent of everything. _objs = [];//Array that will be filled with our images /*===================Images Object "Class Constructor"=====================*/ var Images = function( block, element, image, canvas, context ) { this.block = block; this.element = element; this.image = image; this.canvas = canvas; this.context = context; this.pixelation = 100; } //Called by Array.prototype.slice Images.prototype.bindLoad = function() { var obj = this; this.image.onload = function() { obj.reportLoad.call(obj); }; if ( this.image.complete ) { this.image.onload(); } } //Called by Images.prototype.bindLoad Images.prototype.reportLoad = function() { var obj = this; size = (play ? v : 100) * 0.01, w = this.width * size; h = this.height * size; this.imageWidth = this.canvas.width = this.image.width; this.imageHeight = this.canvas.height = this.image.height; this.context.drawImage(this.image, 0, 0, w, h); this.context.drawImage(this.image, 0, 0, w, h, 0, 0, this.element.width, this.element.height); //Turn off image smoothing so we get the pixelated effect this.context.mozImageSmoothingEnabled = false; this.context.webkitImageSmoothingEnabled = false; this.context.imageSmoothingEnabled = false; this.block.addEventListener('mouseover', function() { obj.mouseOver(); }, false); this.block.addEventListener('mouseout', function() { obj.mouseOut(); }, false); } /*=====================Images Object MouseOver Function======================*/ Images.prototype.mouseOver = function() { var obj = this, play = true; cancelAnimationFrame( obj.idUndraw ); var draw = function() { if ( obj.pixelation <= PIXELATION ) { play = false; cancelAnimationFrame( obj.idDraw ); obj.pixelation = PIXELATION; } else { obj.pixelate( obj.imageWidth, obj.imageHeight, 0, 0 ); obj.idDraw = requestAnimationFrame( draw, obj.context ); } }; obj.idDraw = requestAnimationFrame( draw, obj.context ); } /*====================Images Object MouseOut Function==================*/ Images.prototype.mouseOut = function() { var obj = this, play = true; cancelAnimationFrame( obj.idDraw ); var undraw = function() { if ( obj.pixelation > 98 ) { //New Code play = false;//New Code cancelAnimationFrame( obj.idUndraw ); obj.pixelation = 98; } else { obj.depixelate( obj.imageWidth, obj.imageHeight, 0, 0 ); obj.idUndraw = requestAnimationFrame( undraw, obj.context ); } }; obj.idUndraw = requestAnimationFrame( undraw, obj.context ); } /*=================Images Object Pixelation Calculation===================*/ //Called by Images.prototype.pixelate & depixelate Images.prototype.setPixels = function() { size = this.pixelation * 0.01; w = this.image.width * size; h = this.image.height * size; this.context.drawImage(this.image, 0, 0, w, h); this.context.drawImage(this.canvas, 0, 0, w, h, 0, 0, this.canvas.width, this.canvas.height); } /*====================Images Object Pixelation Methods=====================*/ //Called by Images.prototype.mouseOver Images.prototype.pixelate = function() { this.pixelation -= speed; this.setPixels(); } //Called by Images.prototype.mouseOut (Line 113) Images.prototype.depixelate = function() { this.pixelation += speed; this.setPixels(); } /*=============================Create Array of images=====================*/ //It all seems to start here. Don't really know how this gets called //though unfortunately... Array.prototype.slice.call(items, 0).forEach(function(el, i) { var block = el, element = el.querySelector('.profile-image'), image = element.querySelector('img'), canvas = document.createElement('canvas'), context = canvas.getContext('2d'); element.appendChild( canvas ); _objs.push( new Images( block, element, image, canvas, context ) ); _objs[i].bindLoad(); }); </code></pre> |
14,568,430 | 0 | <p>Caching large objects in NoSQL stores is generally not a good idea, because it is expensive in term of memory and network bandwidth. I don't think NoSQL solutions shine when it comes to storing large objects. Redis, memcached, and most other key/value stores are clearly not designed for this.</p> <p>If you want to store large objects in NoSQL products, you need to cut them in small pieces, and store the pieces as independent objects. This is the approach retained by 10gen for gridfs (which is part of the standard MongoDB distribution):</p> <p>See <a href="http://docs.mongodb.org/manual/applications/gridfs/" rel="nofollow">http://docs.mongodb.org/manual/applications/gridfs/</a></p> <p>To store large objects, I would rather look at distributed filesystems such as:</p> <ul> <li><a href="http://ceph.com/" rel="nofollow">Ceph</a></li> <li><a href="http://www.gluster.org/" rel="nofollow">GlusterFS</a></li> <li><a href="http://doc.mapr.com/display/MapR/Architecture+Guide" rel="nofollow">MapR-FS</a></li> </ul> <p>These systems are scalable, highly available, and provide both file and object interfaces (you probably need an object interface). You can also refer to the following SO question to choose a distributed filesystem.</p> <p><a href="http://stackoverflow.com/questions/269179/best-distributed-filesystem-for-commodity-linux-storage-farm">Best distributed filesystem for commodity linux storage farm</a> </p> <p>Up to you to implement a cache on top of these scalable storage solutions.</p> |
40,428,530 | 0 | <p>Sorry, no built-in support for volumes. Feel free to raise an issue here: <a href="https://github.com/spring-cloud/spring-cloud-deployer-kubernetes/issues" rel="nofollow noreferrer">https://github.com/spring-cloud/spring-cloud-deployer-kubernetes/issues</a></p> |
14,252,678 | 0 | Backbone.js per attribute rendering (multiple small views vs multiple templates per view ) <p>I have a model and a view. The view displays attributes of a model and allows the user to manipulate these attributes. The problem is that when an attribute is modified it re-renders the whole view which causes a lot of problems for me.</p> <p><em>Example blur event on a text input saves the new input to an attribute and thus fires render. Which means that if the user clicked from that text input straight to a button on the same view that event will never fire as the first event that fires will be blur causing the whole view to re-render and thus losing the button click event.</em></p> <p>I have two ideas:</p> <ol> <li>Have a single view where every attribute is in a separate template. Then I bind to a particular attribute change event and in render I update only the html of the changed attribute. This seems like a hack, as there is a lot of work to force the view to update only the changed attribute. It will add a lot of unnecessary complexity to an already complex view.</li> <li>Create a master view which consists of views, where each of them represents a model's attribute. This will create a lot of views, with nearly no functionality. </li> </ol> <p>I seem to prefer the 2. option. What do you think? What are the best practices? Is there any better way to handle this?</p> |
7,863,384 | 0 | <p>It means just what it says. The value being passed to the <code>text</code> method is the result of the expression <code>350 - ta.va().length</code>. The variable <code>ta</code> has not been defined at the point this code is being run.</p> <p>A few things to note before my proposed solution.</p> <ol> <li>You are correct in responding to the keypress event to truncate the user input, but there is no need to use an interval to update the count - just update it in the event handler.</li> <li>Don't put the function passed to <code>setInterval</code> in quotes. This causes it to be run through <code>eval</code>, which is both slower and less secure.</li> <li>Save jQuery objects in variables outside of the event handler so the same objects can be used each time the handler is invoked. This uses less memory and should be a tiny bit faster.</li> </ol> <p>Here's how I would implement this:</p> <pre><code>$(function () { var ta = $(".txtclass"), counter = $("#counter span"); ta.keypress(function () { var taValue = ta.val(); if (taValue.length >= 350) { taValue = ta.val(taValue.slice(0, 350)).val(); } counter.text(taValue.length); }); }); </code></pre> |
21,674,245 | 0 | <p>You can store a reference to the previously opened paragraph and hide it before displaying a new one. This has the advantage of being quicker if you have lots of paragraphs.</p> <pre class="lang-js prettyprint-override"><code>// My function to open and close the p tag var para = null var evtDelegation = function(evt){ var target = evtUtility.getTarget(evt); if(target.nodeName.toLowerCase() === 'h1'){ if(para !== null) { para.style.display = 'none'; } para = evtUtility.nextSiblings(target); para.style.display = 'block'; }; }; evtUtility.addEvent(document, 'click', evtDelegation); </code></pre> <p><a href="http://jsfiddle.net/dHUPg/" rel="nofollow">http://jsfiddle.net/dHUPg/</a></p> |
29,311,392 | 0 | <p>Here is the list of valid timezones:</p> <p><a href="http://en.wikipedia.org/wiki/List_of_tz_database_time_zones">http://en.wikipedia.org/wiki/List_of_tz_database_time_zones</a></p> <p>You can use</p> <pre><code>TIME_ZONE = 'Europe/Istanbul' </code></pre> <p>for UTC+02:00</p> |
35,278,266 | 0 | <p>I would use a regular expression on that, that looks like this:</p> <pre><code>(\d+) ([\d.:]+) (\d+) (\d+)\([^)]+\) (.*) </code></pre> <p>combined with <a href="http://php.net/manual/de/function.preg-match-all.php" rel="nofollow"><code>preg_match_all</code></a> in PHP like that:</p> <pre><code>preg_match_all('#(\d+) ([\d.:]+) (\d+) (\d+)\([^)]+\) (.*)#', $players, $matches); </code></pre> |
2,544,548 | 0 | <p>Is it fair to assume that you control the types which have "CustomPropertyOfControl"? If so, make them all implement an interface, and cast to that interface.</p> <p>The point of a cast is to tell the compiler something you know that it doesn't - <em>at compile time</em>. Here you don't know the type at compile time. If you know some base class or interface, then you can tell the compiler <em>that</em> with no problem.</p> <p>Now in C# 4 you <em>could</em> do this using dynamic typing:</p> <pre><code>private void ConvertToTypeAndUseCustomProperty(Control c) { dynamic d = c; d.CustomPropertyOfControl = 234567; } </code></pre> <p>However, even though you <em>can</em> do this, I'd still recommend sticking with static typing if at all possible - if you've got a group of types which all have some common functionality, give them a common interface.</p> |
27,750,633 | 0 | Edit read-only file in java <p>I have a protect, read-only, text file on my Linux operating system that I have to make edits to. Of course I can goto the terminal and type:</p> <pre><code>sudo gedit /etc/ppp/options </code></pre> <p>I would then have to type my sudo password. My question is how do I give my java program "sudo" privileges to be able to write to this file and save those edits? I figured once I have given the program these privileges I could then use a BufferedWriter or PrintWriter to make edits.</p> <p>To clarify, my program prompts the user for their administrative (sudo) password. How could I use this to grant access to this file for writing purposes?</p> |
8,956,942 | 0 | <p>I would suggest you to use CRON if you need to start a process on a time basis.</p> |
36,652,205 | 0 | Take let variable out of temporal dead zone <p>See this code:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code><script> let {foo} = null; // TypeError </script> <script> // Here I want to assign some some value to foo </script></code></pre> </div> </div> </p> <p>The first script attempts to let-declare <code>foo</code> via a destructuring assignment. However, <code>null</code> can't be destructured, so the assignment throws a TypeError.</p> <p>The problem is that then the <code>foo</code> variable is declared but uninitialized, so if in the 2nd script I attempt to reference <code>foo</code>, it throws:</p> <pre><code>foo = 123; // ReferenceError: can't access lexical declaration `foo' before initialization </code></pre> <p>And <code>let</code> variables can't be redeclared:</p> <pre><code>let foo = 123; // SyntaxError: redeclaration of let foo </code></pre> <p>Is there any way to take it out of the TDZ, so that I can assign values and read them?</p> |
38,585,109 | 0 | <p>As the <code>rle</code> is a <code>list</code> object with <code>lengths</code> and <code>values</code> as elements of the <code>list</code>, we can extract the <code>lengths</code> and <code>sum</code></p> <pre><code>sum(b$lengths) #[1] 10 </code></pre> |
20,380,699 | 0 | <p>Can you try using,</p> <p><code>$delete = "DELETE from $table_name where $key = '".$value."' ";</code></p> <p>instead of </p> <p><code>$delete = "DELETE from $table_name where $key = $value";</code></p> |
27,186,994 | 0 | <p>You would need the parameter pass to <code>Destruir</code> to be a <code>var</code> parameter so that the modification you make to the passed argument to modify the passed variable, rather than a local copy of it.</p> <pre><code>procedure TForm1.Destruir(var aForm: TForm); begin FreeAndNil(aForm); end; </code></pre> <p>Of course, this function is a little needless since you may as well just call <code>FreeAndNil</code> directly instead of calling <code>Destruir</code>.</p> |
22,422,615 | 0 | <p>The best practice here would be to use two different stages.</p> <p>Using two stages will simplify design in sense that the viewport management for 2d animation will simplify by a considerable amount. Also the event handling has to be completely different style. Your information panel won't have much relative layout changes in actors as compared to 2d animation.</p> <p>Using same stage would make sense only if both contents overlap each other in some form. I'm sure this is not the case here. Your info panel will always be ABOVE animation (most probably).</p> <p>Hope this helps.</p> |
27,819,078 | 0 | <p>Thanks all for trying to help me! However, the solution is to do so in the code:</p> <pre><code>System.setProperty("com.siebel.management.jmxapi.cfgFileName", "C:\\siebelmonitor\\1srvr.xml"); </code></pre> |
34,876,614 | 0 | <p>First of all you need to tell where are you writing this code. Don't mind but your code looks like not as it should be: 1- Which version are you using (Yii1 | Yii2)? I guess Yii1</p> <p>if you are using yii1 and you want to perform this stuff under profile update Action. </p> <p>so lets consider "profile/update" Action. so there will be some thing like below under "ProfileController". </p> <pre><code>public function actionUpdate(){ //some thing will be placed here.... } </code></pre> <p>There are 2 ways to do it. one just do it along with the controller or user Hooks (recommended) so it will be under "Model afterSave" hook. some thing like that. you can use any extension / component / widget.</p> <p><a href="http://www.yiiframework.com/extension/paypal/" rel="nofollow">Paypal Extension</a> can tell you how you can do it .</p> |
3,479,298 | 0 | <p>Not sure if this is the same 'MIRTH', but here is an entire community around it</p> <p><a href="http://www.mirthcorp.com/community/forums/index.php?s=b6990e9fe7bf68731f7075bd1412f336" rel="nofollow noreferrer">http://www.mirthcorp.com/community/forums/index.php?s=b6990e9fe7bf68731f7075bd1412f336</a></p> <p>I have never used MIRTH, but this looks promising ...</p> |
5,095,992 | 0 | <p>The follows will give you the amount in <code>$matches[2]</code>, and the currency symbol or alpha representation will always be in <code>$matches[1]</code> or <code>$matches[3]</code></p> <pre><code>$values = array("$5.00", "€1.23", "£1,323.45", "1.23USD"); foreach($values as $val) { preg_match("/([^0-9.,]*)([0-9.,]*)([^0-9.,]*)/", $val, $matches); print_r($matches); } </code></pre> |
30,875,815 | 0 | Resize HDF5 dataset in Julia <p>Is there a way to resize a chunked dataset in HDF5 using Julia's HDF5.jl? I didn't see anything in the documentation. Looking through the source, all I found was <code>set_dims!()</code>, but that cannot extend a dataset (only shrink it). Does HDF5.jl have the ability to enlarge an existing (chunked) dataset? This is a very important feature for me, and I would rather not have to call into another language.</p> |
40,166,634 | 0 | leaflet - how to add a handler with cycle behavior? <p>I've followed handler tutorial on <a href="http://leafletjs.com/examples/extending/extending-3-controls.html" rel="nofollow">http://leafletjs.com/examples/extending/extending-3-controls.html</a>.</p> <p>I can do handler that do something on event ('mouseover', etc...) but I don't find a way to do something every 100ms. I have tried to use setTimeout/setInterval but I can't catch 'this' because window object throw the event. </p> <p>I didn't found something about that in documentation, nor in github. Is there such mecanism in leaflet ?</p> <p>Anybody could help me ?</p> <p>Thx</p> |
909,600 | 0 | <p>Is'nt this the sort of this that RemObjects is good at? Bri</p> |
10,955,497 | 0 | <p>Adding my solution as answer, per halfer's advice: Solved this one, because I was passing the content to Zend_Pdf as a string, i should have been using Zend_Pdf::parse($new_pdf);, as it very likely says in the manual. (oops)</p> <p>Further; I solved pretty much ALL of my problems with digitally signing PDFs of various versions and form constituents by moving to TCPDF, as several of the articles here suggest. A similar caveat was met with TCPDF though, when using strings, ensure that you are using TCPDF's 'writeHTMLCell' instead of 'writeHTML'. And watch for PHPs 'magic_quotes', errant whitespace, encoding, and goblins.</p> |
13,791,014 | 0 | Some Fibonacci FUN in Java <p>I'm having a little trouble with a problem in my intro to java book. Here is the situation: A user must input a Number, after that I must find the Fibonacci of that number. I am given this equitation for listing the numbers(see code). While yes i got that working i am wondering how i go about calculating my Fibonacci from that. oh and on a side note "Notepad ++" yells at me for not having a "public static void main(Strings[] args)". Is there a work around for that?</p> <pre><code>public class Fibonacci { public static void main(String[] args) { } public int Fib(int n) { FibonacciJDialog userInput = new FibonacciJDialog(); int in1=1,in2=1; int sum=1;//initial value int index; index = userInput.getUserInput(); while (index <= n) { sum = in1+in2;// sum=the sum of 2 values; in1=in2;// in1 gets in2 in2 = sum;// in2 gets sum index++;// increment index } return sum; } } </code></pre> |
3,316,261 | 0 | prevent long running averaging from overflow? <p>suppose I want to calculate average value of a data-set such as</p> <pre><code>class Averager { float total; size_t count; float addData (float value) { this->total += value; return this->total / ++this->count; } } </code></pre> <p>sooner or later the <code>total</code> or <code>count</code> value will overflow, so I make it doesn't remember the total value by :</p> <pre><code>class Averager { float currentAverage; size_t count; float addData (float value) { this->currentAverage = (this->currentAverage*count + value) / ++count; return this->currentAverage; } } </code></pre> <p>it seems they will overflow longer, but the multiplication between <code>average</code> and <code>count</code> lead to overflow problem, so next solution is:</p> <pre><code>class Averager { float currentAverage; size_t count; float addData (float value) { this->currentAverage += (value - this->currentAverage) / ++count; return this->currentAverage; } } </code></pre> <p>seems better, next problem is how to prevent <code>count</code> from overflow?</p> |
36,764,398 | 0 | <p>It turns out this issue didn't have anything to do with the APIs or how they were being used. It looks like the encoder used to create the video segments were creating errors in the resulting files.</p> <p>The errors reported by ffprobe are like:</p> <pre><code>[h264 @ 00000249a4348980] decode_slice_header error [h264 @ 00000249a4348980] no frame! [h264 @ 00000249a4348980] non-existing PPS 0 referenced </code></pre> <p>I'm not sure what the original tool was that was used to create the video segments I was using, but I've verified that Apple's mediafilesegmenter also causes errors.</p> <p>I solved the error by encoding the segments using ffmpeg.</p> |
24,575,977 | 0 | Flow 3 machines 2 manipulators <p>I have 3 machines <code>Mach1</code>, <code>Mach2</code>, <code>Mach3</code> and 2 manipulators <code>Man1</code>, <code>Man2</code></p> <p><code>Man1</code> handles <code>Mach1</code> and <code>Mach3</code></p> <p><code>Man2</code> handles <code>Mach2</code> and <code>Mach3</code>, so there is one common Machine</p> <p>each Machine has cycle time <code>Tmach</code>, each manipulator has service time <code>Tservice</code>.</p> <p>Service times often differs due to some problems during servicing etc.</p> <p>Machine cycle times are in most cases constant, but they are unknown at the start of system.</p> <p><strong>The question is:</strong> How to optimize flow for this system? What algorithms can be used? Each reference is valuable, but the best is pseudo code.</p> <p>Stupid solution for the problem is: Start <code>Man1</code> handle <code>Mach3</code>, <code>Man2</code> handle <code>Mach2</code> then <code>Man1</code> handle <code>Mach1</code> and <code>Man2</code> handle <code>Mach3</code> and so on...</p> <p>It is quite ok, but when handling times starts to differ, flow is not optimal.</p> <p>//Edit thanks @j_random_hacker for questions that helps to specify problem more clearly</p> <p>Manipulator is for example industrial robot</p> <p>Cycle time means time of processing part on a machine</p> <p>Service time means time in which robot handles machine it can differ due to waiting for part to be loaded, positioning part etc.</p> <p>Each machine is the same, but manipulators can reach only specified machines</p> <p>Jobs are qued so there are always jobs to be done Each job is processed in one cycle Processing can not and must not be splited</p> |
20,165,275 | 0 | <p>See the documentation of Math.log : <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log</a></p> <p>For further help you should ask your math teacher or someone who knows about algorithms ;-P</p> <p>maybe you should see the part: <code>((b*c-a*d)/(c*c)*(Math.log(Math.abs(c*Xp+d))))</code> Maye you want to have the braces done like <code>(x/(z*y))</code> or <code>((x*y)/z)</code>.</p> |
34,662,260 | 0 | <pre><code>var arraySearch = function (subArray,array ) { var i = -1; return subArray.every(function (v) { if(i != -1) { i++; return (array.indexOf(v) === i) } i = array.indexOf(v); return i >= 0; }); }; var arr = [1,3,4,5,9]; console.log(arraySearch([4,5],arr)) </code></pre> |
7,086,236 | 0 | Possible to detect bit errors in memory in software? <p>A friend and I were curious as to whether you could detect levels of ionizing radiation by looking at rates of single bit errors in memory. I did a little research and I guess most errors are caught and fixed at the hardware level. Would there be any way to detect errors in software (say, in c code on a pc)?</p> |
40,101,080 | 0 | <p>Yor problem is here: <code>$message = wordwrap($message, 70, "\r\n");</code> you neet to add <code>.=</code> <br><br> It is the same as <code>$message = $message . "wordwrap($message, 70, "\r\n")";</code></p> |
2,984,603 | 0 | <p><a href="http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/" rel="nofollow noreferrer">This is good tutorial.</a> Note that mysql (i believe youll use it) online users table should be typed as MEMORY.</p> |