pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
549,202
0
<p>osascript -e "tell application \"Terminal\" to set background color of window 1 to {0,45000,0,0}"</p> <p><a href="http://stackoverflow.com/questions/157959/how-do-i-make-the-apple-terminal-window-auto-change-colour-scheme-when-i-ssh-to-a">(Can't take the credit)</a> </p>
21,462,564
0
<p>Hi in the Facebook SDK for the Android it is only possible to Share something not to Like. if you want to Like page you should use WebView and use Iframe in it to display like button.</p>
10,371,662
0
<p>A generic approach:</p> <pre><code>:%s/\(&lt;string name="\)\(\u\)\([^" ]\+\) \([^" ]\+\)/\1\l\2\e\3_\4/ </code></pre> <p>This replaces every string @name that </p> <ul> <li>starts with an upper case character (<code>\u</code>) and</li> <li>consists of two space-separated words (<code>\([^" ]\+\) \([^" ]\+\)</code>) and </li> <li>replaces it with the corresponding lower-case character (<code>\l\2\e</code>). </li> <li>It also replaces the space with an underscore.</li> </ul> <hr> <p>To make everything in @name lower-case, this could be simplified:</p> <pre><code>:%s/\(&lt;string name="\)\([^" ]\+\) \([^" ]\+\)/\1\l\2_\3_\e/ </code></pre> <hr> <p>To get rid of multiple spaces, do two steps. First, make the attribute value lower-case:</p> <pre><code>:%s/\(&lt;string name="\)\([^"]\+\)/\1\l\2\e/ </code></pre> <p>then, replace every space in the attribute value with an underscore</p> <pre><code>:%s/\(&lt;string name="[^"]*\)\@&lt;= /_/g </code></pre> <p>Note that the <code>\@&lt;=</code> is vim's way of expressing a positive look-behind assertion.</p>
20,047,697
0
<p>Problem solved! The issue is never about log4j. It is because WebApplicationInitializer need servlet 3.1 support which is not enabled as default. We have enabled following in the start.ini</p> <pre><code># =========================================================== # Enable additional webapp environment configurators # ----------------------------------------------------------- OPTIONS=plus etc/jetty-plus.xml # =========================================================== # Enable servlet 3.1 annotations # ----------------------------------------------------------- OPTIONS=annotations etc/jetty-annotations.xml </code></pre>
20,572,875
0
DataGridView CellContentClick event missed if SelectionChanged event handled? <p>I'm using C++/CLI .NET 4.5 on Win7. I develop a control with a DataGridView. The cells are not editable by the user neither it is possible to add rows manually.</p> <p>I need to catch/handle the <em>SelectionChanged</em> event, so I added a handler for it. I also need to catch/handle the <em>CellContentClick</em> event, so I added too the handler for it. If I click on the content of a cell, of course the selection is changed but I would like to catch the event for the click too. The handler for <em>CellContentClick</em> is never called.</p> <ul> <li><p>If I remove the <em>SelectionChanged</em> handler, the <em>CellContentClick</em> is catched as wanted.</p></li> <li><p>If I put a <code>return</code> as the first line of my <em>SelectionChanged</em> handler, the <em>CellContentClick</em> is never catched neither.</p></li> </ul> <p>It looks like if the handler for the Selection forbids the event for the click to be fired????</p> <p>Any idea? Let me know if you need more info about the settings of my DataGridView.</p> <p>Thanks!</p>
37,415,120
0
Okay to use underscores in file and folder names in PHP? <p>For example using <code>&lt;?php include '_blogroll.php'; ?&gt;</code> instead of blogroll.php ? It helps me organize the partial files in cPanel (_header.php, _footer.php, etc.)</p>
11,725,338
0
<p>The my.cnf should not be world-writable (i.e. **6 or **7) permissions.</p> <p>It is a security vulnerability. MySQL will ignore files with this this permission setting.</p>
36,806,353
0
Can object method call be done simultaneously with object instantiation? <p>I'm trying to use java class <code>BitSet</code> as a field for a customized class. And I want the class to use a default BitSet with all bits set.</p> <pre><code>import java.util.BitSet; public class MyClass { private BitSet mask; public MyClass() { this(new BitSet(4)); // want to set all bits first // something like // this( new BitSet(4).set(0,3) ); } public MyClass(BitSet mask) { this.mask = mask; } } </code></pre> <p>By default <code>BitSet</code> constructor unsets all bits. So before I send it as an anonymous object, I would like call <code>set(int, int)</code> method to set all bits. I know that I could simply initialize the field <code>mask</code> to a new <code>BitSet</code> and then call <code>set(int, int)</code> method from there. </p> <p>However, in general I'm wondering is it possible to access an instance method at time of object instantiation?</p>
16,168,794
0
EF classes don't show up in when adding new API Controller <p>This question has been asked a few times in SO but nothing helped so far in my case.</p> <p>To an existing MVC project I added a model generated from a database (using database first). Now I would like to add a new API controller. However, neither my new model classes nor my data context class show up in "Add Controller" dialog:</p> <ul> <li>made sure I recompiled my dll</li> <li>restarted VS (2010)</li> <li>deleted AssemblyInfo.cs (as suggested in another SO post)</li> <li>checked with ILSpy to make sure models are in and have an Id</li> </ul> <p>My workaround is to put my models in another dll. However, I think that shouldn't be necessary...</p>
3,320,676
0
<p>I found the answer. I finally broke down and downloaded the ROM and extracted the bitmaps with NAPIT. (btw: staring at extracted ROM bitmaps is really bloody hard on your eyes!)</p> <p>I matched a few bitmaps and end-results <a href="http://img405.imageshack.us/img405/9396/finalfantasy2.gif" rel="nofollow noreferrer">here</a>.</p> <p>Each character has a color that is mostly relegated to top part of the sprite so I chased that idea a while. It turns out that's a red herring. Comparing the in-game sprites vs. the color masks, you can see that black and transparent use the same color mask. Therefore, <em>IF</em> a black outline is shown, then it must be on a separate layer. However, despite the black outlines on the sprite-sheet, I can't find any real examples of black outlines in the game.</p> <p><a href="http://www.youtube.com/watch?v=Tx0c7jXbA_E" rel="nofollow noreferrer">Here's a video on YouTube</a> with lots of good examples. When you are on the blue background screen (@ 0:27), the outlines and the black mage's face are the blue of the background (ie: there is no black outline, it's transparent). In combat, the background is black. @ 1:46 a spell is cast that makes the background flash grey. All black areas, including outlines and black eyes, flash grey. Other spells are also cast around this part of the video with different colors of flashes. The results are the same.</p> <p>The real answer is that the black outlines on the sprite sheet don't seem to exist in the game. Whoever made the sprite sheet took the screenshots with a black background and scrubbed the background away.</p>
33,494,433
0
specs2 - how to use the same variable inside around and inside the test itself? <p>I am using specs2 as my test framework. I want to generate a uniq key that will be available in the test itself.</p> <pre><code>def around[R: AsResult](r: =&gt; R): Result = { val uniqueToken = before() try AsResult(r)(uniqueToken) finally after(uniqueToken) } "foo" should { "bar" in { do something with uniqueToken } } </code></pre> <p>Couldn't find any good way to do it.. Any idea?</p>
20,855,152
0
<p>First get the text length by </p> <pre><code>var get = $("#value").val().length; </code></pre> <p>Then get the max size means width of button before this set a fixed width to button</p> <pre><code>maxScale = $("#value").width(); </code></pre> <p>then just reduce the font size by</p> <p>by comparing the both with if set the fontsize</p> <pre><code>if ( currentFontSize &lt; maxSize ) { currentFontSize += .1; $("button").css('font-size', fontSize + 'px'); </code></pre> <p>try this ...</p>
1,897,907
0
<p>The Skyhook system seems to work only for mobile devices. It uses either GPS (from the device's own GPS software), knowledge of the location of the WiFi access point in use, or triangulation from the cell towers that are in use.</p> <p>Details are <a href="http://www.skyhookwireless.com/howitworks/" rel="nofollow noreferrer">here</a>.</p> <p>The best accuracy comes if the user is willing to share their GPS location, or their WiFi access point is listed in the Skyhook database. However, most casual users won't have their GPS antenna turned on unless they're navigating somewhere, and most private or corporate WiFi access points won't be listed.</p> <p>So in practice this service is only really useful for applications where the user gives consent, such as tracking devices in use by a company. </p> <p>The fallback is to use geolocation of the IP, which as I mentioned in my comment above is very very inaccurate and is really only of use for fun.</p>
25,362,820
0
Get build requestor using Groovy script (Jenkins / email-ext) <p>I want to get the username and/or email address of the build requestor in a post-build script.</p> <p><em>Sidenote: I want the requestor so I can set the email sender of the post-build email notification dynamically in the email-ext plugin's pre-send script.</em></p> <p><a href="http://javadoc.jenkins-ci.org/hudson/model/AbstractBuild.html" rel="nofollow"><code>AbstractBuild</code></a> has built-in support for <code>AbstractBuild.getCulprits()</code> and <code>AbstractBuild.hasParticipant(User user)</code> but I can't find a method for retrieving the requestor. I can't find any useful reference in <a href="http://javadoc.jenkins-ci.org/hudson/model/class-use/User.html" rel="nofollow">reference list</a> to the <code>User</code> class either.</p>
30,929,519
0
Android: How to find width and height of screen? <p>I am trying to find the width and height of the screen but none of the ways I have tried will work in the class I created, my code is below. </p> <p>Does anyone know how to find it? I cannot use the way I am trying below because .getWidth() is deprecated?</p> <pre><code>public class Crate { public int acrossCrate; public int upDownCrate; Context theContext; WindowManager wm = (WindowManager)theContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width = display.getWidth(); public Crate() { acrossCrate = 650; upDownCrate = 650; //int width = ; //int height = ; } } </code></pre>
36,742,234
0
<p>The error that you showed is because Twig is trying to execute the <code>getLastname()</code> method in your object and it's not defined.</p> <p>The solution is the one provided by @qooplmao in a previous comment and use the <a href="http://twig.sensiolabs.org/doc/functions/attribute.html" rel="nofollow">attribute() function</a>:</p> <pre><code>{{ attribute(obj, 'getLastname' ~ suff) }} </code></pre>
22,236,706
0
<p>I figured I'd elaborate on my comment. I'd just have some bitwise fun.</p> <pre><code>char string[] = "123456" byte1 = ((unsigned char)string[0] &lt;&lt; 4) | (unsigned char)string[1]; byte2 = ((unsigned char)string[2] &lt;&lt; 4) | (unsigned char)string[3]; byte3 = ((unsigned char)string[4] &lt;&lt; 4) | (unsigned char)string[5]; </code></pre>
24,532,285
0
Get value if all objects in chain exist, get fallback value if not <p>Feel kind of stupid to ask.. I want to get something like this:</p> <pre><code>var value = $scope.settings.paper.font.color || 0; </code></pre> <p>The problem is that some of the middle objects may not exist. </p> <p>Is there an ultimate way to get <strong>value</strong> if all "object chain" exists and get some fallback if not?</p> <p>For example, in line above if all objects exists, we may return value of <strong>color</strong>, but if only $scope.settings exists, and there's no <em>paper</em> object in it, i will get an error, not 0.</p>
21,906,600
0
<pre><code>echo "&lt;meta http-equiv=\"refresh\" content=\"4;URL=inbox.php\"&gt;"; </code></pre> <p>change 0 to 4 can do this</p>
19,342,595
0
<p>I was battling this for a few hours as well and came up with a solution. In my project i am using angular to control the actual view switching. so what i did was to define two separate route groups in L4, one that returns actual pages directly from laravel's routing system and another that returns HTML fragments for angulars routing system.</p> <p>Here is an example of my routing</p> <pre><code>//Laravel pages and API routes Route::get('/', function() { return View::make('hello'); }); Route::get('/register',function(){ return View::make('registration'); }); //Angular SPA routes(HTML fragments for angulars routing system) Route::get('/getstarted', function(){ return View::make('getStarted'); }); Route::get('/terms',function(){ return View::make('terms'); }); </code></pre> <p>So in this scenario, laravel sends your home page when you call "/", and the ng-view asks for "/getstarted" by ajax which returns your html fragment. Hope this helps :)</p>
34,660,347
0
<p>Assuming <code>(</code> and <code>)</code> are not nested and unescaped. You can use split using:</p> <pre><code>String[] arr = input.split(",(?![^()]*\\))\\s*"); </code></pre> <p><a href="https://regex101.com/r/wK4bC6/1" rel="nofollow">RegEx Demo</a></p> <p><code>,(?![^()]*\))</code> will match a comma if it is NOT followed by a non-parentheses text and <code>)</code>, thus ignoring commas inside <code>(</code> and <code>)</code>.</p>
7,137,845
0
<p>As others have pointed out ruby's <code>Symbol#to_proc</code> method is invoked and calls the <code>age</code> method on each hash in the array. The problem here is that the hashes do not respond to an <code>age</code> method.</p> <p>Now we could define one for the Hash class, but we probably don't want it for every hash instance in the program. Instead we can simply define the <code>age</code> method on each hash in the array like so:</p> <pre><code>array.each do |hash| class &lt;&lt; hash def age self[:age] end end end </code></pre> <p>And then we can use <code>group_by</code> just as you were before:</p> <pre><code>array = array.group_by &amp;:age </code></pre>
23,458,780
0
<p>I know for sure that the C++ version supports merging two channels, so you can use it. Have you tried passing two input images and NULL for the rest?</p>
15,679,897
0
<p>You can use conditional compilation to get only IE10, this is a good way because it does not rely on jQuery or anything that could be spoofed(afaik).</p> <p>Tested it on IE8, IE9, IE10, Chrome and worked as expected in all.</p> <p>Usage:</p> <p><code>if(Function('/*@cc_on return document.documentMode===10@*/')()){ $("html").addClass("ie10"); }</code></p> <p>read on: <a href="http://stackoverflow.com/a/13971998/1711038">http://stackoverflow.com/a/13971998/1711038</a></p>
20,808,639
0
javascript check from input if any values are in array of forbidden words <p>I'm having trouble figuring out how to do this. I'm using jQuery and I know the inArray function but I'm stuck. When the user inserts some values in an input field, I want to check if any of the words entered are in an array...if they are then to remove them. Here's what I have:</p> <pre><code>&lt;input type="text" id="search"/&gt; $("#search").bind('enterKey', function(e){ var search = $('#search').val(); var check = ['on', 'a', 'the', 'of', 'in', 'if', 'an']; var id = $.inArray(check, search); if (id !== -1){ alert ("in array"); }else{ alert ("not in array"); } }); $('#search').keyup(function(e){ if(e.keyCode == 13){ $(this).trigger("enterKey"); } }); </code></pre> <p><a href="http://jsfiddle.net/F4ZfD/2/" rel="nofollow">Fiddle</a></p> <p>I'm sure my if statement is wrong...please help me out!</p>
23,413,206
0
Add style to link_to <p>I don't get along with the <code>link_to</code> helper and similar stuff. I am trying to add a style to my link but I can't manage to do it, because according to the documentation the parameters are options and html_options, but then some parameters I am using are not even listed in the docs for <code>link_to</code> so I don't know which are options and which html_options so I can't rearrage the hashes.</p> <pre><code>&lt;%= link_to '+', :controller =&gt; 'shop', :action =&gt; 'add', :id =&gt; product, :remote =&gt; true %&gt; </code></pre> <p>How should I rearrange the hashes to allow me to add <code>:styles =&gt; 'color:red;.....'</code>?</p>
1,645,232
0
<p>Drewamweaver or MS's Visual Studio/Web Developer Express will do the trick. They're both overkill (especially MS's tools). </p> <p>I also think MS has (free) HTMLHelp. It's out there, but I don't know if it'll produce the files you need.</p>
31,856,093
0
<p>Just write <code>import Bolts</code> in you AppDelegate.swift file</p>
7,488,838
0
Gradient Backgrounds in internet explorer version <=8 <p>I need to have gradient backgrounds on my website for internet explorer. I know there is some kind of proprietry way of doing this:</p> <pre><code>filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#20799d', EndColorStr='#5cb9df'); </code></pre> <p>But this doesn't grok with <code>border-radius</code> (supported by IE8, at least), which my site uses all over the place.</p> <p>How should I solve this? (Other than just not having gradient backgrounds on old versions of IE, I mean.)</p>
19,159,958
0
<p>I think its TinyMCE that messes with your markup. You can edit the TinyMCE config file in App_Data\Settings\tinymce-standard.js to suit your needs.</p>
4,519,068
0
<p>It might be quite a late reply, but you could benefit from this lab course written primarily for learning PIC Assembly through applications. </p> <p>Check: <a href="http://embedded-ju.ucoz.com/" rel="nofollow">http://embedded-ju.ucoz.com/</a></p> <p>Check the experiments tab, it includes:</p> <p><strong>Experiment 0</strong> - (Introduction to MPLAB)</p> <p><strong>Experiment 1</strong> - (Introduction to PIC Assembly Instruction Set)</p> <p><strong>Experiment 2</strong> - (More on Instruction Set and Modular Programming Techniques)</p> <p><strong>Experiment 3</strong> - (Basic System Analysis and Design)<br> 3.1. Guide to Hardware I </p> <p><strong>Experiment 4</strong> - ( LCD - HD44780 )</p> <p><strong>Experiment 5</strong> - (Keypad) </p> <p><strong>Experiment 6</strong> - (Using HI-TECH C Compiler in MPLAB) 6.1. PIC Programming with ICD2 Guide.</p> <p><strong>Experiment 7</strong> - (Timers (Timer0 and Timer2))</p> <p><strong>Experiment 8</strong> - (USART)</p> <p><strong>Experiment 9</strong> - (Software PWM &amp; A/D)</p> <hr> <p>It is based on the PIC 16 series, most notably, 16f84A, 16F877A and 16F917 .. the examples are fully commented, and the experiments fully explained.</p>
28,223,574
0
Try to move UIImageView in screen with touchesMoved <p>I try to move 2 UIImageView.</p> <p>Only one picture is supposed to move when I drag.</p> <p>What I trying to accomplish is move UIImageView when I touch and drag the UIImageView.</p> <p>This Is my viewDidLoad :</p> <pre><code>-(void)viewDidLoad { [super viewDidLoad]; myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 100)]; [myImageView setImage:[UIImage imageNamed:@"image1.png"]]; [self.view addSubview:myImageView]; myImageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 200,100)]; [myImageView1 setImage:[UIImage imageNamed:@"image2"]]; [self.view addSubview:myImageView1]; } </code></pre> <p>This Is my touchesMoved method :</p> <pre><code> - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // get touch event UITouch *touch = [[event allTouches] anyObject]; CGPoint touchLocation = [touch locationInView:self.view]; for (UIImageView *image in [self.view subviews]) { if ([touch view] == image) { // move the image view image.center = touchLocation; } } } </code></pre> <p>In this line I don't get the images view </p> <pre><code>for (UIImageView *image in [self.view subviews]) </code></pre> <p>It is possible to get the current touched UIIamgeView ?</p>
20,632,342
0
<p>Just change your for loop,</p> <pre><code> for(int row=0; row&lt;1; row++){ for(int column = 0; column&lt;x[row].length; column++){ System.out.println(x[row][column] + "\t"+x[row+1][column] ); } System.out.print("\n"); } </code></pre> <p>into below this will work even you have 5000 rows, </p> <pre><code> for(int row=0; row&lt;x.length-1; row++){ for (int column = 0; column &lt; x.length; column++) { System.out.print(x[column][row] + "\t" ); } System.out.println(); } </code></pre>
21,748,244
0
<p>You might also consider using <a href="http://packer.io" rel="nofollow">Packer</a> to create VirtualBox images for developers to use. </p> <p>Rather than sharing the Vagrantfile which developers each use to build and run their VM, you would have a packer template (json) which is used to create a VM image. Developers download or copy the image and run it locally, directly in VB, without having to build it themselves.</p> <p>Many of the publicly shared Vagrant base boxes are created with Packer.</p>
40,359,412
0
<p>I used the (penultimate) code in Robert McKee's solution, however, had to adapt it to get it to compile and display correctly in the view:</p> <pre><code>public ActionResult Create() { ViewBag.AllSystems = new MultiSelectList(db.dbSystem.Select(x=&gt;new { Name=x.systemName, Value=x.systemId }),"Value","Name"); return View(); } </code></pre> <p>etc....</p>
26,905,220
0
<p>Create a <code>List&lt;TextBox&gt;</code> for each group:</p> <pre><code> List&lt;TextBox&gt; list01 = new List&lt;TextBox&gt;() { tbPlay0, tbPlay1, ....}; List&lt;TextBox&gt; list02 = new List&lt;TextBox&gt;() { ..., ... , ....}; // .. } </code></pre> <p>And pass such a group to the function:</p> <pre><code>private void convertBasetoDrawn(List&lt;TextBox&gt; list, string numBase, string reference) { string[] texts = new string[8] { "000", "500", "050", "005", "550", "505", "055", "555" }; for (int t = 0; t &lt; list.Count; t++) list[t].Text = texts[t]; list[0].ForeColor = Color.Red; list[7].ForeColor = Color.Red; } </code></pre> <p>Assuming the texts will always look like that. If they depend on, maybe <code>numbase</code> you can construct them dynamically as well, as long as you know the rules.. Maybe even a simple replacement will do the job?</p> <p>You didn't use <code>reference</code>, btw..</p> <p>Now, I'm just guessig here, but maybe this is the pattern for your texts..:</p> <pre><code> string[] texts = new string[8] { "nnn", "dnn", "ndn", "nnd", "ddn", "dnd", "ndd", "ddd" }; for (int s = 0; s &lt; texts.Length; s++) texts[s] = texts[s].Replace("d", numBase).Replace("n", reference); </code></pre> <p>Now you can call it like this:</p> <pre><code>convertBasetoDrawn(list01, "0","5"); </code></pre> <p>Update: For the rules as I understand them now you could do:</p> <pre><code>string newText = ""; for (int s = 0; s &lt; texts.Length; s++) { newText = ""; for (int i = 0; i &lt; 3; i++) { if (texts[s][i] == 'n') newText += numBase[i]; else newText += (Convert.ToByte(numBase[i].ToString()) + Convert.ToByte(reference[0].ToString()) ).ToString("0"); } texts[s] = newText; } </code></pre> <p>and call it like this: </p> <pre><code> convertBasetoDrawn(list01, "001", "5"); </code></pre> <p>or</p> <pre><code> convertBasetoDrawn(list02, "000", "1"); </code></pre> <p>Note: no carry over here.. You'd have to define rules for that and code it yourself..</p>