pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
32,433,046
0
<p>The default dxSlideOut item template does not support the 'icon' field. So, you can use the <a href="http://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxSlideOut/Default_Item_Template/?version=15_1#menuTemplate" rel="nofollow">menuTemplate</a> option to define icon for a menu item.</p> <pre><code>&lt;div data-options="dxTemplate:{ name:'menuItem' }"&gt; &lt;span data-bind="attr: {'class': 'dx-icon-' + icon}"&gt;&lt;/span&gt; &lt;span data-bind="text: text"&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>I've created a small fiddle here - <a href="http://jsfiddle.net/dfc2ggck/1/" rel="nofollow">http://jsfiddle.net/dfc2ggck/1/</a></p> <p>Also, be sure your icon exists in the <a href="http://js.devexpress.com/Documentation/Guide/Themes/Icon_Library/?version=15_1#Icon_Library" rel="nofollow">DevExtreme Icon Library</a>.</p>
28,285,128
0
Excel 2010 Macro to transpose non adjacent cells <p>I'm currently transposing data from column to a row in a different spreadsheet one at a time. I began using the "record macro" function but I'm having trouble. I need the macro to copy data column by column and transpose it into a corresponding row, 15 rows apart. There are 100 entries per document. For example; P4 - P23 in document 1 needs to be transposed to M217 - AF217 in document 2. Q4 - Q23 needs to be transposed to M232 - AF 232, up to row 1501.</p>
39,860,827
0
<p>I think you should add @Configuration and @EnableWebSecurity annotations to SecurityConfig</p> <pre><code>@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { } </code></pre>
26,598,833
0
Using a UIScrollView to change the alpha of an image <p>My aim is to effectively use a UIScrollView as a UISlider.</p> <p>I've managed to code a UISlider to change the alpha of an image however I want to code a scrollview to change the alpha of an image when it is scrolled. </p> <p>I think I'm on the right lines by using the scroll views content offset to adjust alpha balances in the scroll view delegate but I just can't seem to get the code to work! </p> <p>Any suggestions on how I can get do this?</p> <p>Thanks</p>
32,163,675
0
<p>Is "05 - Listen to the Man_[plixid.com]" an asset within your project? If not I believe that's why this won't work. I'm pretty sure <a href="http://docs.unity3d.com/ScriptReference/Resources.Load.html" rel="nofollow">Resources.Load</a> is just for loading your existing assets into RAM, so that they're ready when you need them.</p> <p>I did a bit of looking around, and you might find <a href="http://forum.unity3d.com/threads/importing-audio-files-at-runtime.140088/" rel="nofollow">this thread</a> useful, as well as <a href="http://docs.unity3d.com/ScriptReference/WWW.GetAudioClip.html" rel="nofollow">this page</a> from the Unity reference docs.</p> <p>Here's a sample of JS from there that should do the trick. Hopefully you can translate into C# easily enough if that's what you prefer :)</p> <pre><code>var www = new WWW ("file://" + Application.dataPath.Substring (0, Application.dataPath.LastIndexOf ("/")) + "/result.wav"); AudioClip myAudioClip= www.audioClip; while (!myAudioClip.isReadyToPlay) yield return www; gameObject.GetComponent&lt;AudioSource&gt; ().audio.clip = myAudioClip; audio.Play (); </code></pre>
30,819,556
0
<p>I believe that the problem is in the <strong>order</strong> of your rules:</p> <pre><code>.antMatchers("/admin/**").hasRole("ADMIN") .antMatchers("/admin/login").permitAll() </code></pre> <p>The order of the rules matters and the more specific rules should go first. Now everything that starts with <code>/admin</code> will require authenticated user with ADMIN role, even the <code>/admin/login</code> path (because <code>/admin/login</code> is already matched by the <code>/admin/**</code> rule and therefore the second rule is ignored).</p> <p>The rule for the login page should therefore go before the <code>/admin/**</code> rule. E.G.</p> <pre><code>.antMatchers("/admin/login").permitAll() .antMatchers("/admin/**").hasRole("ADMIN") </code></pre>
31,250,986
0
Why there is a duplicated consumer after a connection recovery in RabbitMQ? <p>I am using:</p> <ul> <li>RabbitMQ 3.5.1</li> <li>Java RabbitMQ client</li> <li>Cluster with two RabbitMQ instances</li> </ul> <p>I have a queue that is:</p> <ul> <li>Durable=false</li> <li>Exclusive=false</li> <li>Auto-delete=true</li> <li>Queue mirroring didn't affect the results</li> </ul> <p>In my application there is an asynchronous consumer receiving the messages through a callback. The problem happens when I try to simulate a connection failure by disabling the network communication with the broker. After the connection is restablished the queue (in the web administration interface) is showing two consumers connected with the same consumer tag, but with different port numbers.</p> <p>When I stop the app one of the consumers disappears, but the other one remains connected, thus the queue is not deleted. Is this expected or I do I have to change something to avoid this?</p>
40,278,534
0
<p>i think that you have to add following configuration:</p> <pre><code>sonar.forceAuthentication=true ldap.bindDn=[YOURLDAPSERVICEUSER] ldap.bindPassword=[YOURLDAPSERVICEUSERPWD] ldap.user.baseDn=ou=[YOUROU],dc=[DOMAINNAME] ldap.user.request=(&amp;(objectClass=user)(sAMAccountName={login})) </code></pre> <p>you should not change last line but you have to replace parameters which marked with []</p>
29,165,578
0
<p>Here's an example, to give you an idea:</p> <pre><code>function recursiveKeyTargeting($array, $target_key, $element_to_add) { foreach($array AS $arr) { if(is_array($arr['key'])) { recursiveKeyTargeting($array['key'], $target_key, $element_to_add); } else if($arr['key'] == $target_key) { $arr[] = $element_to_add; break; } } } </code></pre>
16,737,371
0
<p>maybe you can use jquery if loaded to add/remove classes and attributes</p>
14,002,181
0
<p>As I mentioned in my comment, <code>$.getJSON</code> is an asynchronous function. The data won't be available immediately after you call it, but after you are done processing the response returned by the server in the <code>success</code> callback.</p> <p>In other words:</p> <pre><code>$('#ss').mlData({ url:'ajax.php', }, function(result,add) { ... /* At his point the data should be available */ /* You can call it onwards */ $('#ss').mlSelect(); }); </code></pre> <p>That's why you can't see the new data.</p>
15,315,857
0
<p>BI = new BondImage(this); has not been added to layout view that y its not showing up </p> <p>try</p> <pre><code>setContentView(BI); </code></pre>
31,467,286
0
NSUserDefaults for high score is not working on iOS 8 Simulator? <p>I've tried to synchronize the saved data but my game still does not store the highest score. I can't find whats wrong with the replacing of the highScore with score if it is higher. Sorry I'm a beginner who just started learning iOS programming.</p> <pre><code>init(size: CGSize, score: NSInteger) { super.init(size: size) self.backgroundColor = SKColor.whiteColor() //To save highest score var highscore = 0 let userDefaults = NSUserDefaults.standardUserDefaults() if (score &gt; highscore){ NSUserDefaults.standardUserDefaults().setObject(score, forKey: "highscore") NSUserDefaults.standardUserDefaults().synchronize() } var savedScore: Int = NSUserDefaults.standardUserDefaults().objectForKey("highscore") as! Int //To get the saved score var savedScore: Int = NSUserDefaults.standardUserDefaults().objectForKey("highscore") as! Int </code></pre>
23,949,360
0
<p>If you are referring to the mangled key of <code>files</code> array then it's raw infohash - check out the spec:</p> <ul> <li><a href="https://wiki.theory.org/BitTorrentSpecification#Tracker_.27scrape.27_Convention" rel="nofollow">https://wiki.theory.org/BitTorrentSpecification#Tracker_.27scrape.27_Convention</a></li> <li><a href="http://wiki.vuze.com/w/Scrape" rel="nofollow">http://wiki.vuze.com/w/Scrape</a></li> </ul>
39,513,341
0
Changing a word document title with Textbox values <p>Im currently making a VBA userform with multiple textboxes. My goal is to make a macro enabled word template that pops up a userform on startup, containing multiple textboxes where the user can input values. </p> <p>I was looking for a way to change the default save title of my word document. I wanted to pass input values from textboxes into the title so that it would look something like this:</p> <blockquote> <p>"Textbox1.Value_Textbox2.Value_Combobox1.Value_Textbox3.Value_....." (Space for the user to personalize the document name)</p> </blockquote> <p>The underscore seperation is very important. </p> <p>I tried setting it with </p> <pre><code> 'WORKS' With Dialogs(wdDialogFileSummaryInfo) .Title = TextBox7.Value .Execute End With </code></pre> <p>With the aim to combine all those textbox values into textbox 7 but i just cant get it to work. Is there any other way to fix this issue?</p>
37,841,439
0
Running SonarQube against an ASP.Net Core solution/project <p>SonarQube has an MSBuild runner but .NET Core uses dotnet.exe to compile and msbuild just wraps that. I have tried using the MSBuild runner with no success against my ASP.NET Core solution. Using SonarQube Scanner works kind of.</p> <p>Any suggestions on how I can utilize SonarQube with .NET Core? The static code analysis is what I am looking for.</p>
16,681,086
0
<p>Yes, you need the group by clause, and you need to use the <a href="http://dev.mysql.com/doc/refman/5.6/en/group-by-functions.html#function_group-concat" rel="nofollow">GROUP_CONCAT</a> function. You should group your results by People.fk_rooms and Thing.fk_rooms.</p> <p>Maybe you could use two different queries: The first will result the join of Rooms and People, grouped by fk_rooms, having selected three columns, they are being RoomsID, RoomName, People, while the second will result the join of Rooms and Thing, grouped by fk_rooms, having selected three columns, they are being RoomID, RoomName, Things. In your query you name these selections as t1 and t2 and join t1 and t2 by RoomsID, select t1.RoomName, t1.People, t2.Things.</p> <p>Good luck.</p>
13,424,379
0
How do I get browsers to trust self-signed certificates for testing? Website address is slightly different than fully qualified domain name <p>I have a website that is being configured with SSL, and I am using a self-signed certificate for testing purposes, for now. The machine is running Windows 2008 R2 with IIs 7.5 and Apache Tomcat 5.5. </p> <p>The problem is FireFox is gives the error that the connection is untrusted because it's a self-signed certificate and it also says that the site is using an invalid security certificate. I tried importing the certificate into Firefox, to remedy the situation, and it did not help. However, with IE, exporting the certificate from IIS and importing it into the browser's Trusted Root Certificate Authorities store permitted IE to trust the self-signed certificate.</p> <p>It's important to note that the server's fully qualified domain name is webdev.dev.mysite.com, whereas the website address is webdev.mysite.com and I've had no problems with the site under HTTP. And with the help of the site <a href="http://blogs.iis.net/thomad/archive/2010/04/16/setting-up-ssl-made-easy.aspx" rel="nofollow">here</a>, I setup the self-signed certificate such that it's name is webdev.mysite.com.</p> <p>How can I get Firefox to trust the self-signed certificate? </p> <p>Thank you very much for any help.</p>
32,888,869
0
<p>Firebase stores a sequence of values in this format:</p> <pre><code>"-K-Y_Rhyxy9kfzIWw7Jq": "Value 1" "-K-Y_RqDV_zbNLPJYnOA": "Value 2" "-K-Y_SBoKvx6gAabUPDK": "Value 3" </code></pre> <p>If that is how you have them, you are getting the wrong type. The above structure is represented as a <code>Map</code>, not as a <code>List</code>:</p> <pre><code>mFirebaseRef = new Firebase(FIREBASE_URL); mFirebaseRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { Map&lt;String, Object&gt; td = (HashMap&lt;String,Object&gt;) dataSnapshot.getValue(); List&lt;Object&gt; values = td.values(); //notifyDataSetChanged(); } @Override public void onCancelled(FirebaseError firebaseError) { } }); </code></pre>
38,936,410
0
planets and star sizes as page scrolls <p>I am a teacher and I am trying to make a page for my students showing the comparative size of the planets and the stars, like in one of those videos that are popular in Youtube.</p> <p>But I have not been able to solve the problem, the closest I got was using "if window.pageXOffset > 1000" animate width etc. but what I really wanted was for the planets and stars (images) to scroll into view at 100% height and then as the page scrolled towards the right, they´d shrink down till 0% when reaching the left border (left=0px), while the next and next planet scrolled into view (showing 3 or 4 at a time) and so forth. The page should allow the user to scroll back and forth at will.</p> <p>I tried the transform: scale method but wasn´t successful either.</p> <p>Any help will be greatly appreciated.</p>
12,562,777
0
<p>There is a backport of the <code>functools</code> module from <em>Python 3.2.3</em> for use with <em>Python 2.7</em> and <em>PyPy</em>: <a href="http://pypi.python.org/pypi/functools32">functools32</a>.</p> <p>It includes the <code>lru_cache</code> decorator.</p>
32,526,621
0
<p>We can use <code>cut</code> to produce bins and <code>sub</code> to rename them</p> <pre><code>mtcars$dispR &lt;- as.character(cut(mtcars$disp,breaks = seq(0,500,100),right=FALSE)) mtcars$dispR &lt;- sub("\\[(\\d{1,3}).*","\\1+",mtcars$dispR) </code></pre> <p>Then, to add the proportion, we can use <code>questionr::rprop</code></p> <pre><code>library(questionr) rprop(table(mtcars$gear,mtcars$dispR)) 0+ 100+ 200+ 300+ 400+ Total 3 0.0 6.7 33.3 33.3 26.7 100.0 4 33.3 66.7 0.0 0.0 0.0 100.0 5 20.0 40.0 0.0 40.0 0.0 100.0 Ensemble 15.6 34.4 15.6 21.9 12.5 100.0 </code></pre> <p>This second step may be done in base R with <code>addmargins</code></p> <pre><code>t &lt;- addmargins(table(mtcars$gear,mtcars$dispR)) round(t/t[,"Sum"] * 100,1) 0+ 100+ 200+ 300+ 400+ Sum 3 0.0 6.7 33.3 33.3 26.7 100.0 4 33.3 66.7 0.0 0.0 0.0 100.0 5 20.0 40.0 0.0 40.0 0.0 100.0 Sum 15.6 34.4 15.6 21.9 12.5 100.0 </code></pre>
4,942,312
0
<p>JS Beautifier will both reformat and unpack:</p> <p><a href="http://jsbeautifier.org/">http://jsbeautifier.org/</a></p>
5,332,132
0
<p>Perhaps your UIImageView is not configured to receive user interaction</p> <blockquote> <p>UIImageView has in default userInteractionEnabled set to NO. I would try to change it to YES.</p> </blockquote> <p><a href="http://stackoverflow.com/questions/3005903/uigesturerecognizer-in-a-view-inside-a-uiscrollview">UIgestureRecognizer in a view inside a UIScrollView</a></p>
32,731,449
0
<p>Use range.setValues, is the best choice. Works for any range in any sheet, as far as the origin and destination range are similar.</p> <p>Here's a sample code:</p> <pre><code>function openCSV() { //Buscamos el archivo var files = DriveApp.getFilesByName("ts.csv"); //Cada nombre de archivo es unico, por eso next() lo devuelve. var file = files.next(); fileID = file.getId(); //Abrimos la spreadsheet, seleccionamos la hoja var spreadsheet = SpreadsheetApp.openById(fileID); var sheet = spreadsheet.getSheets()[0]; //Seleccionamos el rango var range = sheet.getRange("A1:F1"); values = range.getValues(); //Guardamos un log del rango //Logger.log(values); //Seleccionamos la hoja de destino, que es la activeSheet var ss = SpreadsheetApp.getActiveSpreadsheet(); var SSsheet = ss.getSheets()[0]; //Seleccionamos el mismo rango y le asignamos los valores var ssRange = SSsheet.getRange("A1:F1"); ssRange.setValues(values); } </code></pre>
11,624,929
0
<p>Something to do with the exit status returned by Ant in the version I was using (6) as reported by another user <a href="http://jenkins.361315.n4.nabble.com/Ant-build-successful-but-hudson-claims-a-failure-td362339.html" rel="nofollow">here</a>. I "solved" it by upgrading to version 8.</p>
24,450,377
0
<p>I managed to sort this so including the answer for anyone else who runs into this error message.</p> <p>The error: <code>unexpected TOK_IDENT</code> basically means that a field referenced in the query doesn't exist in the index.</p> <p>The best way to verify what's in your index is to run the Sphinx CLI using:</p> <pre><code>mysql -P9306 --protocol=tcp --prompt='sphinxQL&gt; ' </code></pre> <p>And run a SELECT * query like:</p> <pre><code>SELECT * FROM your_index_core WHERE sphinx_deleted = 0 LIMIT 0, 20; </code></pre> <p>From here you can see the fields in the index across the top. </p> <p>I can't figure out why they didn't exist in the index - I'd ran <code>rake ts:rebuild</code> multiple times to no avail. In the end I had to stop searchd, manually delete the configuration file and indexes and rebuild from scratch.</p>
7,159,852
1
Speed up often used Django random query <p>I've got a query set up that puts 28 random records from a database into a JSON response. This page is hit often, every few seconds, but is currently too slow for my liking.</p> <p>In the JSON response I have:</p> <ul> <li>ID's</li> <li>Usernames</li> <li>a Base64 thumbnail</li> </ul> <p>These all come from three linked tables.<br/> I'd be keen to hear of some other solutions, instead of users simply hitting a page, looking up 28 random records and spitting back the response. One idea I had:</p> <ul> <li>Have a process running that creates a cached page every 30 seconds or so with the JSON response.</li> </ul> <p>Is this a good option? If so, I'd be keen to hear how this would be done.</p> <p>Thanks again,<br/> Hope everyone is well</p>
23,190,912
0
<blockquote> <pre><code>std::vector&lt;int&gt; a{1,2,4}; </code></pre> </blockquote> <p>This is initializer-list initialization, not aggregate, because <code>vector</code> is not an aggregate — its data is stored on the heap. You need to have <code>#include &lt;initializer_list&gt;</code> for it to work, although that header is typically included from <code>&lt;vector&gt;</code>.</p> <blockquote> <pre><code>a = {1,2,4}; </code></pre> </blockquote> <p>This also goes through a function overloaded on <code>std::initializer_list</code>, and the semantics are the same as the function call:</p> <pre><code>a.assign( {1,2,4} ); </code></pre> <blockquote> <pre><code> int c[3]={1,4}; </code></pre> </blockquote> <p>This <em>is</em> aggregate initialization. However you cannot do <code>c = { 3, 5, 6 }</code> afterward, because the braced-init-lists may only be initializers for new variables, not operands to built-in expressions. (In a declaration, the <code>=</code> sign is just a notation for initialization. It is not the usual operator. Braced lists are specifically allowed by the grammar for assignment operators, but this usage is only valid with function overloading, which causes the list to initialize a new variable: the function parameter.)</p> <p>The answer to your final question is that there's no way to write the necessary <code>operator =</code> overload for "naked" arrays, because it must be a member function. The workaround is to use <code>std::copy</code> and a <code>std::initializer_list</code> object.</p>
26,137,786
0
<p>If all the elements to be added were already in the Collection (prior to the call to addAll), and the Collection doesn't allow duplicates, it will return false, since all the individual <code>add</code> method calls would return false. This is true for Collections such as <code>Set</code>.</p> <p>For other Collections, <code>add</code> always returns true, and therefore <code>addAll</code> would return true, unless you call it with an empty list of elements to be added.</p>
24,082,185
0
<p>Change the <code>img</code>s <code>display</code> to <code>block</code> </p> <pre><code>a { display:inline-block; } a img { display:block; } </code></pre> <p>See this <a href="http://jsfiddle.net/TLBEx/2/">jsfiddle</a></p> <p>So what does it do? The image inside the link has a default <code>display</code> of <code>inline-block</code>. The a you set to <code>display:inline-block</code>. It's the combination of the two in combination with whitespace inside the <code>a</code> element, that does the problem.</p> <p>You can simulate with two nested <code>inline-block</code> <code>div</code>s which has the dimensions set only on the inner one. <a href="http://jsfiddle.net/TLBEx/4/">http://jsfiddle.net/TLBEx/4/</a></p>
39,055,242
0
<p>Try below solution to achieve what you want. </p> <pre><code>viewPager.setClipToPadding(false); // set padding manually, the more you set the padding the more you see of prev &amp; next page viewPager.setPadding(40, 0, 40, 0); // sets a margin b/w individual pages to ensure that there is a gap b/w them viewPager.setPageMargin(20); </code></pre> <p>Whatever padding you want on top and bottom specify in xml file</p> <pre><code>android:paddingTop="30dp" android:paddingBottom="50dp" </code></pre>
38,912,267
0
Access to PasswordVault fails for user account delegation <p>We are porting a Windows Phone 8.1 app to UWP. In the original app we used PasswordVault (<code>Windows.Security.Credentials</code>) to store user credentials and everything just worked fine. After the porting every operation related to PasswordVault throws exception with the following message:</p> <blockquote> <p>The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation. Failed to open store.</p> </blockquote> <p>If I run the app on my local machine everything is ok, but on the office tablets (with a lot of additional security things like bitlocker, user domains, etc.) the error just shows up.</p> <p>I also tried to create a blank app, and add/retrieve credentials to/from PasswordVault, but the same happened.</p> <p>Any ideas?</p>
2,522,353
0
<pre><code>SELECT * from Table1 WHERE (CDATE(ColumnDate) BETWEEN #03/26/2010# AND #03/19/2010#) SELECT * from Table1 WHERE (CINT(ColumnAge) between 25 and 40) </code></pre> <p>Dates are represented in Access between <code>#</code> symbols in <strong><code>#MM/DD/YYYY#</code></strong>. You should really be storing the date as a date field :)</p>
19,182,502
0
<p>Not saying this is the most efficient way to do it but it works:</p> <pre><code>List&lt;DrawingData&gt; _DrawingList = new List&lt;DrawingData&gt;(); _DrawingList.Add(new DrawingData() { DrawingName = "411000D", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000D", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000A", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000A", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000C", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000C", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000B", DrawingQty = 1 }); _DrawingList.Add(new DrawingData() { DrawingName = "411000B", DrawingQty = 1 }); var _WithIndex = _DrawingList.Select(x =&gt; new { DrawingData = x, Index = _DrawingList.Where(y =&gt; y.DrawingName == x.DrawingName).ToList().IndexOf(x) }); var _FinalOrder = _WithIndex.OrderBy(x =&gt; x.Index).ThenBy(x =&gt; x.DrawingData.DrawingName).Select(x =&gt; x.DrawingData); Console.WriteLine("Final Sort:"); Console.WriteLine(string.Join("\n", _FinalOrder)); Console.ReadLine(); </code></pre> <p>Get the index of each duplicated item, then sort on that index and then the name.</p> <p>Made it a bit simpler. Can be a single LINQ statement:</p> <pre><code>var _FinalOrder = _DrawingList .Select(x =&gt; new { DrawingData = x, Index = _DrawingList.Where(y =&gt; y.DrawingName == x.DrawingName) .ToList() .IndexOf(x) }) .OrderBy(x =&gt; x.Index) .ThenBy(x =&gt; x.DrawingData.DrawingName) .Select(x =&gt; x.DrawingData); </code></pre>
40,699,244
0
<p>You would indeed use whatever server side configuration options are available to you.</p> <p>Depending on how your hosting is set up you could either modify the include path for PHP (<a href="http://php.net/manual/en/ini.core.php#ini.include-path" rel="nofollow noreferrer">http://php.net/manual/en/ini.core.php#ini.include-path</a>) or restricting the various documents/directories to specific hosts/subnets/no access in the Apache site configuration (<a href="https://httpd.apache.org/docs/2.4/howto/access.html" rel="nofollow noreferrer">https://httpd.apache.org/docs/2.4/howto/access.html</a>).</p> <p>If you are on shared hosting, this level of lock down isn't usually possible, so you are stuck with using the Apache rewrite rules using a combination of a easy to handle file naming convention (ie, classFoo.inc.php and classBar.inc.php), the .htaccess file and using the FilesMatch directive to block access to *.inc.php - <a href="http://www.askapache.com/htaccess/using-filesmatch-and-files-in-htaccess/" rel="nofollow noreferrer">http://www.askapache.com/htaccess/using-filesmatch-and-files-in-htaccess/</a></p> <p>FWIW all else being equal the Apache foundation says it is better/more efficient to do it in server side config vs. using .htaccess IF that option is available to you.</p>
28,950,781
0
<p>What about:</p> <pre><code>import re lines = ''' &amp; $(-1,1)$ &amp; $(0,\infty)$ ''' matches = re.findall(r'\((.*),(.*)\)', lines) for (a,b) in matches: print "x: %s y: %s" % (a,b) </code></pre> <p>Outputs</p> <pre><code>x: -1 y: 1 x: 0 y: \infty </code></pre> <p>If you catch some weirdness, consider replacing <code>*</code> with <code>*?</code> to make the matching "not greedy".</p>
23,450,776
1
Python open default terminal, execute commands, keep open, AND then allow user-input <p>I'm wanting to open a terminal from a Python script (not one marked as executable, but actually doing python3 myscript.py to run it), have the terminal run commands, and then keep the terminal open and let the user type commands into it.</p> <p>EDIT (as suggested): I am primarily needing this for Linux (I'm using Xubuntu, Ubuntu and stuff like that). It would be really nice to know Windows 7/8 and Mac methods, too, since I'd like a cross-platform solution in the long-run. Input for any system would be appreciated, however.</p> <hr> <p>Just so people know some useful stuff pertaining to this, here's some code that may be difficult to come up with without some research. This doesn't allow user-input, but it does keep the window open. The code is specifically for Linux:</p> <pre><code>import subprocess, shlex; myFilePathString="/home/asdf asdf/file.py"; params=shlex.split('x-terminal-emulator -e bash -c "python3 \''+myFilePathString+'\'; echo \'(Press any key to exit the terminal emulator.)\'; read -n 1 -s"'); subprocess.call(params); </code></pre> <p>To open it with the Python interpreter running afterward, which is about as good, if not better than what I'm looking for, try this:</p> <pre><code>import subprocess, shlex; myFilePathString="/home/asdf asdf/file.py"; params=shlex.split('x-terminal-emulator -e bash -c "python3 -i \''+myFilePathString+'\'"'); subprocess.call(params); </code></pre> <p>I say these examples may take some time to come up with because passing parameters to bash, which is being opened within another command can be problematic without taking a few steps. Plus, you need to know to use to quotes in the right places, or else, for example, if there's a space in your file path, then you'll have problems and might not know why.</p> <p>EDIT: For clarity (and part of the answer), I found out that there's a standard way to do this in Windows:</p> <pre><code>cmd /K [whatever your commands are] </code></pre> <p>So, if you don't know what I mean try that and see what happens. Here's the URL where I found the information: <a href="http://ss64.com/nt/cmd.html" rel="nofollow">http://ss64.com/nt/cmd.html</a></p>
2,481,876
0
<p>The accepted answer here did not work for me. Instead I had to cast the base channel into an IContextChannel, and set the OperationTimeout on that. </p> <p>To do that, I had to create a new file with a partial class, that matched the name of the ServiceReference. In my case the I had a PrintReportsService. Code is below. </p> <pre><code>using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace RecipeManager.PrintReportsService { public partial class PrintReportsClient : System.ServiceModel.ClientBase&lt;RecipeManager.PrintReportsService.PrintReports&gt;, RecipeManager.PrintReportsService.PrintReports { public void SetOperationTimeout(TimeSpan timeout) { ((System.ServiceModel.IContextChannel)base.Channel).OperationTimeout = timeout; } } } </code></pre> <p>Then when I create the client, I do the following:</p> <pre><code> PrintReportsService.PrintReportsClient client = new RecipeManager.PrintReportsService.PrintReportsClient(); client.SetOperationTimeout(new TimeSpan(0, 4, 0)); </code></pre> <p>That did it for me! More info is available <a href="http://final-proj.blogspot.com/2009/09/wcf-timeouts.html" rel="nofollow noreferrer">here</a>, but the code snippet in this post doesn't compile. </p>
4,600,750
0
Idiomatic usage of filter, map, build-list and local functions in Racket/Scheme? <p>I'm working through <a href="http://htdp.org/2003-09-26/Book/curriculum-Z-H-27.html#node_sec_21.2" rel="nofollow">Exercise 21.2.3</a> of HtDP on my own and was wondering if this is idiomatic usage of the various functions. This is what I have so far:</p> <pre><code>(define-struct ir (name price)) (define list-of-toys (list (make-ir 'doll 10) (make-ir 'robot 15) (make-ir 'ty 21) (make-ir 'cube 9))) ;; helper function (define (price&lt; p toy) (cond [(&lt; (ir-price toy) p) toy] [else empty])) (define (eliminate-exp ua lot) (cond [(empty? lot) empty] [else (filter ir? (map price&lt; (build-list (length lot) (local ((define (f x) ua)) f)) lot))])) </code></pre> <p>To my novice eyes, that seems pretty ugly because I have to define a local function to get <code>build-list</code> to work, since <code>map</code> requires two lists of equal length. Can this be improved for readability? Thank you.</p>
17,599,894
0
Share current URL of UIWebview to Facebook and Twitter <p>so I want to share the current URL of my webview to facebook and twitter using the social framework in Xcode, can anyone tell me how to do this here is my code</p> <pre><code>- (IBAction)social:(id)sender { UIActionSheet *share = [[UIActionSheet alloc] initWithTitle:@"Pass on the news!" delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:@"Post to Twitter", @"Post to Facebook", nil]; [share showInView:self.view]; } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (actionSheet.tag == 0) { if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *tweetSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [tweetSheet setInitialText:@"Check out this article I found using the 'Pass' iPhone app: "]; [self presentViewController:tweetSheet animated:YES completion:nil]; } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have at least one Twitter account setup and your device is using iOS6 or above!." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } } } </code></pre>
9,762,927
0
extracting values to be populated in a dropdown from SQLite database <p>I am developing a web application using ASP.NET MVC and using FluentNHibernate for ORM. I am faced with a situation.</p> <p>I have 8 tables say A,B,C,D,E,F,G,H and each table has say 10 attributes, out of which an average of 5 are lists that have to be populated as dropdowns in the view.</p> <p>Now, these values have to be extracted from the database. I have built individual tables for each dropdown attribute in table A with values, say HighestEducation is an attribute in A and the dropdown values include Undergrad, Masters, Doctorate, etc.</p> <p>I want to build a tightly coupled ADO.NET entity model for that table, but cant seem to do so. Any suggestions on how to get around this one? </p>
1,629,103
0
Disabling screen minimization animation effect in iPhone: <p>Is it possible to disable the home screen minimize animation effect when user presses the home button on iPhone?. Or can we set our own custom image for minimize animation?</p> <p>Regards ypk</p>
35,384,569
0
Remove glow from HTML5 canvas drawings? <p>If I draw a green circle on a black background, then draw the same circle in black, a green shadow/glow is left behind. The circle is not actually erased.</p> <p>How do I make it purely black again and remove the glow?</p> <p>I've tried <code>context.shadowColor = "transparent";</code></p> <p>Here is a snippet:</p> <pre><code>context.beginPath(); context.arc(x-1, y-2, 2, 0, 2*Math.PI); context.fillStyle = "#FF0000"; //context.strokeStyle = "#FF0000"; //context.stroke(); context.fill(); context.beginPath(); context.arc(x-1, y-2, 2, 0, 2*Math.PI); context.fillStyle = "#000000"; //context.strokeStyle = "#000000"; //context.stroke(); context.fill(); </code></pre> <p>Here is the full object:</p> <p><a href="https://i.stack.imgur.com/DzfpC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DzfpC.png" alt="enter image description here"></a></p>
10,183,483
0
InflateException: Binary XML file line #60: Error inflating class com.google.android.maps.MapView <p>I keep on receiving this error and i don't know where this error occurs this the xml file</p> <pre><code>?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;/LinearLayout&gt; </code></pre> <p>And here it is the log cat </p> <pre><code>04-17 02:19:25.556: W/dalvikvm(731): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 04-17 02:19:25.586: E/AndroidRuntime(731): FATAL EXCEPTION: main 04-17 02:19:25.586: E/AndroidRuntime(731): java.lang.RuntimeException: Unable to start activity ComponentInfo{sbn.project.gp/sbn.project.gp.Mainevent}: android.view.InflateException: Binary XML file line #60: Error inflating class com.google.android.maps.MapView 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.os.Handler.dispatchMessage(Handler.java:99) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.os.Looper.loop(Looper.java:123) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.main(ActivityThread.java:4627) 04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Method.invokeNative(Native Method) 04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Method.invoke(Method.java:521) 04-17 02:19:25.586: E/AndroidRuntime(731): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 04-17 02:19:25.586: E/AndroidRuntime(731): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 04-17 02:19:25.586: E/AndroidRuntime(731): at dalvik.system.NativeStart.main(Native Method) 04-17 02:19:25.586: E/AndroidRuntime(731): Caused by: android.view.InflateException: Binary XML file line #60: Error inflating class com.google.android.maps.MapView 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.createView(LayoutInflater.java:513) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 04-17 02:19:25.586: E/AndroidRuntime(731): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.Activity.setContentView(Activity.java:1647) 04-17 02:19:25.586: E/AndroidRuntime(731): at sbn.project.gp.Mainevent.onCreate(Mainevent.java:27) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 04-17 02:19:25.586: E/AndroidRuntime(731): ... 11 more 04-17 02:19:25.586: E/AndroidRuntime(731): Caused by: java.lang.reflect.InvocationTargetException 04-17 02:19:25.586: E/AndroidRuntime(731): at com.google.android.maps.MapView.&lt;init&gt;(MapView.java:238) 04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Constructor.constructNative(Native Method) 04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.createView(LayoutInflater.java:500) 04-17 02:19:25.586: E/AndroidRuntime(731): ... 21 more 04-17 02:19:25.586: E/AndroidRuntime(731): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity. 04-17 02:19:25.586: E/AndroidRuntime(731): at com.google.android.maps.MapView.&lt;init&gt;(MapView.java:282) 04-17 02:19:25.586: E/AndroidRuntime(731): at com.google.android.maps.MapView.&lt;init&gt;(MapView.java:255) </code></pre> <p>And here it is the android manifest </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tt.pp.ss" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;uses-library android:name="com.google.android.maps" /&gt; &lt;activity android:name=".SbnActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Main" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="tt.pp.ss.MAIN" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Db" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="tt.pp.ss.DB" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".View" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="tt.pp.ss.VIEW" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Mainevent" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="tt.pp.ss.MAINEVENT" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Signup" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="tt.pp.ss.SIGNUP" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Any help i have spent more than 5 hours and i can't figure it out.</p>
12,221,252
0
How pinterest type url's work <p>When we click on pinterest pin the url changes to pinterest.com/pin/[pinid] But how come it happens without full loading of the page and only the url is changed. <img src="https://i.stack.imgur.com/JVmnI.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/LfYJk.jpg" alt="enter image description here"></p>
39,541,750
0
Unable to move on to next page http://indianvisa-bangladesh.nic.in/visa/Get_Appointment via httpClient 4.4 <p>Hiii Update 2: thanks 4 the help. I got the cookies now but i am stuck on the same page. I added cookie as header with request but i got the same page as response. Don't know i m doing wrong. Please guide me.</p> <pre><code>org.apache.http.impl.client.AbstractHttpClient httpclient = new org.apache.http.impl.client.DefaultHttpClient(); try { // Create a local instance of cookie store CookieStore cookieStore = new BasicCookieStore(); // Create local HTTP context HttpContext localContext = new BasicHttpContext(); // Bind custom cookie store to the local context System.out.println("Binding Cookie from Cookie Store="+this.cookies); String c=this.cookies.replaceAll("Set-Cookie: ", ""); String c1=c.replaceAll(";path=/", ""); System.out.println("c="+c1); String []ar=c1.split("="); System.out.println("a[0]="+ar[0]); System.out.println("a[1]="+ar[1]); BasicClientCookie cookie = new BasicClientCookie(ar[0], ar[1]); cookie.setDomain("indianvisa-bangladesh.nic.in"); cookie.setPath("/"); cookieStore.addCookie(cookie); httpclient.setCookieStore(cookieStore); localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); HttpGet httpget = new HttpGet("http://indianvisa-bangladesh.nic.in/visa/Get_Appointment"); System.out.println("executing request " + httpget.getURI()); // Pass local context as a parameter HttpResponse response = httpclient.execute(httpget, localContext); HttpEntity entity = response.getEntity(); System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); } List&lt;Cookie&gt; cookies = cookieStore.getCookies(); for (int i = 0; i &lt; cookies.size(); i++) { System.out.println("Local cookie: " + cookies.get(i)); } BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println("Page contect="+result); // Consume response content EntityUtils.consume(entity); System.out.println("----------------------------------------"); } finally { // When HttpClient instance is no longer needed, // shut down the connection manager to ensure // immediate deallocation of all system resources //httpclient.getConnectionManager().shutdown(); } </code></pre>
15,623,236
0
<p>Google has actually since added <a href="https://developers.google.com/appengine/docs/python/mail/bounce" rel="nofollow">a method for receiving bounced messages</a> via an HTTP Request. It requires adding to your app.yaml:</p> <pre><code>inbound_services: - mail_bounce </code></pre> <p>Which will cause a request to hit <code>/_ah/bounce</code> each time a bounce is received. You can then handle the bounce by adding a handler for it. See the section <a href="https://developers.google.com/appengine/docs/python/mail/bounce" rel="nofollow">there</a> on Handling Bounce Notifications for more details on how to glean the additional information from those requests.</p>
23,656,280
0
<p>To insert ID value on a table just do that</p> <pre><code>SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF } </code></pre> <p>Example your table name is People it should be</p> <pre><code>INSERT INTO People(ID,NAME) VALUES(3,'Felicio') </code></pre> <p>PS: to insert indentity value you also need to explicity the columns names and order as in previous example.</p>
31,533,113
0
FullCalendar, JSON array empty but working on PHP file <p>I am configuring FullCalendar with a MySQL DB, using PHP to process and return a JSON.</p> <ul> <li><strong>db-connect.php</strong> - fetches results from my Db and encodes to JSON.</li> <li><strong>get-events.php</strong> - reads JSON, converts to FullCalendar</li> <li><strong>json.html</strong> - is my front-end calendar view</li> </ul> <p>File contents below, but before reading: <code>db-connect.php</code> successfully outputs JSON that I have verified on JSONLint.</p> <pre><code>[{"title":"Test new calendar","start":"2015-07-21","end":"2015-07-22"}] </code></pre> <p><code>get-events.php</code> is successfully 'reading' <code>db-connect.php</code> as the "php/get-events.php must be running." error message on my front-end view has disappeared (shows if for example it can't establish that <code>db-connect.php</code> is in the directory, or spelling error in file name, etc).</p> <p>However when I either pass the query via <code>params</code> or check in Firebug console, the JSON array is empty.</p> <pre><code>/cal/demos/php/get-events.php?start=2015-07-01&amp;end=2015-07-31 </code></pre> <p>returns <code>[]</code> whereas my test calendar entry does fall within these parameters.</p> <p>I'm convinced it's my <code>db-connect.php</code> that is the error, but I'm scratching my head about it. Relative newbie so I'm sure it's obvious!</p> <p><strong>db-connect.php</strong></p> <pre><code>&lt;?php $db = mysql_connect("localhost:3306","root",""); if (!$db) { die('Could not connect to db: ' . mysql_error()); } mysql_select_db("test",$db); $result = mysql_query("select * from cal", $db); $json_response = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $row_array['id'] = $row['id']; $row_array['title'] = $row['title']; $row_array['start'] = $row['start']; $row_array['end'] = $row['end']; array_push($json_response,$row_array); } echo json_encode($json_response); mysql_close($db); ?&gt; </code></pre> <p><strong>get-events.php</strong></p> <pre><code>&lt;?php // Require our Event class and datetime utilities require dirname(__FILE__) . '/utils.php'; if (!isset($_GET['start']) || !isset($_GET['end'])) { die("Please provide a date range."); } $range_start = parseDateTime($_GET['start']); $range_end = parseDateTime($_GET['end']); $timezone = null; if (isset($_GET['timezone'])) { $timezone = new DateTimeZone($_GET['timezone']); } $json = file_get_contents(dirname(__FILE__) . '/db-connect.php'); $input_arrays = json_decode($json, true); $output_arrays = array(); if (is_array($input_arrays) || is_object($input_arrays)) { foreach ($input_arrays as $array) { $event = new Event($array, $timezone); if ($event-&gt;isWithinDayRange($range_start, $range_end)) { $output_arrays[] = $event-&gt;toArray(); } } } echo json_encode($output_arrays); </code></pre>
4,081,286
0
<p>The <code>DefaultControllerFactory</code> will indeed instantiate and destroy the controller instance for each request. (You can <a href="http://aspnet.codeplex.com/SourceControl/changeset/view/23011#266459" rel="nofollow">browse the source yourself</a>, or see Dino Esposito's article <a href="http://dotnetslackers.com/articles/aspnet/Inside-the-ASP-NET-MVC-Controller-Factory.aspx" rel="nofollow">Inside the ASP.NET MVC Controller Factory</a> for a tour.)</p>
17,610,542
0
<p>In order to be able to use DMA, the buffers should be in page-locked memory. AMD and NVIDIA state in their programming guide that to have a buffer in page-locked memory it should be created with the CL_MEM_ALLOC_HOST_PTR flag. Here is what NVIDIA says in the section 3.3.1 of its <a href="http://hpc.oit.uci.edu/nvidia-doc/sdk-cuda-doc/OpenCL/doc/OpenCL_Programming_Guide.pdf" rel="nofollow">guide:</a></p> <blockquote> <p>OpenCL applications do not have direct control over whether memory objects are allocated in page-locked memory or not, but they can create objects using the CL_MEM_ALLOC_HOST_PTR flag and such objects are <strong>likely</strong> to be allocated in page-locked memory by the driver for best performance.</p> </blockquote> <p>Note the "likely" in bold. </p> <p>Which OS? NVIDIA doesn't speak about the OS so any OS NVIDIA provides drivers for (the same for AMD). <br/>Which Hardware? Any having DMA controller I guess.</p> <p>Now to write only a part of a buffer you could have a look to the <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueWriteBufferRect.html" rel="nofollow">function</a>:</p> <pre><code>clEnqueueWriteBufferRect() </code></pre> <p>This function allow to write to a 2 or 3D region of a buffer. Another possibility would be to use sub buffers creating them with the <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateSubBuffer.html" rel="nofollow">function</a>: </p> <pre><code>clCreateSubBuffer() </code></pre> <p>However there is no notion of 2D buffer with it.</p>
5,116,714
0
Egit ssh changes push & pull <p>In my office Eclipse is being used popularly and I have newly installed <code>GIT</code> and <code>Egit</code> plugin for Eclipse.<br> I'm not CVCS or DVCS user and I'm asked to install and configure Egit.<br> I could able to clone a remote projects <strong>Graphically</strong> with Egit between Ubuntu desktop systems.<br> Where I'm failing to understand is, when ever I create any folder/file under the project or update the project and after pulling (<code>R.C on project&gt;Team&gt;Pull</code>) or pushing (<code>R.C on project&gt;Team&gt;Remote&gt;Push</code>) it's says <code>Up-to-date</code>, but I could not see any newly created folders/files or updated files on the another computer.</p> <p>What's the proper way of doing push and pull after cloning the repo with Egit?<br> I'm trying in this way:</p> <ul> <li><p>Updated a project on a computer</p></li> <li><p>Did R.C on project<code>&gt;Team&gt;Add</code> and <code>Team&gt;Commit</code></p></li> <li><p>Went to Remote computer and did R.C on project><code>Team&gt;Pull</code> and got the prompt Up-to-date </p></li> <li><p>I did <code>Team&gt;Add</code> and <code>Team&gt;Commit</code> on this remote computer but I didn't see the changes which is made on the source computer.</p></li> </ul> <p>Please don't scold me as I've no much knowledge.<br> How do I do proper push and pull between two computers with Egit?.</p>
22,412,698
0
Optimizing hand-evaluation algorithm for Poker-Monte-Carlo-Simulation <p>I've written an equilator for Hold'em Poker as a hobbyproject. It works correctly, but there is still one thing I am not happy with: In the whole process of simulating hands, the process of evaluating the hands takes about 35% of the time. That seems to be pretty much to me compared with what else has to be done like iterating through and cloning large arrays and stuff.</p> <p>Any idea of how to get this more performant would be great.</p> <p>This is the code:</p> <pre><code> private static int getHandvalue(List&lt;Card&gt; sCards) { // --- Auf Straight / Straight Flush prüfen --- if ((sCards[0].Value - 1 == sCards[1].Value) &amp;&amp; (sCards[1].Value - 1 == sCards[2].Value) &amp;&amp; (sCards[2].Value - 1 == sCards[3].Value) &amp;&amp; (sCards[3].Value - 1 == sCards[4].Value)) { if ((sCards[0].Color == sCards[1].Color) &amp;&amp; (sCards[1].Color == sCards[2].Color) &amp;&amp; (sCards[2].Color == sCards[3].Color) &amp;&amp; (sCards[3].Color == sCards[4].Color)) return (8 &lt;&lt; 20) + (byte)sCards[0].Value; // Höchste Karte Kicker else return (4 &lt;&lt; 20) + (byte)sCards[0].Value; // Höchste Karte Kicker (Straight) } // --- Auf Wheel / Wheel Flush prüfen --- if ((sCards[4].Value == Card.CardValue.Two) &amp;&amp; (sCards[3].Value == Card.CardValue.Three) &amp;&amp; (sCards[2].Value == Card.CardValue.Four) &amp;&amp; (sCards[1].Value == Card.CardValue.Five) &amp;&amp; (sCards[0].Value == Card.CardValue.Ace)) { if ((sCards[0].Color == sCards[1].Color) &amp;&amp; (sCards[1].Color == sCards[2].Color) &amp;&amp; (sCards[2].Color == sCards[3].Color) &amp;&amp; (sCards[3].Color == sCards[4].Color)) return(8 &lt;&lt; 20) + (byte)sCards[1].Value; // Zweithöchste Karte Kicker else return(4 &lt;&lt; 20) + (byte)sCards[1].Value; // Zweithöchste Karte Kicker (Straight) } // --- Auf Flush prüfen --- if ((sCards[0].Color == sCards[1].Color) &amp;&amp; (sCards[1].Color == sCards[2].Color) &amp;&amp; (sCards[2].Color == sCards[3].Color) &amp;&amp; (sCards[3].Color == sCards[4].Color)) return (5 &lt;&lt; 20) + ((byte)sCards[0].Value &lt;&lt; 16) + ((byte)sCards[1].Value &lt;&lt; 12) + ((byte)sCards[2].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[4].Value; // --- Auf Vierling prüfen --- if (((sCards[0].Value == sCards[1].Value) &amp;&amp; (sCards[1].Value == sCards[2].Value) &amp;&amp; (sCards[2].Value == sCards[3].Value)) || ((sCards[1].Value == sCards[2].Value) &amp;&amp; (sCards[2].Value == sCards[3].Value) &amp;&amp; (sCards[3].Value == sCards[4].Value))) return (7 &lt;&lt; 20) + (byte)sCards[1].Value; // Wert des Vierlings (keine Kicker, da nicht mehrere Spieler den selben Vierling haben können) // --- Auf Full-House / Drilling prüfen --- // Drilling vorne if ((sCards[0].Value == sCards[1].Value) &amp;&amp; (sCards[1].Value == sCards[2].Value)) { // Full House if (sCards[3].Value == sCards[4].Value) return (6 &lt;&lt; 20) + ((byte)sCards[0].Value &lt;&lt; 4) + (byte)sCards[3].Value; // Drilling (höher bewerten) // Drilling return (3 &lt;&lt; 20) + ((byte)sCards[0].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[4].Value; // Drilling + Kicker 1 + Kicker 2 } // Drilling hinten if ((sCards[2].Value == sCards[3].Value) &amp;&amp; (sCards[3].Value == sCards[4].Value)) { // Full House if (sCards[0].Value == sCards[1].Value) return (6 &lt;&lt; 20) + ((byte)sCards[2].Value &lt;&lt; 4) + (byte)sCards[0].Value; // Drilling (höher bewerten) // Drilling return (3 &lt;&lt; 20) + ((byte)sCards[2].Value &lt;&lt; 8) + ((byte)sCards[0].Value &lt;&lt; 4) + (byte)sCards[1].Value; // Drilling + Kicker 1 + Kicker 2 } // Drilling mitte if ((sCards[1].Value == sCards[2].Value) &amp;&amp; (sCards[2].Value == sCards[3].Value)) return (3 &lt;&lt; 20) + ((byte)sCards[1].Value &lt;&lt; 8) + ((byte)sCards[0].Value &lt;&lt; 4) + (byte)sCards[4].Value; // Drilling + Kicker 1 + Kicker 2 // --- Auf Zwei Paare prüfen --- // Erstes Paar vorne, zweites Paar mitte if ((sCards[0].Value == sCards[1].Value) &amp;&amp; (sCards[2].Value == sCards[3].Value)) return (2 &lt;&lt; 20) + ((byte)sCards[0].Value &lt;&lt; 8) + ((byte)sCards[2].Value &lt;&lt; 4) + (byte)sCards[4].Value; // Erstes Paar + Zweites Paar + Kicker // Erstes Paar vorne, zweites Paar hinten if ((sCards[0].Value == sCards[1].Value) &amp;&amp; (sCards[3].Value == sCards[4].Value)) return (2 &lt;&lt; 20) + ((byte)sCards[0].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[2].Value; // Erstes Paar + Zweites Paar + Kicker // Erstes Paar mitte, zweites Paar hinten if ((sCards[1].Value == sCards[2].Value) &amp;&amp; (sCards[3].Value == sCards[4].Value)) return (2 &lt;&lt; 20) + ((byte)sCards[1].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[0].Value; // Erstes Paar + Zweites Paar + Kicker // --- Auf Paar prüfen --- // Paar vorne if (sCards[0].Value == sCards[1].Value) return (1 &lt;&lt; 20) + ((byte)sCards[0].Value &lt;&lt; 12) + ((byte)sCards[2].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[4].Value; // Paar + Kicker 1 + Kicker 2 + Kicker 3 // Paar mitte-vorne if (sCards[1].Value == sCards[2].Value) return (1 &lt;&lt; 20) + ((byte)sCards[1].Value &lt;&lt; 12) + ((byte)sCards[0].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[4].Value; // Paar + Kicker 1 + Kicker 2 + Kicker 3 // Paar mitte-hinten if (sCards[2].Value == sCards[3].Value) return (1 &lt;&lt; 20) + ((byte)sCards[2].Value &lt;&lt; 12) + ((byte)sCards[0].Value &lt;&lt; 8) + ((byte)sCards[1].Value &lt;&lt; 4) + (byte)sCards[4].Value; // Paar + Kicker 1 + Kicker 2 + Kicker 3 // Paar hinten if (sCards[3].Value == sCards[4].Value) return (1 &lt;&lt; 20) + ((byte)sCards[3].Value &lt;&lt; 12) + ((byte)sCards[0].Value &lt;&lt; 8) + ((byte)sCards[1].Value &lt;&lt; 4) + (byte)sCards[2].Value; // Paar + Kicker 1 + Kicker 2 + Kicker 3 // --- High Card bleibt übrig --- return ((byte)sCards[0].Value &lt;&lt; 16) + ((byte)sCards[1].Value &lt;&lt; 12) + ((byte)sCards[2].Value &lt;&lt; 8) + ((byte)sCards[3].Value &lt;&lt; 4) + (byte)sCards[4].Value; // High Card + Kicker 1 + Kicker 2 + Kicker 3 + Kicker 4 } </code></pre> <p>This method returns an exact value for every sorted 5-Card-Combination in poker. It gets called by another method:</p> <pre><code> private static int getHandvalueList(List&lt;Card&gt; sCards) { int count = sCards.Count; if (count == 5) return getHandvalue(sCards); int HighestValue = 0; Card missingOne; int tempValue; for (int i = 0; i &lt; count - 1; i++) { missingOne = sCards[i]; sCards.RemoveAt(i); tempValue = getHandvalueList(sCards); if (tempValue &gt; HighestValue) HighestValue = tempValue; sCards.Insert(i, missingOne); } missingOne = sCards[count - 1]; sCards.RemoveAt(count - 1); tempValue = getHandvalueList(sCards); if (tempValue &gt; HighestValue) HighestValue = tempValue; sCards.Add(missingOne); return HighestValue; } </code></pre> <p>This recursive method returns the highest value of all possible 5-card-combinations. And this one gets called by the final public method:</p> <pre><code> public static int GetHandvalue(List&lt;Card&gt; sCards) { if (sCards.Count &lt; 5) return 0; sCards.Sort(new ICardComparer()); return getHandvalueList(sCards); } </code></pre> <p>It gets delivered a maximum of 7 cards.</p> <p><strong>Update</strong></p> <p>So far: Each time, the public function gets called with 7 cards (which is the case most of the time), it has to call the hand-evaluation method 21 times (one time for every possible 5-card-combo).</p> <p>I thought about caching the value for each possible set of 5 to 7 cards in a hashtable und just look it up. But if I am not wrong, it would have to store more than 133.784.560 32-bit-integer values, which is about 500MB.</p> <p>What could be good hashfunction to assign every possible combination to exactly one arrayindex?</p> <p>Created a new question on that: <a href="http://stackoverflow.com/questions/22477192/hashfunction-to-map-combinations-of-5-to-7-cards">Hashfunction to map combinations of 5 to 7 cards</a></p> <p>Update: For further improvement regarding the accepted answer, have alook at: <a href="http://stackoverflow.com/questions/39317649/efficient-way-to-randomly-select-set-bit">Efficient way to randomly select set bit</a></p>
27,426,305
0
Edmodo android image cropper, fix aspect ratio <p>I've some problem using edmodo/cropper library on android lollipop. My app should take some pictures, and after each picture is taken, user should crop a square image. this is my layout:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;com.example.newapicamera.AutoFitTextureView android:id="@+id/texture" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/footer" /&gt; &lt;com.edmodo.cropper.CropImageView xmlns:custom="http://schemas.android.com/apk/res-auto" android:id="@+id/CropImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/footer" android:visibility="invisible" /&gt; &lt;ImageView android:id="@+id/footer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:src="@drawable/footer" /&gt; &lt;TextView android:id="@+id/current_picture" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:textColor="#FFFFFF" android:textSize="30sp" /&gt; </code></pre> <p></p> <p>and this is how i launch library for crop after picture is taken;</p> <pre><code>crop_view.setImageBitmap(bitmap); mCameraDevice.close(); mTextureView.setVisibility(View.INVISIBLE); crop_view.setVisibility(View.VISIBLE); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); int dpWidth = displayMetrics.widthPixels; crop_view.setFixedAspectRatio(true); crop_view.setAspectRatio(dpWidth, dpWidth); </code></pre> <p>I have the sequent problem:</p> <ul> <li>with this code, the crop is a stripe high as screen</li> <li>if i remove fixed aspect ratio, the aspect ratio i've is ignored, and i obtain a rectangular crop. So, how can i do to force crop to a square?</li> </ul>
17,238,438
0
Simple SQL to Eloquent Query (Laravel) <p>I have two tables: users (Users) and groups (Groups).</p> <pre><code> Users ----------------- id | username | group 1 | Bob | 2 Groups ----------------- id | name 1 | firstgroup 2 | secondgroup </code></pre> <p>I would like to display: users.ID, users.username, group.name (1, Bob, secondgroup) An SQL statement like so would work:</p> <pre><code>SELECT Users.id, Users.username, Groups.name FROM Users INNER JOIN Groups ON Groups.id = Users.group </code></pre> <p>However, I'm struggling to write this in Eloquent, since there is no "FROM". At the moment I'm going for something along the lines of the below, using JOINS (<a href="http://laravel.com/docs/queries#joins" rel="nofollow">http://laravel.com/docs/queries#joins</a>)</p> <pre><code>$users = Users::select('id','username', 'Groups.name')-&gt;joins('Groups.id', '=', 'id')-&gt;get(); </code></pre> <p>Now this isn't working - I think the joins has to come before the select but I just can't work it out :(</p>
26,658,476
0
<p>The <code>ssl_protocol</code> parameter is part of the <code>Apache::Vhost</code> defined type. Not part of the <code>apache</code> class.</p> <p>You can set the defaults with the following:</p> <pre><code> Apache::Vhost { ssl_protocol =&gt; 'all -SSLv2 -SSLv3' } </code></pre> <p>Hope this helps.</p>
16,825,643
0
<p>did you try:</p> <pre><code>animation-direction:alternate; -webkit-animation-direction:alternate; /* Safari and Chrome */ </code></pre> <p>very nice effects BTW :)</p>
10,652,262
0
<p>Straight from Phonegap website -</p> <blockquote> <p>PhoneGap is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores.</p> </blockquote> <p>What this means is it is not browser dependent. The code compiles to native application. You don't need a browser to run it.</p>
17,192,485
0
<p>There have been numerous posts on here about trying to do OCR on camera generated images. The problem is not that the resolution is too low, but that its too high. I cannot find a link right now, but there was a question a year or so ago where in the end, if the image size was reduced by a factor of four or so, the OCR engine worked better. If you examine the image in Preview, what you want is the number of pixels per character to be say 16x16 or 32x32, not 256x256. Frankly I don't know the exact number but I'm sure you can research this and find posts from actual framework users telling you the best size.</p> <p><a href="http://stackoverflow.com/a/7775470/1633251">Here is a nice response</a> on how to best scale a large image (with a link to code).</p>
10,783,338
0
<p>You could add a Textbox for each message which would allow you to have more control over the positioning. But a non-clickable Listbox would be good too. in the end it's your artistic choice</p>
2,790,016
0
<p>The code language of classic ASP is VBScript, so you have to make do with the error handling capabilities of that language, by using the "On Error ..." construct. You need to decide on whether to make a general error handler or insert some specific error handling logic for the SQL calls.</p> <p>These are your options for error handling: </p> <pre><code>On Error Goto 0 ' Turns off error trapping. This is most likely what you got now On Error Resume Next ' In case of error, simply execute next statement. Not recommended ! On Error Goto &lt;label&gt; ' Go to the specified label on an Error. </code></pre> <p>If you use On Error Goto ..., The Err object will contain error information. This means you should be able to write somehting like:</p> <pre><code>On Error Goto errorHandler ' Your code here. errorHandler: ' Handle the error somehow. Perhaps log it and redirect to a prettier error page. Response.Write Err.Number Response.Write Err.Description </code></pre>
33,006,821
0
How to use caching mechanism in android for httprequest <p>I am working on an android application in which i want to use caching mechanism for httpurlrequest. I want to cache the response and want to use again for next request.</p> <p>So, in android how to cache the response and how to use it next time when we do the same request.</p> <p>Any working example would be great for me.</p> <p>How to check whether response is from cache or from server?</p> <p>How to check whether cache is available for the particular request.</p> <p>PS: there is no any support of cache from server side. i.e sever doesn't send any 'Cache-Control' header field in response.</p> <p>Thanks,</p>
18,195,600
0
<p>Seems you forgot to add the html code</p> <p>From the code you have provided, I can only assume you should write this:</p> <pre><code>if ( Image_Number &gt; 0 ) { $("html_item_that_contains_image").fadeOut(); document.my_imagearray.src = Image[Image_Number]; $("html_item_that_contains_image").fadeIn(); } </code></pre>
20,589,885
0
How to launch the normal function in jquery <p>I have some links to launch ajax.</p> <pre><code>&lt;a href="javascript:void(0)" onclick="artClick(1)"&gt;1&lt;/a&gt;&lt;br&gt; &lt;a href="javascript:void(0)" onclick="artClick(2)"&gt;2&lt;/a&gt;&lt;br&gt; &lt;a href="javascript:void(0)" onclick="artClick(3)"&gt;3&lt;/a&gt;&lt;br&gt; . . </code></pre> <p>These links are made by script so I cant use #id.</p> <p>my javascript is this </p> <pre><code>function artClick(id){ $.post(url, { id:id },function(data){ }); } </code></pre> <p>but it doesnt work. I think I should use</p> <pre><code>$(document).ready(function() { }); </code></pre> <p>But if I put the function in this,nothing changes.</p> <p>I want to know the good way to handle the multiple links and ajax.</p>
34,396,151
1
Place in a file from drop down list <p>How would you find out the position in a text file of an option selected from a drop down box? I have got a text file of different values stored on new lines. I then load this into an array which forms the values of a drop down box. I would like to know the line position of the value selected by the user. My code so far is included below. </p> <pre><code>from tkinter import * class search(): def __init__ (self, master): self.master = master self.master.title("Search For Quotes Screen") self.master.geometry("2100x1400") self.master.configure(background = 'white') self.master.configure(background = "white") self.Title = Label(self.master, text = "Quote Retrieval", font = ("calibri", 20), bg = "White") self.Title.place(x=650, y = 10) array=[]#initialises array with open('PostCode_File.txt', 'r') as f:# opens name of your file array= [line.strip() for line in f]#puts values of file in array. each line = one part of array f.close() Option = StringVar() Option.set("Please select postcode of quote") self.options = OptionMenu(self.master, Option, *array)#creates drop down menu self.options.config(bg = 'navy', fg='white', font =('calibri', 20)) self.options["menu"].config(bg="Navy", font=('calibri', 13), fg= 'white') self.options.place(x=100, y=100) print( self.options.get()) </code></pre> <p>I have noticed a drop down box doesn't have the function like a text entry box or maybe im using it wrong. Any help would be appreciated. </p>
4,615,607
0
<p>Famous <a href="http://www.bitstorm.org/gameoflife/" rel="nofollow">Game of Life</a> seems to be a good idea. Cells are persistence units, JSF, web beans + ejb to display the working area, scheduled beans - to put it in motion. Game's logic can be implemented in EJB or JMS (or even both). You could extend original logic, introduce new objects or rules and finally get Nobel prize for achievements in social modeling :)</p>
4,552,355
0
How can we get unique elements from any ORDER BY DECREASING OR INCREASING <p>Code given below is taken from the stackoverflow.com !!! Can anyone tell me how to get the array elements order by decreaseing or increasing !! plz help me !!! Thanks in advance</p> <pre><code>$contents = file_get_contents($htmlurl); // Get rid of style, script etc $search = array('@&lt;script[^&gt;]*?&gt;.*?&lt;/script&gt;@si', // Strip out javascript '@&lt;head&gt;.*?&lt;/head&gt;@siU', // Lose the head section '@&lt;style[^&gt;]*?&gt;.*?&lt;/style&gt;@siU', // Strip style tags properly '@&lt;![\s\S]*?--[ \t\n\r]*&gt;@' // Strip multi-line comments including CDATA ); $contents = preg_replace($search, '', $contents); $result = array_count_values( str_word_count( strip_tags($contents), 1 ) ); print_r($result); </code></pre>
741,437
0
<p>Add @Key(types=String.class) @Value(types=String.class)</p> <p>since "Properties" is a bit of a hack in that it can also contain non-String, and doesn't allow generic specification so you need to restrict it. The next version of AppEngine will have a version of DataNucleus that doesn't require this additional info.</p>
14,933,797
0
ASP.NET Web Forms (4.5) Strongly Typed Model Binding - DropDownList in InsertItemTemplate of ListView <p><strong>Note: This is ASP.NET Web Forms Model Binding in .NET 4.5 and NOT MVC.</strong></p> <p>I am using the new Strongly Typed Model Binding features of ASP.NET Web Forms (4.5) to produce a list of items that can be edited. This is working fine for viewing the initial list, editing an item and deleting an item. I am however having a problem with the insertion of a new item.</p> <p>Specifically, within my EditItemTemplate and InsertItemTemplate I have a DropDownList (well, actually it is a custom control derived from DropDownList but for the purposes of this question it is a DropDownList). The control is defined within the markup as follows...</p> <pre><code>&lt;agp:ClientStatusDropDownList ID="ClientStatusID" runat="server" SelectedValue="&lt;%#: BindItem.ClientStatusID %&gt;" /&gt; </code></pre> <p>Within the EditItemTemplate, this is fine however within the InsertItemTemplate this generates an error upon running the page: <em>Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.</em></p> <p>As such, I removed the section <code>SelectedValue="&lt;%#: BindItem.ClientStatusID %&gt;"</code> from the InsertItemTemplate and tried again. This time no error message, however when the <code>ListView.InsertMethod</code> is called, the ClientStatusID property on the model is not set to the value of the DropDownList (whereas the rest of the properties are set correctly).</p> <p>The ListView.InsertMethod:</p> <pre><code>public void ListView_InsertMethod(int ID) { Model model = this.DbContext.Models.Create(); if (this.TryUpdateModel(model)) { this.DbContext.SaveChanges(); this.ListView.DataBind(); } } </code></pre> <p>The Model class:</p> <pre><code>public class Model{ public Int32 ID { get; set; } public String Description { get; set; } public Boolean IsScheduleFollowUp { get; set; } public Nullable&lt;Int32&gt; ClientStatusID { get; set; } } </code></pre> <p>The EditItemTemplate:</p> <pre><code>&lt;EditItemTemplate&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:TextBox ID="Description" runat="server" Text="&lt;%#: BindItem.Description %&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:CheckBox ID="IsScheduleFollowUp" runat="server" Checked="&lt;%# BindItem.IsScheduleFollowUp %&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;agp:ClientStatusDropDownList ID="ClientStatusID" runat="server" SelectedValue="&lt;%#: BindItem.ClientStatusID %&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Button ID="Update" runat="server" ClientIDMode="Static" CommandName="Update" Text="Update" /&gt; &lt;asp:Button ID="Cancel" runat="server" ClientIDMode="Static" CommandName="Cancel" Text="Cancel" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/EditItemTemplate&gt; </code></pre> <p>The InsertItemTemplate:</p> <pre><code>&lt;InsertItemTemplate&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:TextBox ID="Description" runat="server" Text="&lt;%#: BindItem.Description %&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:CheckBox ID="IsScheduleFollowUp" runat="server" Checked="&lt;%# BindItem.IsScheduleFollowUp %&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;agp:ClientStatusDropDownList ID="ClientStatusID" runat="server" /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:Button ID="Insert" runat="server" ClientIDMode="Static" CommandName="Insert" Text="Add" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/InsertItemTemplate&gt; </code></pre> <p>I had originally thought that it was the ID of the control that was used to determine the property on the model that the value would be passed to (i.e. where the TextBox was called "Description", the value would be passed to the "Description" property of the model). Clearly this is not the case and it is instead controlled by the "&lt;%# BindItem.Description %>", however as you can see from the rest of this question I am unable to use this syntax in the "InsertItemTemplate". I cannot believe that the DropDownList is not supported in this scenario, but I cannot find any examples of a DropDownList being used with the 4.5 model bindings using Google or Bing (in fact, there are very few examples of the new model binding in ASP.NET 4.5 using anything other than a couple of TextBox controls).</p> <p>Can anybody shed any further light on the issue (and preferably tell me what needs to be done)?</p> <p>Other questions on SO that I have looked at...</p> <ul> <li><a href="http://stackoverflow.com/questions/470315/binding-a-dropdownlist-in-listview-insertitemtemplate-throwing-an-error">Binding a DropDownList in ListView InsertItemTemplate throwing an error</a></li> <li><a href="http://stackoverflow.com/questions/2184757/asp-net-listview-with-identical-markup-in-edititemtemplate-and-insertitemtemplat">ASP.NET ListView with identical markup in EditItemTemplate and InsertItemTemplate</a></li> <li><a href="http://stackoverflow.com/questions/2265852/bind-selectedvalue-of-asp-net-dropdownlist-to-custom-object">Bind SelectedValue of ASP.net DropDownList to custom object</a></li> <li><a href="http://stackoverflow.com/questions/3785021/databinding-to-asp-net-dropdownlist-list-in-listview">Databinding to ASP.NET DropDownList list in ListView</a></li> </ul> <p>All of these use the older style binding methods and not the new methods in 4.5</p> <p>Thanks.</p>
16,084,574
0
<p>This is not a very good question for StackOverflow; it's better for one of the math sites. But I'll answer it here anyways.</p> <p>You certainly can do better than brute force, as you are doing here. You should be able to compute the answer in a few microseconds.</p> <p>There exists a solution if and only if the <em>greatest common divisor</em> of (A, B, C, D) divides K evenly. That's the extended form of <em>Bézout's identity</em>.</p> <p>In order to determine (1) what the gcd is and (2) what the values for p, q, r, s are, you use the <em>Extended Euclidean Algorithm</em>, which you can read about here:</p> <p><a href="http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm" rel="nofollow">http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm</a></p> <p>My advice is to first write a program that solves simple linear Diophantine equations of the form <code>ax + by = c</code>. Once you've done that, then read the section of that Wikipedia article called "The case of more than two numbers", which describes how to extend the algorithm to handle your case.</p>
18,055,468
0
update value simultaneously to table using MVC ajax async <p>I want to update values to sql table from queue simultaneously using Ajax async. It's not working for me. </p> <p>My code </p> <pre><code> function ProcessQueue() { $.ajax({ url: '@Url.Action("process", "MyAccount")', type: 'GET', dataType: 'html', async: true, }); setTimeout(function () { ProcessQueue(); }, 900); } </code></pre> <p>Controller :</p> <pre><code> public void process() { for (int i = 0; i &lt; 10; i++) { calling table update function here. .... } } </code></pre> <p>Thanks </p>
6,791,287
0
<p><code>header</code> statements will not work if there is any output before they are called. In this case, your <code>echo</code>s are killing it. Also, make sure there is no other output before this is called (white space, HTML, etc.).</p>
804,551
0
<p>Boolean is a value type, so it will always have a value. [Required] therefore has no real effect. What happens if you use a Nullable&lt;bool&gt; instead? This should allow MVC to assign a null value if the first option is selected, and the Required attribute can then assert that the user did in fact select a value.</p>
6,207,907
0
What are possible causes for differing behaviors in jsFiddle and in local context <p>Upon invsetigating 'mu is too short's answer to <a href="http://stackoverflow.com/questions/6206985/what-can-make-jquerys-unbind-function-not-work-as-expected" title="this question">this question</a>, I noticed that I get different behaviour in jsFiddle than in my local context for the exact same script. Any clues as to why that is?</p> <p>Note: I am not getting any javascript errors in Firefox's error console in the local context.</p> <p><strong>UPDATE</strong>: I tried grabbing the HTML from <a href="http://fiddle.jshell.net/ambiguous/ZEx6M/1/show/light" rel="nofollow">fiddle.jshell.net/ambiguous/ZEx6M/1/show/light</a> to a local file and loading that local file in Chromium browser and I got the following errors in the javascript console:</p> <ul> <li><code>GET file:///css/normalize.css undefined (undefined) /css/normalize.css</code></li> <li><code>GET file:///css/result-light.css undefined (undefined) /css/result-light.css</code></li> <li><code>Resource interpreted as Script but transferred with MIME type application/empty jquery.scrollTo-1.4.2.js:-1</code></li> <li><code>Resource interpreted as Script but transferred with MIME type text/plain jquery.viewport.js:-1</code></li> </ul> <p>I can get rid of these javascript errors by downloading the files and modifying the <code>&lt;script&gt;</code> tags, but it doesn't solve the problem. The page still scrolls down to the very bottom. Also these errors appear even in the working (jsFiddle) version.</p> <p>I also tried the same process in Konqueror. Result: the script does absolutely nothing.</p>
31,629,117
0
<pre><code>def combinations(ary1, ary2) ary1.map {|i| ary2.map {|i2| "#{i}#{i2}" }}.flatten end </code></pre>
32,793,474
0
PHP Why does this work? <p>Specifically speaking, why does the below code work (outputs "test").</p> <pre><code>&lt;? $variable = 'test'; ?&gt; &lt;?=$variable?&gt; </code></pre> <p>Is this hacky, or functionality?</p>
36,696,169
0
sitecore installation wizard could not install some content <p>I would like to ask you if someone has similar problem. I am using Sitecore.NET 7.2 (rev. 151021) with Solr. I need to add some items from prod to my local sitecore instance. When I create package and tried to install specific content I get exception null reference exception. It doesnt depend on the content. I tried to used package designer with varios content and always I get this exception.</p> <p><a href="https://i.stack.imgur.com/pXvvo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pXvvo.png" alt="enter image description here"></a></p>
7,426,257
0
<p>Task Manager is one way to do it. I prefer <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653" rel="nofollow">Process Explorer</a> because it gives a lot more info than Task Manager.</p>
902,480
0
Error parsing .dae,Error#1009 in flash player,Augmented Reality flash <p>Whenever I am trying to use an animate.dae file(I am creating small project using flartoolkit+papervision3d+ascollada) .The flash player is reporting me the errors pasted below.If I am pressing continue then I can see my .dae file but without animation :( And Please note that I am not using any heavy animation.</p> <p>ERROR:</p> <p>TypeError: Error #1009: Cannot access a property or method of a null object reference.</p> <p>at org.papervision3d.objects.parsers::DAE/buildAnimationChannels()[C:..\org\papervision3d\objects\parsers\DAE.as:657]</p> <p>at org.papervision3d.objects.parsers::DAE/onParseAnimationsComplete()[C:..\org\papervision3d\objects\parsers\DAE.as:1722]</p> <p>at flash.events::EventDispatcher/dispatchEventFunction()</p> <p>at flash.events::EventDispatcher/dispatchEvent()</p> <p>at org.ascollada.io::DaeReader/loadNextAnimation()[C:..\Libs\org\ascollada\io\DaeReader.as:169]</p> <p>at flash.utils::Timer/_timerDispatch()</p> <p>at flash.utils::Timer/tick()</p>
40,773,611
0
<p>The output of <code>resize</code> has a dtype of float, hence it is in the 0-1 range. You can convert your image back to uint8 range with:</p> <pre><code>from skimage import img_as_ubyte image = img_as_ubyte(image) </code></pre> <p>Please see the <a href="http://scikit-image.org/docs/dev/user_guide/data_types.html" rel="nofollow noreferrer">user guide</a> for a full description of data types and their ranges.</p>
465,467
0
<p>I don't believe it's possible to achieve what you'd like here. From the comments in your code it looks like you are attempting to capture the name of the property which did the assignment in MethodThatTakesExpression. This requires an expression tree lambda expression which captures the contexnt of the property access. </p> <p>At the point you pass a delegate into MethodThatTakesDelegate this context is lost. Delegates only store a method address not any context about the method information. Once this conversion is made it's not possible to get it back. </p> <p>An example of why this is not possible is that there might not even be a named method backing a delegate. It's possible to use ReflectionEmit to generate a method which has no name whatsoever and only exists in memory. It is possible though to assign this out to a Func object. </p>
3,735,617
0
<p>The <a href="http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22" rel="nofollow noreferrer">documentation</a> for the Optimize command specifies that, by default, the command will block until all changes are written to disk and that the new searcher is available. So if you keep those default values, when the command returns, you can consider the optimize done. Note that, depending on the number of segments you currently have and to how many you want to go down to, the command can block for a long time. I have seen optimize taking up to an hour to complete. </p>
25,442,455
0
Sencha Touch Ext.js Codes in Html Page <p>How to use ext codes in html pages ? </p> <p>Defined this :</p> <pre><code> var Ext = Ext || {}; var msg=new Ext.Msg(); Ext.Msg.alert("Something","Something"); </code></pre> <p>but Ext.Msg.alert doesnt work , throwing " undefined is not a function " error in console.</p>
15,084,601
0
<p>easiest way:</p> <pre><code>(@id in xmlIn) </code></pre> <p>this will return true if id attrtibute exists and false otherwise.</p>
2,480,477
0
<blockquote> <p><em>Is there a way to override java.io.File to perform the file path translation with custom code? In this case, I would translate the remote paths to a mount point</em></p> </blockquote> <p>Yes, you can perform your own implementation of <code>java.io.File</code> and place it in a separate jar and then load it instead of the real <code>java.io.File</code>.</p> <p>To have the JVM load it you can either use the <code>java.endorsed.dirs</code> property or <code>java -Xbootclasspath/p:path</code> option in the java launcher ( java ) </p> <p><strong>BUT!!!</strong> </p> <p>Creating your own version of the <code>java.io.File</code> class won't be as easy as modifying the legacy source code. </p> <p>If you're afraid of breaking something you could first extract all your hardcoded paths to use a resource bundle:</p> <p>So:</p> <pre><code> File file = new File("C:\\Users\\oreyes\\etc.txt"); </code></pre> <p>Would be:</p> <pre><code>File file = new File( Paths.get( "user.dir.etc" )); </code></pre> <p>And <code>Paths</code> would have a resource bundle internally</p> <pre><code>class Paths { private static ResourceBundle rs = ResourceBundle.getBundle("file.paths"); public static String get( String key ) { rs.getString( key ); } } </code></pre> <p>You can have all this hardcoded paths extraction with an IDE ( usually an internationalization plugin ) </p> <p>Provide a different resource bundle for Linux and your done. Test and re-test and re-test</p> <p>So, use provide your own <code>java.io.File</code> only as a last resource. </p>
35,853,284
0
How to extract just the date portion from a time in Rails? <p>I have the following piece of code currently in my view.</p> <p><strong>display.html.erb</strong></p> <pre><code>&lt;% @total_sales_volume.each do |record| %&gt; &lt;%= record.transaction_date %&gt; &lt;% end %&gt; </code></pre> <p>What gets displayed currently: <code>2016-02-23 00:00:00 UTC</code></p> <p>What I want to display: <code>2016-02-23</code></p>
18,670,565
1
Why __init__ in python fail <p>I'm using python2.7 to define a function like this</p> <pre><code>def foo(*args, **kwargs): print 'args = ', args print 'kwargs = ', kwargs print '---------------------------------------' </code></pre> <p>and by calling foo(3), the output is as the following:</p> <pre><code>args = (3,) kwargs = {} </code></pre> <p>which is desired.</p> <p>But as for <code>__init__</code> function in a class in which the parameters are the same form as foo, I can't instantize the class Person by invoking <code>Person(3)</code></p> <pre><code>def Person(): def __init__(self, *args, **kwargs): print args print kwargs x = Person(3) </code></pre> <p>The output is</p> <pre><code> x = Person(3) TypeError: Person() takes no arguments (1 given) </code></pre> <p>That confused me a lot, have I missed something?</p>
36,102,749
0
<p>Have you scanned for peripheral with the services, code below:</p> <pre><code>NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil]; [self.bluetoothManager scanForPeripheralsWithServices:nil options:options]; </code></pre>
2,265,360
0
Where does the iPhone Simulator store the installed applications? <p>I want to have a look at the app directory from the iPhone Simulator, so that I can see what kind of files it is creating when I use my app and what stuff is in these files (i.e. when it creates the sqlite file for Core Data and stuff like that).</p>
8,365,346
0
Why does this Parallel.ForEach code freeze the program up? <p>More newbie questions: </p> <p>This code grabs a number of proxies from the list in the main window (I couldn't figure out how to make variables be available between different functions) and does a check on each one (simple httpwebrequest) and then adds them to a list called finishedProxies.</p> <p>For some reason when I press the start button, the whole program hangs up. I was under the impression that Parallel creates separate threads for each action leaving the UI thread alone so that it's responsive?</p> <pre><code>private void start_Click(object sender, RoutedEventArgs e) { // Populate a list of proxies List&lt;string&gt; proxies = new List&lt;string&gt;(); List&lt;string&gt; finishedProxies = new List&lt;string&gt;(); foreach (string proxy in proxiesList.Items) { proxies.Add(proxy); } Parallel.ForEach&lt;string&gt;(proxies, (i) =&gt; { string checkResult; checkResult = checkProxy(i); finishedProxies.Add(checkResult); // update ui /* status.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate() { status.Content = "hello" + checkResult; } )); */ // update ui finished //Console.WriteLine("[{0}] F({1}) = {2}", Thread.CurrentThread.Name, i, CalculateFibonacciNumber(i)); }); } </code></pre> <p>I've tried using the code that's commented out to make changes to the UI inside the Parallel.Foreach and it makes the program freeze after the start button is pressed. It's worked for me before but I used Thread class.</p> <p>How can I update the UI from inside the Parallel.Foreach and how do I make Parallel.Foreach work so that it doesn't make the UI freeze up while it's working?</p> <p><a href="http://pastie.org/2958219">Here's the whole code.</a></p>
3,883,227
0
<p>There are several problems you need to address — both in your code and both in your current knowledge :-) Start with this:</p> <ol> <li><p>Read a few articles about ASP.NET's page life-cycle, so you become more familiar with what to do in each life-cycle event handler (<code>OnInit</code>, <code>OnLoad</code>, …). Good starting point might be this <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="nofollow">MSDN overview</a>. However, google for “ASP.NET page life cycle” and read a few other articles and examples as well.</p> <p>Also, you will need to get familiar with the request-response nature of ASP.NET page processing. In the beginning, bear in mind that when the user hits some 'Submit' button which in turn causes an HTTP POST request to occur, you are responsible to creating the page's control tree to match its structure, IDs, etc. as they were in the previous request. Otherwise ASP.NET doesn't know how in which controls to bind the data the user filled-in.</p></li> <li><p>Near the line tagged <code>//Lost and confused here :/</code> you are creating a new control and immediately querying it for the 'results' (which I expect to be values of some edit boxes within it). This cannot work, because it's most probably too early for the form to have the data received from the <code>Page</code> object that drives the request processing.</p></li> <li><p>Your <code>Results</code> property is poorly designed. First, you shouldn't be using properties that actually 'generate' data in such a way they can change without notice. Properties shall be used as “smart fields”, otherwise you end up with less manageable and less readable code. Second, the setter you left there like “set;” causes any value assigned into the property to be actually lost, because there's no way to retrieve it. While in some rare cases this behavior may be intentional, in your case I guess it's just an error.</p></li> </ol> <p>So, while you can currently leave behind any “good OOP way” to approach your problem, you certainly should get more familiar with the page life-cycle. Understanding it really requires some thinking about the principles how ASP.NET web applications are supposed to work, but I'm sure it will provide you with the kick forward you actually need.</p> <p><strong>UPDATE:</strong> In respect to Tony's code (see comments) the following shall be done to move the code forward:</p> <ol> <li><p>The list of form data in the <code>requestForm</code> property shall have tuple of [form ASCX path, control ID, the actual <code>RequestForm</code> data class]</p></li> <li><p><code>GatherForms</code> shall be called only when the page is initially loaded (i.e. <code>if (Page.IsPostBack)</code>) and it shall fill <code>requestForm</code> with the respective tuples for available ASCX forms.</p></li> <li><p>Both <code>chklApplications</code> and wizard steps shall be created in <code>LoadForms</code> on the basis of <code>requestForm</code>'s content.</p></li> <li><p>When results are to be gathered, the ID stored in the respective <code>requestForm</code> entry can be used to look-up the actual user control.</p></li> </ol>
2,102,395
0
<p>This is a specification. </p> <p><a href="http://www.hanselman.com/blog/ASPNETMVCBetaReleasedCoolnessEnsues.aspx" rel="nofollow noreferrer" title="Scott Hanselman&#39;s Computer Zen - ASP.NET MVC Beta released - Coolness Ensues">Scott Hanselman's Computer Zen - ASP.NET MVC Beta released - Coolness Ensues</a></p> <p>This is V1 RTW base model binder sample code.</p> <p>1.Make custom model binder.</p> <pre><code>using System.Web.Mvc; namespace Web { public class HttpPostedFileBaseModelBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var bind = new PostedFileModel(); var bindKey = (string.IsNullOrEmpty(bindingContext.ModelName) ? "" : bindingContext.ModelName + ".") + "PostedFile"; bind.PostedFile = controllerContext.HttpContext.Request.Files[bindKey]; return bind; } } } </code></pre> <p>2.Create model class.</p> <pre><code>using System.Web; namespace Web { public class PostedFileModel { public HttpPostedFileBase PostedFile { get; set; } } } </code></pre> <p>3.Entry model binder in global.asax.cs.</p> <pre><code>protected void Application_Start() { RegisterRoutes(RouteTable.Routes); ModelBinders.Binders[typeof(PostedFileModel)] = new HttpPostedFileBaseModelBinder(); } </code></pre>
6,953,923
0
<p>You don't have to convert it to integer. You can check it from the string.</p> <p>Take the first character and the last character compare those .</p> <p>Iterate the first pointer +1 and the last pointer -1 then compare.</p> <p>Continue this process upto you are in middle of the string.</p>
18,865,083
0
<p>You can run my demo code and see what the error means.</p> <p>When you loop over an array and expect to call a method you need to validate that it exists, first.</p> <pre><code>var arr = [0, {test: function(){}}]; // the error - Uncaught TypeError: Object 0 has no method 'test' //arr.forEach(function(e) { // e.test(); //}); // the right way arr.forEach(function(e) { if (e &amp;&amp; e.test) { e.test(); } else { console.log("no valid element or no support for method 'test'"); } }); </code></pre>
40,817,934
0
why dose my app in android shows wrong size of External memory? <p>i want to get size of External memory in my app. my code doesn't work properly because i have 16 Gb External Memory size but my app shows me 5 GB :</p> <pre><code>import android.os.Environment; import android.os.StatFs; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import java.io.File; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getTotalExternalMemorySize(); } public boolean externalMemoryAvailable() { return android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED); } public void getTotalExternalMemorySize() { TextView textView= (TextView) findViewById(R.id.ExternalSize); if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSizeLong(); long totalBlocks = stat.getBlockCountLong(); textView.setText(String.valueOf(totalBlocks * blockSize/1073741824)); //1073741824 to convert to GB }else{ textView.setText("There is no External memory"); } } } </code></pre> <p>i don't know why, i will appreciate to show me what's wrong?</p>
23,061,804
0
Optimizing MySQL self-join query <p>I have following query:</p> <pre><code>SELECT DISTINCT(a1.actor) FROM actions a1 JOIN actions a2 ON a1.ip = a2.ip WHERE a2.actor = 143 AND a2.ip != '0.0.0.0' AND a2.ip != '' AND a2.actor != a1.actor AND a1.actor != 0 </code></pre> <p>This is the explain of the query:</p> <pre><code>+----+-------------+-------+-------+------------------+---------+---------+------------------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+------------------+---------+---------+------------------+------+--------------------------+ | 1 | SIMPLE | a2 | range | actor,ip,actorIp | actorIp | 66 | NULL | 3800 | Using where; Using index | | 1 | SIMPLE | a1 | ref | ip | ip | 62 | formabilio.a2.ip | 11 | Using where | +----+-------------+-------+-------+------------------+---------+---------+------------------+------+--------------------------+ </code></pre> <p>Even if from this it doesn't seem a problematic query, in my machine it takes more or less 69 seconds with MyIsam and 56 seconds in InnoDB. The table has more or less 1 thousand records. As you can see from the explain I have indeces both on the actor column, on the ip column and even on both columns. I have mysql version 5.5.35.</p> <p>Do you have any idea on why this query takes so long? How can I optimize it?</p>
1,283,377
0
<p>In this specific case, it is going to work because the string in <code>buffer</code> will be the first thing that is going to enter in <code>buffer</code> (again, useless), so you should use <code>strcat()</code> instead to get the [almost] same effect.</p> <p>But, if you are trying to combine <code>strcat()</code> with the formating possibilities of <code>sprintf()</code>, you may try this:</p> <pre><code>sprintf(&buffer[strlen(buffer)], " &lt;input type='file' name='%s' /&gt;\r\n", id);</code></pre>
4,071,677
0
<p>There are wrappers to inotify that make it easy to use from high-level languages. For example, in ruby you can do the following with <a href="http://github.com/nex3/rb-inotify" rel="nofollow">rb-inotify</a>:</p> <pre><code>notifier = INotify::Notifier.new # tell it what to watch notifier.watch("path/to/foo.txt", :modify) {puts "foo.txt was modified!"} notifier.watch("path/to/bar", :moved_to, :create) do |event| puts "#{event.name} is now in path/to/bar!" end </code></pre> <p>There's also <a href="http://pyinotify.sourceforge.net/" rel="nofollow">pyinotify</a> but I was unable to come up with an example as concise as the above.</p>
41,028,642
0
Cannot use LinkedIn API with activeadmin because of how activeadmin includes javascript <p>I have succesfully gotten the Linkedin API to work using the following code:</p> <pre><code>&lt;script type="text/javascript" src="//platform.linkedin.com/in.js"&gt; api_key: my_key &lt;/script&gt; $('#sign_in').click(function(){ IN.User.authorize(user_authorized); }); var capture_data = function(){ IN.API.Raw().url('/people/~:(id,num-connections,picture-url,industry,headline,summary)?format=json').result(display_data); } </code></pre> <p>I am trying to redo this functionality in ActiveAdmin. The problem is the way active_admin includes javascripts and linkedin's formatting. LinkedIn required the exact linebreaks I use for including the src and api_key. I can't figure out how to add the first 3 lines above using activeadmin.</p>