id
int64
4
73.8M
title
stringlengths
10
150
body
stringlengths
17
50.8k
accepted_answer_id
int64
7
73.8M
answer_count
int64
1
182
comment_count
int64
0
89
community_owned_date
stringlengths
23
27
creation_date
stringlengths
23
27
favorite_count
int64
0
11.6k
last_activity_date
stringlengths
23
27
last_edit_date
stringlengths
23
27
last_editor_display_name
stringlengths
2
29
last_editor_user_id
int64
-1
20M
owner_display_name
stringlengths
1
29
owner_user_id
int64
1
20M
parent_id
null
post_type_id
int64
1
1
score
int64
-146
26.6k
tags
stringlengths
1
125
view_count
int64
122
11.6M
answer_body
stringlengths
19
51k
26,921,836
Correct way to test for numpy.dtype
<p>I'm looking at a third-party lib that has the following <code>if</code>-test:</p> <pre><code>if isinstance(xx_, numpy.ndarray) and xx_.dtype is numpy.float64 and xx_.flags.contiguous: xx_[:] = ctypes.cast(xx_.ctypes._as_parameter_,ctypes.POINTER(ctypes.c_double)) </code></pre> <p>It appears that <code>xx_.dtype is numpy.float64</code> always fails:</p> <pre><code>&gt;&gt;&gt; xx_ = numpy.zeros(8, dtype=numpy.float64) &gt;&gt;&gt; xx_.dtype is numpy.float64 False </code></pre> <p>What is the correct way to test that the <code>dtype</code> of a numpy array is <code>float64</code> ?</p>
26,921,882
2
5
null
2014-11-14 02:15:10.137 UTC
5
2014-11-15 03:46:59 UTC
2014-11-14 02:37:13.04 UTC
null
424,153
null
424,153
null
1
31
python|numpy
35,750
<p>This is a bug in the lib.</p> <p><a href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html" rel="noreferrer"><code>dtype</code> objects</a> can be constructed dynamically. And NumPy does so all the time. There's no guarantee anywhere that they're interned, so constructing a <code>dtype</code> that already exists will give you the same one.</p> <p>On top of that, <code>np.float64</code> isn't actually a <code>dtype</code>; it's a… I don't know what these types are called, but the types used to construct scalar objects out of array bytes, which are usually found in the <code>type</code> attribute of a <code>dtype</code>, so I'm going to call it a <code>dtype.type</code>. (Note that <code>np.float64</code> subclasses both NumPy's numeric tower types and Python's numeric tower ABCs, while <code>np.dtype</code> of course doesn't.)</p> <p>Normally, you can use these interchangeably; when you use a <code>dtype.type</code>—or, for that matter, a native Python numeric type—where a <code>dtype</code> was expected, a <code>dtype</code> is constructed on the fly (which, again, is not guaranteed to be interned), but of course that doesn't mean they're identical:</p> <pre><code>&gt;&gt;&gt; np.float64 == np.dtype(np.float64) == np.dtype('float64') True &gt;&gt;&gt; np.float64 == np.dtype(np.float64).type True </code></pre> <p>The <code>dtype.type</code> usually <em>will</em> be identical if you're using builtin types:</p> <pre><code>&gt;&gt;&gt; np.float64 is np.dtype(np.float64).type True </code></pre> <p>But two <code>dtype</code>s are often not:</p> <pre><code>&gt;&gt;&gt; np.dtype(np.float64) is np.dtype('float64') False </code></pre> <p>But again, none of that is guaranteed. (Also, note that <code>np.float64</code> and <code>float</code> use the exact same storage, but are separate types. And of course you can also make a <code>dtype('f8')</code>, which is guaranteed to work the same as <code>dtype(np.float64)</code>, but that doesn't mean <code>'f8'</code> <code>is</code>, or even <code>==</code>, <code>np.float64</code>.)</p> <p>So, it's possible that constructing an array by explicitly passing <code>np.float64</code> as its <code>dtype</code> argument will mean you get back the same instance when you check the <code>dtype.type</code> attribute, but that isn't guaranteed. And if you pass <code>np.dtype('float64')</code>, or you ask NumPy to infer it from the data, or you pass a dtype string for it to parse like <code>'f8'</code>, etc., it's even less likely to match. More importantly, you <em>definitely</em> not get <code>np.float64</code> back as the <code>dtype</code> itself.</p> <hr> <p>So, how should it be fixed?</p> <p>Well, the docs define what it means for two <code>dtype</code>s to be <em>equal</em>, and that's a useful thing, and I think it's probably the useful thing you're looking for here. So, just replace the <code>is</code> with <code>==</code>:</p> <pre><code>if isinstance(xx_, numpy.ndarray) and xx_.dtype == numpy.float64 and xx_.flags.contiguous: </code></pre> <p>However, to some extent I'm only guessing that's what you're looking for. (The fact that it's checking the contiguous flag implies that it's probably going to go right into the internal storage… but then why isn't it checking C vs. Fortran order, or byte order, or anything else?)</p>
41,238,786
Error: No matching distribution found for pip
<p>I am trying to install pip in my <strong>python 2.6.6</strong>, I have <strong>Oracle Linux 6</strong></p> <p>I followed the answers given at this link <a href="https://stackoverflow.com/questions/24294467/how-to-install-pip-for-python-2-6">Link</a></p> <p>I downloaded <strong>get-pip.py</strong> file and ran the following command</p> <pre><code>sudo python2.6 get-pip.py </code></pre> <p><strong>However I get the following error</strong></p> <pre><code>[root@bigdatadev3 Downloads]# sudo python2.6 get-pip.py DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6 Collecting pip Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x3cad210&gt;: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/ Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x3cadad0&gt;: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/ Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x3cad6d0&gt;: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/ Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x3cad790&gt;: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/ Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x3cad110&gt;: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/ Could not find a version that satisfies the requirement pip (from versions: ) No matching distribution found for pip </code></pre> <p>The error shows some network issue, but I have full open internet access here. </p> <p>How can I install pip?</p> <p>I also tried yum, <code>yum install python-pip</code> but it gave the following message</p> <pre><code>[root@bigdatadev3 ~]# yum install python-pip Loaded plugins: refresh-packagekit, security, ulninfo Setting up Install Process No package python-pip available. Error: Nothing to do </code></pre> <p><strong>Update 1</strong>:</p> <p>I used the following command,</p> <pre><code>python get-pip.py --proxy="MY_PROXY" </code></pre> <p>I get the following error</p> <pre><code>DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6 Collecting pip Exception: Traceback (most recent call last): File "/tmp/tmpnz7ISh/pip.zip/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/tmp/tmpnz7ISh/pip.zip/pip/commands/install.py", line 324, in run requirement_set.prepare_files(finder) File "/tmp/tmpnz7ISh/pip.zip/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/tmp/tmpnz7ISh/pip.zip/pip/req/req_set.py", line 554, in _prepare_file require_hashes File "/tmp/tmpnz7ISh/pip.zip/pip/req/req_install.py", line 278, in populate_link self.link = finder.find_requirement(self, upgrade) File "/tmp/tmpnz7ISh/pip.zip/pip/index.py", line 465, in find_requirement all_candidates = self.find_all_candidates(req.name) File "/tmp/tmpnz7ISh/pip.zip/pip/index.py", line 423, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "/tmp/tmpnz7ISh/pip.zip/pip/index.py", line 568, in _get_pages page = self._get_page(location) File "/tmp/tmpnz7ISh/pip.zip/pip/index.py", line 683, in _get_page return HTMLPage.get_page(link, session=self.session) File "/tmp/tmpnz7ISh/pip.zip/pip/index.py", line 792, in get_page "Cache-Control": "max-age=600", File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/sessions.py", line 488, in get return self.request('GET', url, **kwargs) File "/tmp/tmpnz7ISh/pip.zip/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/sessions.py", line 475, in request resp = self.send(prep, **send_kwargs) File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/sessions.py", line 596, in send r = adapter.send(request, **kwargs) File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/cachecontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/adapters.py", line 390, in send conn = self.get_connection(request.url, proxies) File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/adapters.py", line 290, in get_connection proxy_manager = self.proxy_manager_for(proxy) File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/adapters.py", line 184, in proxy_manager_for **proxy_kwargs File "/tmp/tmpnz7ISh/pip.zip/pip/_vendor/requests/adapters.py", line 43, in SOCKSProxyManager raise InvalidSchema("Missing dependencies for SOCKS support.") InvalidSchema: Missing dependencies for SOCKS support. </code></pre>
41,239,100
3
6
null
2016-12-20 09:24:54.733 UTC
1
2022-09-09 11:21:26.78 UTC
2017-05-23 12:10:35.767 UTC
null
-1
null
3,811,401
null
1
19
python|python-2.6
88,008
<p>This is a proxy issue because of using sudo. Starting a command with sudo will not ensure that exports like <code>export http_proxy=&lt;MY_PROXY&gt;</code>are still up to date.</p> <p>You should try that : </p> <pre><code>python get-pip.py --proxy="[user:passwd@]proxy.server:port" </code></pre> <p>and if you don't have user/passwd just : </p> <pre><code>python get-pip.py --proxy="proxy.server:port" </code></pre> <p><strong>Example :</strong> </p> <pre><code>python get-pip.py --proxy="192.168.0.12:3128" </code></pre>
9,992,526
What are these warnings in catalina.out?
<p>I have a web application in Tomcat 7.<br> When I shut down Tomcat I see these warning (but not always) </p> <pre><code>SEVERE: The web application [/MyApplication] created a ThreadLocal with key of type [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1] (value [org.apache.xml.security.algorithms.MessageDigestAlgorithm$1@2e2c2e2c]) and a value of type [java.util.HashMap] (value [{http://www.w3.org/2000/09/xmldsig#sha1=MESSAGE DIGEST SHA-1}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. Apr 3, 2012 1:56:19 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks SEVERE: The web application [/MyApplication] created a ThreadLocal with key of type [com.sun.xml.bind.v2.ClassFactory$1] (value [com.sun.xml.bind.v2.ClassFactory$1@25442544]) and a value of type [java.util.WeakHashMap] (value [{class com.classes.internal.ContactType=java.lang.ref.WeakReference@17eb17eb, class javax.xml.bind.annotation.adapters.HexBinaryAdapter=java.lang.ref.WeakReference@178a178a, class com.classes.internal.xjc.ListType=java.lang.ref.WeakReference@181c181c, class com.classes.internal.xjc.MessageType=java.lang.ref.WeakReference@17711771, class com.classes.internal.xjc.MessageType=java.lang.ref.WeakReference@17011701}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. Apr 3, 2012 1:56:19 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks SEVERE: The web application [/MyApplication] created a ThreadLocal with key of type [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1] (value [org.apache.xml.security.utils.UnsyncBufferedOutputStream$1@4a904a90]) and a value of type [byte[]] (value [[B@67486748]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. </code></pre> <p>What do these warnings mean in catalina.out on shutdown?<br> I see some of my JAXB classes mentioned, but can't tell what the issue is here. </p> <p>Any help please?</p>
10,017,430
3
0
null
2012-04-03 11:42:19.317 UTC
9
2015-09-21 20:58:55.097 UTC
2015-09-21 20:58:55.097 UTC
null
251,589
null
1,197,249
null
1
18
java|multithreading|jakarta-ee|tomcat|jaxb
63,276
<p>You have one or more memory leaks in your application. For a full explanation of why these occur, which ones are your fault and what you can do to fix them see this presentation: <a href="http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf" rel="noreferrer">http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf</a></p>
9,773,154
Canvas toDataUrl increases file size of image
<p>When using toDataUrl() to set the source of an image tag I am finding that the image when saved is a great deal larger than the original image. </p> <p>In the example below I am not specifying a second param for the toDataUrl function so the default quality is being used. This is resulting in an image much larger that the original image size. When specifying 1 for full quality the image generated is even larger.</p> <p>Does anybody know why this is happening or how I can stop it?</p> <pre><code> // create image var image = document.createElement('img'); // set src using remote image location image.src = 'test.jpg'; // wait til it has loaded image.onload = function (){ // set up variables var fWidth = image.width; var fHeight = image.height; // create canvas var canvas = document.createElement('canvas'); canvas.id = 'canvas'; canvas.width = fWidth; canvas.height = fHeight; var context = canvas.getContext('2d'); // draw image to canvas context.drawImage(image, 0, 0, fWidth, fHeight, 0, 0, fWidth, fHeight); // get data url dataUrl = canvas.toDataURL('image/jpeg'); // this image when saved is much larger than the image loaded in document.write('&lt;img src="' + dataUrl + '" /&gt;'); } </code></pre> <p>Thank you :D</p> <p>Here is an example, unfortunately the image cannot be cross domain and so I am having to just pull one of the jsfiddle images.</p> <p><a href="http://jsfiddle.net/ptSUd/" rel="noreferrer">http://jsfiddle.net/ptSUd/</a></p> <p>The image is 7.4kb, if you then save the image which is being output you will see that it is 10kb. The difference is more noticeable with more detailed images. If you set the toDataUrl quality to 1, the image is then 17kb.</p> <p>I am also using FireFox 10 for this, when using Chrome the image sizes are still larger but not by as much.</p>
9,777,037
3
5
null
2012-03-19 15:38:42.36 UTC
8
2015-02-03 11:59:29.223 UTC
2012-03-19 17:46:31.113 UTC
null
997,680
null
997,680
null
1
21
javascript|canvas|data-url
14,782
<p>The string returned by the <code>toDataURL()</code> method does not represent the original data.</p> <p>I have just performed some extensive tests, which showed that the created data-URL depends on the browser (<em>not</em> on the operating system).</p> <pre><code> Environment - md5 sum - file size Original file - c9eaf8f2aeb1b383ff2f1c68c0ae1085 - 4776 bytes WinXP Chrome 17.0.963.79 - 94913afdaba3421da6ddad642132354a - 7702 bytes Linux Chrome 17.0.963.79 - 94913afdaba3421da6ddad642132354a - 7702 bytes Linux Firefox 10.0.2 - 4f184006e00a44f6f2dae7ba3982895e - 3909 bytes </code></pre> <p>The method of getting the data-URI does not matter, the following snippet was used to verify that the data-URI from a file upload are also different:</p> <h2>Test case: <a href="http://jsfiddle.net/Fkykx/" rel="noreferrer">http://jsfiddle.net/Fkykx/</a></h2> <pre><code>&lt;input type=&quot;file&quot; id=&quot;file&quot;&gt;&lt;script&gt; document.getElementById('file').onchange=function() { var filereader = new FileReader(); filereader.onload = function(event) { var img = new Image(); img.onload = function() { var c = document.createElement('canvas'); // Create canvas c.width = img.width; c.height = img.height; c.getContext('2d').drawImage(img,0,0,img.width,img.height); var toAppend = new Image; toAppend.title = 'Imported via upload, drawn in a canvas'; toAppend.src = c.toDataURL('image/png'); document.body.appendChild(toAppend); } img.src = event.target.result; // Set src from upload, original byte sequence img.title = 'Imported via file upload'; document.body.appendChild(img); }; filereader.readAsDataURL(this.files[0]); } &lt;/script&gt; </code></pre>
10,072,124
Iphone - How to encrypt NSData with public key and decrypt with private key?
<p>I am converting a UIImage to NSData. Now I need to encrypt that NSData using a public key and I need to decrypt using a private key. Please provide a step by step procedure. Which algorithm do I need to use? Is there any good library for encryption and decryption? Also provide some code snippet for encryption and decryption.</p>
10,072,378
2
4
null
2012-04-09 10:49:28.65 UTC
32
2019-05-30 20:21:39.463 UTC
2013-04-17 20:43:31.843 UTC
null
111,307
null
1,277,869
null
1
27
iphone|nsdata|encryption
26,542
<p>I have tried <strong>RSA Encryption and Decryption for NSString</strong> and you may well modify it and make it work for <strong>NSData</strong></p> <p>Add Security.Framework to your project bundle.</p> <p><strong>ViewController.h code is as follows:</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;Security/Security.h&gt; @interface ViewController : UIViewController { SecKeyRef publicKey; SecKeyRef privateKey; NSData *publicTag; NSData *privateTag; } - (void)encryptWithPublicKey:(uint8_t *)plainBuffer cipherBuffer:(uint8_t *)cipherBuffer; - (void)decryptWithPrivateKey:(uint8_t *)cipherBuffer plainBuffer:(uint8_t *)plainBuffer; - (SecKeyRef)getPublicKeyRef; - (SecKeyRef)getPrivateKeyRef; - (void)testAsymmetricEncryptionAndDecryption; - (void)generateKeyPair:(NSUInteger)keySize; @end </code></pre> <p><strong>ViewController.m file code is as follows:</strong></p> <pre><code>#import "ViewController.h" const size_t BUFFER_SIZE = 64; const size_t CIPHER_BUFFER_SIZE = 1024; const uint32_t PADDING = kSecPaddingNone; static const UInt8 publicKeyIdentifier[] = "com.apple.sample.publickey"; static const UInt8 privateKeyIdentifier[] = "com.apple.sample.privatekey"; @implementation ViewController -(SecKeyRef)getPublicKeyRef { OSStatus sanityCheck = noErr; SecKeyRef publicKeyReference = NULL; if (publicKeyReference == NULL) { [self generateKeyPair:512]; NSMutableDictionary *queryPublicKey = [[NSMutableDictionary alloc] init]; // Set the public key query dictionary. [queryPublicKey setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass]; [queryPublicKey setObject:publicTag forKey:(__bridge id)kSecAttrApplicationTag]; [queryPublicKey setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; [queryPublicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef]; // Get the key. sanityCheck = SecItemCopyMatching((__bridge CFDictionaryRef)queryPublicKey, (CFTypeRef *)&amp;publicKeyReference); if (sanityCheck != noErr) { publicKeyReference = NULL; } // [queryPublicKey release]; } else { publicKeyReference = publicKey; } return publicKeyReference; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)testAsymmetricEncryptionAndDecryption { uint8_t *plainBuffer; uint8_t *cipherBuffer; uint8_t *decryptedBuffer; const char inputString[] = "How to Encrypt data with public key and Decrypt data with private key"; int len = strlen(inputString); // TODO: this is a hack since i know inputString length will be less than BUFFER_SIZE if (len &gt; BUFFER_SIZE) len = BUFFER_SIZE-1; plainBuffer = (uint8_t *)calloc(BUFFER_SIZE, sizeof(uint8_t)); cipherBuffer = (uint8_t *)calloc(CIPHER_BUFFER_SIZE, sizeof(uint8_t)); decryptedBuffer = (uint8_t *)calloc(BUFFER_SIZE, sizeof(uint8_t)); strncpy( (char *)plainBuffer, inputString, len); NSLog(@"init() plainBuffer: %s", plainBuffer); //NSLog(@"init(): sizeof(plainBuffer): %d", sizeof(plainBuffer)); [self encryptWithPublicKey:(UInt8 *)plainBuffer cipherBuffer:cipherBuffer]; NSLog(@"encrypted data: %s", cipherBuffer); //NSLog(@"init(): sizeof(cipherBuffer): %d", sizeof(cipherBuffer)); [self decryptWithPrivateKey:cipherBuffer plainBuffer:decryptedBuffer]; NSLog(@"decrypted data: %s", decryptedBuffer); //NSLog(@"init(): sizeof(decryptedBuffer): %d", sizeof(decryptedBuffer)); NSLog(@"====== /second test ======================================="); free(plainBuffer); free(cipherBuffer); free(decryptedBuffer); } /* Borrowed from: * https://developer.apple.com/library/mac/#documentation/security/conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html */ - (void)encryptWithPublicKey:(uint8_t *)plainBuffer cipherBuffer:(uint8_t *)cipherBuffer { NSLog(@"== encryptWithPublicKey()"); OSStatus status = noErr; NSLog(@"** original plain text 0: %s", plainBuffer); size_t plainBufferSize = strlen((char *)plainBuffer); size_t cipherBufferSize = CIPHER_BUFFER_SIZE; NSLog(@"SecKeyGetBlockSize() public = %lu", SecKeyGetBlockSize([self getPublicKeyRef])); // Error handling // Encrypt using the public. status = SecKeyEncrypt([self getPublicKeyRef], PADDING, plainBuffer, plainBufferSize, &amp;cipherBuffer[0], &amp;cipherBufferSize ); NSLog(@"encryption result code: %ld (size: %lu)", status, cipherBufferSize); NSLog(@"encrypted text: %s", cipherBuffer); } - (void)decryptWithPrivateKey:(uint8_t *)cipherBuffer plainBuffer:(uint8_t *)plainBuffer { OSStatus status = noErr; size_t cipherBufferSize = strlen((char *)cipherBuffer); NSLog(@"decryptWithPrivateKey: length of buffer: %lu", BUFFER_SIZE); NSLog(@"decryptWithPrivateKey: length of input: %lu", cipherBufferSize); // DECRYPTION size_t plainBufferSize = BUFFER_SIZE; // Error handling status = SecKeyDecrypt([self getPrivateKeyRef], PADDING, &amp;cipherBuffer[0], cipherBufferSize, &amp;plainBuffer[0], &amp;plainBufferSize ); NSLog(@"decryption result code: %ld (size: %lu)", status, plainBufferSize); NSLog(@"FINAL decrypted text: %s", plainBuffer); } - (SecKeyRef)getPrivateKeyRef { OSStatus resultCode = noErr; SecKeyRef privateKeyReference = NULL; // NSData *privateTag = [NSData dataWithBytes:@"ABCD" length:strlen((const char *)@"ABCD")]; // if(privateKey == NULL) { [self generateKeyPair:512]; NSMutableDictionary * queryPrivateKey = [[NSMutableDictionary alloc] init]; // Set the private key query dictionary. [queryPrivateKey setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass]; [queryPrivateKey setObject:privateTag forKey:(__bridge id)kSecAttrApplicationTag]; [queryPrivateKey setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; [queryPrivateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef]; // Get the key. resultCode = SecItemCopyMatching((__bridge CFDictionaryRef)queryPrivateKey, (CFTypeRef *)&amp;privateKeyReference); NSLog(@"getPrivateKey: result code: %ld", resultCode); if(resultCode != noErr) { privateKeyReference = NULL; } // [queryPrivateKey release]; // } else { // privateKeyReference = privateKey; // } return privateKeyReference; } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; privateTag = [[NSData alloc] initWithBytes:privateKeyIdentifier length:sizeof(privateKeyIdentifier)]; publicTag = [[NSData alloc] initWithBytes:publicKeyIdentifier length:sizeof(publicKeyIdentifier)]; [self testAsymmetricEncryptionAndDecryption]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } else { return YES; } } - (void)generateKeyPair:(NSUInteger)keySize { OSStatus sanityCheck = noErr; publicKey = NULL; privateKey = NULL; // LOGGING_FACILITY1( keySize == 512 || keySize == 1024 || keySize == 2048, @"%d is an invalid and unsupported key size.", keySize ); // First delete current keys. // [self deleteAsymmetricKeys]; // Container dictionaries. NSMutableDictionary * privateKeyAttr = [[NSMutableDictionary alloc] init]; NSMutableDictionary * publicKeyAttr = [[NSMutableDictionary alloc] init]; NSMutableDictionary * keyPairAttr = [[NSMutableDictionary alloc] init]; // Set top level dictionary for the keypair. [keyPairAttr setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; [keyPairAttr setObject:[NSNumber numberWithUnsignedInteger:keySize] forKey:(__bridge id)kSecAttrKeySizeInBits]; // Set the private key dictionary. [privateKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecAttrIsPermanent]; [privateKeyAttr setObject:privateTag forKey:(__bridge id)kSecAttrApplicationTag]; // See SecKey.h to set other flag values. // Set the public key dictionary. [publicKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecAttrIsPermanent]; [publicKeyAttr setObject:publicTag forKey:(__bridge id)kSecAttrApplicationTag]; // See SecKey.h to set other flag values. // Set attributes to top level dictionary. [keyPairAttr setObject:privateKeyAttr forKey:(__bridge id)kSecPrivateKeyAttrs]; [keyPairAttr setObject:publicKeyAttr forKey:(__bridge id)kSecPublicKeyAttrs]; // SecKeyGeneratePair returns the SecKeyRefs just for educational purposes. sanityCheck = SecKeyGeneratePair((__bridge CFDictionaryRef)keyPairAttr, &amp;publicKey, &amp;privateKey); // LOGGING_FACILITY( sanityCheck == noErr &amp;&amp; publicKey != NULL &amp;&amp; privateKey != NULL, @"Something really bad went wrong with generating the key pair." ); if(sanityCheck == noErr &amp;&amp; publicKey != NULL &amp;&amp; privateKey != NULL) { NSLog(@"Successful"); } // [privateKeyAttr release]; // [publicKeyAttr release]; // [keyPairAttr release]; } @end </code></pre> <p>Let me know if you need more help.</p> <p>Hope this helps.</p>
10,075,943
Powershell pass variable to start-job
<p>within powershell I'd like to learn the best way to call a variable to a start job so I don't have to edit the script for each server as it will be specific based on the client I've placed my script on.</p> <pre><code>$Servername = 'Server1' $pingblock = { pathping $servername | Out-File C:\client\PS\ServerPing.TXT } start-job $pingblock </code></pre> <p>when I run my code above I just get a file with the help as if I forgot the specify the $servername.</p>
10,075,995
3
0
null
2012-04-09 15:59:43.957 UTC
11
2021-10-10 22:16:10.613 UTC
2012-05-29 19:26:45.747 UTC
null
1,322,172
null
1,322,172
null
1
33
variables|powershell|start-job
49,071
<p>Use the <code>-ArgumentList</code> parameter on <code>Start-Job</code> e.g.:</p> <pre><code>Start-Job -Scriptblock {param($p) "`$p is $p"} -Arg 'Server1' </code></pre> <p>In your case:</p> <pre><code>$pingblock = {param($servername) pathping $servername | Out-File C:\...\ServerPing.txt} Start-Job $pingblock -Arg Server1 </code></pre>
10,001,017
hg shelve equivalent of git stash drop
<p>I have the hg shelve (not attic) extension installed, and I want to drop a patch. In git it would be <code>git stash drop</code>. How do I do this using the shelve extension?</p>
10,001,059
4
0
null
2012-04-03 20:38:04.227 UTC
8
2018-12-21 12:24:15.107 UTC
2018-12-21 12:24:15.107 UTC
null
3,195,477
null
610,585
null
1
40
mercurial|shelving
14,610
<p>The Mercurial shelve extension stores patches under .hg/shelved. Each is a simple patch file, and the filename is the name of the patch. So to remove a patch called 'mypatch' I can simply remove the file 'mypatch' from .hg/shelved:</p> <p><code>rm .hg/shelved/mypatch</code></p>
9,922,145
What is NSManagedObjectContext's performBlock: used for?
<p>In iOS 5, <code>NSManagedObjectContext</code> has a couple of new methods, <code>performBlock:</code> and <code>performBlockAndWait:</code>. What are these methods actually used for? What do they replace in older versions? What kind of blocks are supposed to be passed to them? How do I decide which to use? If anyone has some examples of their use it would be great.</p>
10,003,165
2
3
null
2012-03-29 08:59:30.287 UTC
41
2016-01-14 10:25:10.96 UTC
2016-01-14 10:25:10.96 UTC
null
510,577
null
74,118
null
1
68
ios|core-data|ios5|nsmanagedobjectcontext|blocking
31,928
<p>The methods <code>performBlock:</code> and <code>performBlockAndWait:</code> are used to send messages to your <code>NSManagedObjectContext</code> instance if the MOC was initialized using <code>NSPrivateQueueConcurrencyType</code> or <code>NSMainQueueConcurrencyType</code>. If you do anything with one of these context types, such as setting the persistent store or saving changes, you do it in a block.</p> <p><code>performBlock:</code> will add the block to the backing queue and schedule it to run on its own thread. The block will return immediately. You might use this for long persist operations to the backing store.</p> <p><code>performBlockAndWait:</code> will also add the block to the backing queue and schedule it to run on its own thread. However, the block will not return until the block is finished executing. If you can't move on until you know whether the operation was successful, then this is your choice.</p> <p>For example:</p> <pre><code>__block NSError *error = nil; [context performBlockAndWait:^{ myManagedData.field = @"Hello"; [context save:&amp;error]; }]; if (error) { // handle the error. } </code></pre> <p>Note that because I did a <code>performBlockAndWait:</code>, I can access the error outside the block. <code>performBlock:</code> would require a different approach.</p> <p>From the <a href="http://developer.apple.com/library/ios/#releasenotes/DataManagement/RN-CoreData/_index.html" rel="noreferrer">iOS 5 core data release notes</a>:</p> <blockquote> <p>NSManagedObjectContext now provides structured support for concurrent operations. When you create a managed object context using initWithConcurrencyType:, you have three options for its thread (queue) association</p> <ul> <li><p>Confinement (NSConfinementConcurrencyType).</p> <p>This is the default. You promise that context will not be used by any thread other than the one on which you created it. (This is exactly the same threading requirement that you've used in previous releases.)</p></li> <li><p>Private queue (NSPrivateQueueConcurrencyType).</p> <p>The context creates and manages a private queue. Instead of you creating and managing a thread or queue with which a context is associated, here the context owns the queue and manages all the details for you (provided that you use the block-based methods as described below).</p></li> <li><p>Main queue (NSMainQueueConcurrencyType).</p> <p>The context is associated with the main queue, and as such is tied into the application’s event loop, but it is otherwise similar to a private queue-based context. You use this queue type for contexts linked to controllers and UI objects that are required to be used only on the main thread.</p></li> </ul> </blockquote>
9,720,195
What is the best way to get the count/length/size of an iterator?
<p>Is there a "computationally" quick way to get the count of an iterator?</p> <pre><code>int i = 0; for ( ; some_iterator.hasNext() ; ++i ) some_iterator.next(); </code></pre> <p>... seems like a waste of CPU cycles.</p>
9,720,254
10
2
null
2012-03-15 12:58:42.57 UTC
9
2022-07-18 09:27:53.54 UTC
2012-03-15 13:02:09.64 UTC
null
365,338
null
365,338
null
1
116
java|iterator
219,187
<p>If you've just got the iterator then that's what you'll have to do - it doesn't <em>know</em> how many items it's got left to iterate over, so you can't query it for that result. There are utility methods that will <em>seem</em> to do this efficiently (such as <code>Iterators.size()</code> in Guava), but underneath they're just consuming the iterator and counting as they go, the same as in your example.</p> <p>However, many iterators come from collections, which you can often query for their size. And if it's a user made class you're getting the iterator for, you could look to provide a size() method on that class.</p> <p>In short, in the situation where you <em>only</em> have the iterator then there's no better way, but much more often than not you have access to the underlying collection or object from which you may be able to get the size directly.</p>
9,895,621
Best practice using NSLocalizedString
<p>I'm (like all others) using <code>NSLocalizedString</code>to localize my app.</p> <p>Unfortunately, there are several "drawbacks" (not necessarily the fault of NSLocalizedString itself), including</p> <ul> <li>No autocompletition for strings in Xcode. This makes working not only error-prone but also tiresome.</li> <li>You might end up redefining a string simply because you didn't know an equivalent string already existed (i.e. "Please enter password" vs. "Enter password first")</li> <li>Similarily to the autocompletion-issue, you need to "remember"/copypaste the comment strings, or else <code>genstring</code> will end up with multiple comments for one string</li> <li>If you want to use <code>genstring</code> after you've already localized some strings, you have to be careful to not lose your old localizations.</li> <li>Same strings are scattered througout your whole project. For example, you used <code>NSLocalizedString(@"Abort", @"Cancel action")</code> everywhere, and then Code Review asks you to rename the string to <code>NSLocalizedString(@"Cancel", @"Cancel action")</code> to make the code more consistent.</li> </ul> <p>What I do (and after some searches on SO I figured many people do this) is to have a seperate <code>strings.h</code> file where I <code>#define</code> all the localize-code. For example</p> <pre><code>// In strings.h #define NSLS_COMMON_CANCEL NSLocalizedString(@"Cancel", nil) // Somewhere else NSLog(@"%@", NSLS_COMMON_CANCEL); </code></pre> <p>This essentially provides code-completion, a single place to change variable names (so no need for genstring anymore), and an unique keyword to auto-refactor. However, this comes at the cost of ending up with a whole bunch of <code>#define</code> statements that are not inherently structured (i.e. like LocString.Common.Cancel or something like that). </p> <p>So, while this works somewhat fine, I was wondering how you guys do it in your projects. Are there other approaches to simplify the use of NSLocalizedString? Is there maybe even a framework that encapsulates it?</p>
10,196,327
9
3
null
2012-03-27 18:43:44.757 UTC
74
2020-06-07 23:55:50.41 UTC
2014-06-11 07:40:46.113 UTC
null
886,407
null
886,407
null
1
145
objective-c|ios|localization|nslocalizedstring
76,141
<p><code>NSLocalizedString</code> has a few limitations, but it is so central to Cocoa that it's unreasonable to write custom code to handle localization, meaning you will have to use it. That said, a little tooling can help, here is how I proceed:</p> <h2>Updating the strings file</h2> <p><code>genstrings</code> overwrites your string files, discarding all your previous translations. I wrote <a href="https://github.com/ndfred/xcode-tools/blob/master/update_strings.py" rel="noreferrer">update_strings.py</a> to parse the old strings file, run <code>genstrings</code> and fill in the blanks so that you don't have to manually restore your existing translations. The script tries to match the existing string files as closely as possible to avoid having too big a diff when updating them.</p> <h2>Naming your strings</h2> <p>If you use <code>NSLocalizedString</code> as advertised:</p> <pre><code>NSLocalizedString(@"Cancel or continue?", @"Cancel notice message when a download takes too long to proceed"); </code></pre> <p>You may end up defining the same string in another part of your code, which may conflict as the same english term may have different meaning in different contexts (<code>OK</code> and <code>Cancel</code> come to mind). That is why I always use a meaningless all-caps string with a module-specific prefix, and a very precise description:</p> <pre><code>NSLocalizedString(@"DOWNLOAD_CANCEL_OR_CONTINUE", @"Cancel notice window title when a download takes too long to proceed"); </code></pre> <h2>Using the same string in different places</h2> <p>If you use the same string multiple times, you can either use a macro as you did, or cache it as an instance variable in your view controller or your data source. This way you won't have to repeat the description which may get stale and get inconsistent among instances of the same localization, which is always confusing. As instance variables are symbols, you will be able to use auto-completion on these most common translations, and use "manual" strings for the specific ones, which would only occur once anyway.</p> <p>I hope you'll be more productive with Cocoa localization with these tips!</p>
7,884,393
Can a directory be added to the class path at runtime?
<p>In order to better understand how things works in Java, I'd like to know if I can dynamically add, at runtime, a directory to the class path.</p> <p>For example, if I launch a <em>.jar</em> using <em>"java -jar mycp.jar"</em> and output the <em>java.class.path</em> property, I may get:</p> <pre><code>java.class.path: '.:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java' </code></pre> <p>Now can I modify this class path at runtime to add another directory? (for example before making the first call to a class using a <em>.jar</em> located in that directory I want to add).</p>
7,884,406
3
0
null
2011-10-25 03:32:01.307 UTC
13
2016-02-03 10:20:34.343 UTC
null
null
null
null
986,890
null
1
38
java|classpath
36,793
<p>You can use the following method:</p> <pre><code>URLClassLoader.addURL(URL url) </code></pre> <p>But you'll need to do this with reflection since the method is <code>protected</code>:</p> <pre><code>public static void addPath(String s) throws Exception { File f = new File(s); URL u = f.toURL(); URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class urlClass = URLClassLoader.class; Method method = urlClass.getDeclaredMethod("addURL", new Class[]{URL.class}); method.setAccessible(true); method.invoke(urlClassLoader, new Object[]{u}); } </code></pre> <p>See the Java Trail on <a href="http://download.oracle.com/javase/tutorial/reflect/" rel="noreferrer">Reflection</a>. Especially the section <em>Drawbacks of Reflection</em></p>
11,729,472
Adding data to QTableWidget using PyQt4 in Python
<p>I want to add my data to a table using pyqt in python. I found that I should use <code>setItem()</code> function to add data to a <code>QTableWidget</code> and give it the row and column number and a <code>QTableWidgetItem</code>. I did it but when I want to display the table, it's completely empty. Maybe I made a silly mistake but please help me. Here is my code: </p> <pre><code>from PyQt4 import QtGui class Table(QtGui.QDialog): def __init__(self, parent=None): super(Table, self).__init__(parent) layout = QtGui.QGridLayout() self.led = QtGui.QLineEdit("Sample") self.table = QtGui.QTableWidget() layout.addWidget(self.led, 0, 0) layout.addWidget(self.table, 1, 0) self.table.setItem(1, 0, QtGui.QTableWidgetItem(self.led.text())) self.setLayout(layout) if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) t = Table() t.show() sys.exit(app.exec_()) </code></pre>
11,731,883
1
0
null
2012-07-30 20:58:39.963 UTC
9
2013-11-07 18:33:06.193 UTC
2013-05-04 20:08:10.003 UTC
null
360,899
null
1,560,076
null
1
11
python|pyqt
40,521
<p>What you are looking for are the <code>setRowCount()</code> and <code>setColumnCount()</code> methods. Call these on the <code>QTableWidget</code> to specify the number of rows/columns. E.g.</p> <pre><code>... self.table = QtGui.QTableWidget() self.table.setRowCount(5) self.table.setColumnCount(5) layout.addWidget(self.led, 0, 0) layout.addWidget(self.table, 1, 0) self.table.setItem(1, 0, QtGui.QTableWidgetItem(self.led.text())) ... </code></pre> <p>This code will make a 5x5 table and display "Sample" in the second row (with index 1) and first column (with index 0).</p> <p>Without calling these two methods, <code>QTableWidget</code> would not know how large the table is, so setting the item at position (1, 0) would not make sense.</p> <p>In case you are unaware of it, the <a href="http://qt-project.org/doc/qt-4.8/">Qt Documentation</a> is detailed and contains many examples (which can easily be converted to Python). The "Detailed Description" sections are especially helpful. If you want more information about <code>QTableWidget</code>, go here: <a href="http://qt-project.org/doc/qt-4.8/qtablewidget.html#details">http://qt-project.org/doc/qt-4.8/qtablewidget.html#details</a></p>
12,028,416
Check if a string is rotation of another WITHOUT concatenating
<p>There are 2 strings , how can we check if one is a rotated version of another ?</p> <p><code>For Example : hello --- lohel</code></p> <p>One simple solution is by <code>concatenating</code> first string with itself and checking if the other one is a <code>substring</code> of the concatenated version. </p> <p>Is there any other solution to it ? </p> <p>I was wondering if we could use <code>circular linked list</code> maybe ? But I am not able to arrive at the solution.</p>
12,030,212
11
1
null
2012-08-19 17:18:21.087 UTC
9
2017-02-02 06:44:19.89 UTC
2012-08-19 22:17:07.567 UTC
null
971,683
null
971,683
null
1
11
string|algorithm|language-agnostic
13,241
<blockquote> <p>One simple solution is by concatenating them and checking if the other one is a substring of the concatenated version. </p> </blockquote> <p>I assume you mean concatenate the first string with itself, then check if the other one is a substring of that concatenation.</p> <p>That will work, and in fact can be done without any concatenation at all. Just use any <a href="http://en.wikipedia.org/wiki/String_searching_algorithm#Single_pattern_algorithms" rel="noreferrer">string searching algorithm</a> to search for the second string in the first, and when you reach the end, loop back to the beginning.</p> <p>For instance, using <a href="http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm" rel="noreferrer">Boyer-Moore</a> the overall algorithm would be O(n).</p>
11,528,694
Read/Parse text file line by line in VBA
<p>I'm trying to parse a text document using VBA and return the path given in the text file. For example, the text file would look like:</p> <pre><code>*Blah blah instructions *Blah blah instructions on line 2 G:\\Folder\...\data.xls D:\\AnotherFolder\...\moredata.xls </code></pre> <p>I want the VBA to load 1 line at a time, and if it starts with a <code>*</code> then move to the next line (similar to that line being commented). For the lines with a file path, I want to write that path to cell, say <code>A2</code> for the first path, <code>B2</code> for the next, etc.</p> <p>The main things I was hoping to have answered were:</p> <ol> <li>What is the best/simple way to read through a text file using VBA?</li> <li>How can I do that line by line?</li> </ol>
11,528,932
5
0
null
2012-07-17 18:33:54.987 UTC
21
2021-10-01 00:49:10.39 UTC
2021-05-09 02:26:46.753 UTC
null
3,739,391
null
817,559
null
1
62
excel|vba
421,756
<p>for the most basic read of a text file, use <code>open</code></p> <p>example:</p> <pre><code>Dim FileNum As Integer Dim DataLine As String FileNum = FreeFile() Open &quot;Filename&quot; For Input As #FileNum While Not EOF(FileNum) Line Input #FileNum, DataLine ' read in data 1 line at a time ' decide what to do with dataline, ' depending on what processing you need to do for each case Wend </code></pre> <p>#Author note - Please stop adding in <code>close #FileNum</code> - it's addressed in the comments, and it's not needed as an improvement to this answer</p>
20,255,284
Calculating running sum over partition in BigQuery
<p>I'm trying to calculate a running sum over a partition. This seems easier and quicker than the method suggested in <a href="https://stackoverflow.com/questions/14664578/bigquery-sql-running-totals">BigQuery SQL running totals</a>.</p> <p>For example:</p> <blockquote> <p>SELECT corpus,corpus_date,word_count, sum(word_count) over (partition by corpus,corpus_date order by word_count,word DESC) as running_sum FROM [publicdata:samples.shakespeare]</p> </blockquote> <p>I'm facing 2 problems:</p> <ol> <li><p>I'm unable to let the sum start with the most common word (word with highest word_count). Setting DESC or ASC just doesn't change anything, and the sum starts with the least common word(s). If I change the order by to include only "order by word_count" than the running sum isn't correct since rows with the same order (== same word_count) yield the same running sum.</p></li> <li><p>In a similar query I'm executing (see below), the first row of the running sum yields a sum of 0, although the field I sum upon isn't 0 for the first row. Why does this happen? How can I workaround the problem to show the correct running sum? The query is:</p></li> </ol> <blockquote> <p>select * from <br/> (SELECT <br/> mongo_id, <br/> account_id, <br/> event_date, <br/> trx_amount_sum_per_day, <br/> SUM (trx_amount_sum_per_day) OVER (PARTITION BY mongo_id,account_id ORDER BY event_date DESC) AS running_sum, <br/> ROW_NUMBER() OVER (PARTITION BY mongo_id,account_id ORDER BY event_date DESC) AS row_num <br/> FROM [xs-polar-gasket-4:publicdataset.publictable] <br/> ) order by event_date desc <br/></p> </blockquote>
20,255,807
1
6
null
2013-11-27 23:43:30.19 UTC
1
2013-11-30 17:55:59.18 UTC
2017-05-23 12:34:43.807 UTC
null
-1
null
2,573,392
null
1
16
google-bigquery
47,977
<p>For question 1: </p> <p>Change:</p> <pre><code>SELECT corpus, corpus_date, word_count, SUM(word_count) OVER (PARTITION BY corpus, corpus_date ORDER BY word_count, word DESC) AS running_sum FROM [publicdata:samples.shakespeare] </code></pre> <p>To:</p> <pre><code>SELECT corpus, corpus_date, word_count, SUM(word_count) OVER (PARTITION BY corpus, corpus_date ORDER BY word_count DESC, word) AS running_sum FROM [publicdata:samples.shakespeare] </code></pre> <p>(Original query is sorting by word, but you wanted to sort by word_count)</p>
20,171,165
Getting LibCurl to work with Visual Studio 2013
<p>I am having trouble getting LibCurl to work with Visual Studio 2013. I downloaded the current version (curl-7.33.0) and tried following the instructions I found on this site: <a href="http://quantcorner.wordpress.com/2012/04/08/using-libcurl-with-visual-c-2010/" rel="noreferrer">Using LibCurl with Visual 2010</a></p> <p>But I can't find <strong>curllib.lib</strong> in the folder I downloaded. And I am still getting errors: <img src="https://i.stack.imgur.com/QjfdD.png" alt="enter image description here"></p> <p>After searching the internet for more help. I now get these error messages. There appears to be a problem with linking to libcurl.lib? </p> <p><img src="https://i.stack.imgur.com/MoWfA.png" alt="enter image description here"></p> <p>This is what I have configured: <img src="https://i.stack.imgur.com/o7nXr.png" alt="enter image description here"></p> <hr> <p><img src="https://i.stack.imgur.com/xjpk3.png" alt="enter image description here"></p> <p>Inside /lib I have <strong>libcurl.lib</strong> and <strong>libcurl.dll</strong></p> <hr> <p><strong>UPDATE</strong></p> <p>I downloaded this release for Win32 MSVC: <a href="http://curl.haxx.se/download.html#Win32" rel="noreferrer">http://curl.haxx.se/download.html#Win32</a> After adding the libcurl libraries and successfully compiling, I am now getting this error message:</p> <pre><code> The application was unable to start correctly (0xc000007b). Click OK to close the application. </code></pre> <p>Here is the sample code I am trying to run:</p> <pre><code>#include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;curl/curl.h&gt; int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://google.com"); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); } return 0; } </code></pre> <hr> <p><strong>FINAL UPDATE</strong></p> <p>I believe I have gotten LibCurl to work with Visual Studio 2013 now. Persistence ftw! Although, after spending hours trying to solve these error messages, I am a little hesitant at saying everything is working fine now. That is why I am putting a bounty on this question to get <em>clear and concise</em> instructions on getting LibCurl to work with Visual Studio 2013. </p> <p>This is what I did to get it to work:</p> <ol> <li><p>First, download the Win32 MSVC package here: <a href="http://curl.haxx.se/download.html#Win32" rel="noreferrer">http://curl.haxx.se/download.html#Win32</a> For these instructions sake, let's say you downloaded to C:\LibCurl</p></li> <li><p>Start a new project in Visual Studio. Go to Project|Project Properties|VC++ Directories|Include Directories| Add the path to the include directory inside the downloaded package. (C:\LibCurl\include)</p></li> <li><p>Next, go to Project|Project Properties|Linker|General|Additional Library Directories| Add the path to the lib directory. (Where curllib.dll is located)</p></li> <li><p>Then, go to Project|Project Properties|Linker|Input|Additional Dependencies| And add <strong>curllib.lib</strong></p></li> <li><p>Now if you compile a test program, you will likely get the message saying libsasl.dll is missing. You will need to download this file and put it in the same directory as your build. I used 7-Zip to extract <strong>libsasl.dll</strong> from <strong>OpenLDAP for Windows</strong>. <a href="http://www.userbooster.de/en/download/openldap-for-windows.aspx" rel="noreferrer">OpenLDAP for Windows</a></p></li> </ol> <p>This is the result of my test code from above: <img src="https://i.stack.imgur.com/B3t3v.png" alt="enter image description here"></p>
20,293,708
10
7
null
2013-11-24 04:37:36.177 UTC
39
2018-07-07 19:52:48.913 UTC
2014-04-21 01:33:44.823 UTC
null
1,086,804
null
2,904,614
null
1
52
c++|visual-c++|dll|libcurl
58,154
<p>I would say that in a comment, but I am lacking in points. You don't have to copy any .dll into your program run catalog. Go to <strong>Project | Properties | Configuration Properties</strong> and in line <strong>Envrionment</strong> write: <code>PATH=$(ExecutablePath)$(LocalDebuggerEnvironment)</code>.</p> <p>From now on, all .dlls from any catalog you mention in <strong>Project|Project Properties|VC++ Directories|Binary</strong> should be usable without copying them.</p> <p>The rest is exactly as you written.</p>
3,911,653
Comparing user-inputted characters in C
<p>The following code snippets are from a C program.</p> <p>The user enters Y or N.</p> <pre><code>char *answer = '\0'; scanf (" %c", answer); if (*answer == ('Y' || 'y')) // do work </code></pre> <p>I can't figure out why this <code>if</code> statement doesn't evaluate to true.</p> <p>I checked for the y or n input with a <code>printf</code> and it is there, so I know I'm getting the user input. Also when I replace the the condition of the if statement with 1 (making it true), it evaluates properly.</p>
3,911,673
4
0
null
2010-10-12 04:18:06.773 UTC
5
2016-10-01 17:53:56.053 UTC
2016-10-01 17:53:56.053 UTC
null
3,923,281
null
472,907
null
1
15
c|char
150,392
<p>I see two problems:</p> <p>The pointer <code>answer</code> is a <code>null</code> pointer and you are trying to dereference it in <code>scanf</code>, this leads to <em>undefined behavior</em>. </p> <p>You don't need a <code>char</code> pointer here. You can just use a <code>char</code> variable as:</p> <pre><code>char answer; scanf(" %c",&amp;answer); </code></pre> <p>Next to see if the read character is <code>'y'</code> or <code>'Y'</code> you should do:</p> <pre><code>if( answer == 'y' || answer == 'Y') { // user entered y or Y. } </code></pre> <p>If you <em>really</em> need to use a char pointer you can do something like:</p> <pre><code>char var; char *answer = &amp;var; // make answer point to char variable var. scanf (" %c", answer); if( *answer == 'y' || *answer == 'Y') { </code></pre>
3,247,617
What happens if i return before the end of using statement? Will the dispose be called?
<p>I've the following code</p> <pre><code>using(MemoryStream ms = new MemoryStream()) { //code return 0; } </code></pre> <p>The <code>dispose()</code> method is called at the end of <code>using</code> statement braces <code>}</code> right? Since I <code>return</code> before the end of the <code>using</code> statement, will the <code>MemoryStream</code> object be disposed properly? What happens here?</p>
3,247,635
5
1
null
2010-07-14 15:15:28.697 UTC
15
2020-11-24 21:42:24.74 UTC
2010-07-14 15:19:08.173 UTC
null
16,587
null
250,524
null
1
123
c#|.net|dispose|idisposable|using-statement
33,966
<p>Yes, <code>Dispose</code> will be called. It's called as soon as the execution leaves the scope of the <code>using</code> block, regardless of what means it took to leave the block, be it the end of execution of the block, a <code>return</code> statement, or an exception. </p> <p>As @Noldorin correctly points out, using a <code>using</code> block in code gets compiled into <code>try</code>/<code>finally</code>, with <code>Dispose</code> being called in the <code>finally</code> block. For example the following code:</p> <pre><code>using(MemoryStream ms = new MemoryStream()) { //code return 0; } </code></pre> <p>effectively becomes:</p> <pre><code>MemoryStream ms = new MemoryStream(); try { // code return 0; } finally { ms.Dispose(); } </code></pre> <p>So, because <code>finally</code> is guaranteed to execute after the <code>try</code> block has finished execution, regardless of its execution path, <code>Dispose</code> is guaranteed to be called, no matter what. </p> <p>For more information, see <a href="http://msdn.microsoft.com/en-us/library/yh598w02.aspx" rel="noreferrer">this MSDN article</a>. </p> <p><em>Addendum:</em><br> Just a little caveat to add: because <code>Dispose</code> is guaranteed to be called, it's almost always a good idea to ensure that <code>Dispose</code> never throws an exception when you implement <code>IDisposable</code>. Unfortunately, there are some classes in the core library that <em>do</em> throw in certain circumstances when <code>Dispose</code> is called -- I'm looking at you, WCF Service Reference / Client Proxy! -- and when that happens it can be very difficult to track down the original exception if <code>Dispose</code> was called during an exception stack unwind, since the original exception gets swallowed in favor of the new exception generated by the <code>Dispose</code> call. It can be maddeningly frustrating. Or is that frustratingly maddening? One of the two. Maybe both. </p>
3,479,094
Is Razor view with ASPX .Master page possible?
<p>Is it possible to keep my existing .master page and have it used with a new ASP.NET MVC 3 Razor view? I tried this: </p> <pre><code>@{ LayoutPage = "~/Views/Shared/Site.master"; } </code></pre> <p>And it gives me this error message: </p> <p>The file '~/Views/Shared/Site.master' could not be rendered, because it does not exist or is not a valid page.</p>
3,484,016
6
0
null
2010-08-13 16:59:03.413 UTC
6
2014-04-15 10:41:07.937 UTC
null
null
null
null
265,570
null
1
38
asp.net-mvc|razor
23,700
<p>Unfortunately no. Master pages are a part of the ASPX WebForms view engine, not the MVC framework so Razor cannot interoperate with it.</p> <p>One option would be to duplicate the masters, as you mentioned, but rather than copying all the code, you could factor the Master page into a bunch of ASPX partials that the Razor and ASPX masters could embed. Then you can start converting each page and partial, one-by-one, to Razor and eventually get rid of the ASPX master.</p>
3,870,091
Entity Framework/Linq to SQL: Skip & Take
<p>Just curious as to how Skip &amp; Take are supposed to work. I'm getting the results I want to see on the client side, but when I hook up the AnjLab SQL Profiler and look at the SQL that is being executed it looks as though it is querying for and returning the entire set of rows to the client.</p> <p>Is it really returning all the rows then sorting and narrowing down stuff with LINQ on the client side?</p> <p>I've tried doing it with both Entity Framework and Linq to SQL; both appear to have the same behavior.</p> <p>Not sure it makes any difference, but I'm using C# in VWD 2010.</p> <p>Any insight?</p> <pre><code>public IEnumerable&lt;Store&gt; ListStores(Func&lt;Store, string&gt; sort, bool desc, int page, int pageSize, out int totalRecords) { var context = new TectonicEntities(); totalRecords = context.Stores.Count(); int skipRows = (page - 1) * pageSize; if (desc) return context.Stores.OrderByDescending(sort).Skip(skipRows).Take(pageSize).ToList(); return context.Stores.OrderBy(sort).Skip(skipRows).Take(pageSize).ToList(); } </code></pre> <p>Resulting SQL (Note: I'm excluding the Count query):</p> <pre><code>SELECT [Extent1].[ID] AS [ID], [Extent1].[Name] AS [Name], [Extent1].[LegalName] AS [LegalName], [Extent1].[YearEstablished] AS [YearEstablished], [Extent1].[DiskPath] AS [DiskPath], [Extent1].[URL] AS [URL], [Extent1].[SecureURL] AS [SecureURL], [Extent1].[UseSSL] AS [UseSSL] FROM [dbo].[tec_Stores] AS [Extent1] </code></pre> <p>After some further research, I found that the following works the way I would expect it to:</p> <pre><code>public IEnumerable&lt;Store&gt; ListStores(Func&lt;Store, string&gt; sort, bool desc, int page, int pageSize, out int totalRecords) { var context = new TectonicEntities(); totalRecords = context.Stores.Count(); int skipRows = (page - 1) * pageSize; var qry = from s in context.Stores orderby s.Name ascending select s; return qry.Skip(skipRows).Take(pageSize); } </code></pre> <p>Resulting SQL:</p> <pre><code>SELECT TOP (3) [Extent1].[ID] AS [ID], [Extent1].[Name] AS [Name], [Extent1].[LegalName] AS [LegalName], [Extent1].[YearEstablished] AS [YearEstablished], [Extent1].[DiskPath] AS [DiskPath], [Extent1].[URL] AS [URL], [Extent1].[SecureURL] AS [SecureURL], [Extent1].[UseSSL] AS [UseSSL] FROM ( SELECT [Extent1].[ID] AS [ID], [Extent1].[Name] AS [Name], [Extent1].[LegalName] AS [LegalName], [Extent1].[YearEstablished] AS [YearEstablished], [Extent1].[DiskPath] AS [DiskPath], [Extent1].[URL] AS [URL], [Extent1].[SecureURL] AS [SecureURL], [Extent1].[UseSSL] AS [UseSSL], row_number() OVER (ORDER BY [Extent1].[Name] ASC) AS [row_number] FROM [dbo].[tec_Stores] AS [Extent1] ) AS [Extent1] WHERE [Extent1].[row_number] &gt; 3 ORDER BY [Extent1].[Name] ASC </code></pre> <p>I really like the way the first option works; Passing in a lambda expression for sort. Is there any way to accomplish the same thing in the LINQ to SQL orderby syntax? I tried using qry.OrderBy(sort).Skip(skipRows).Take(pageSize), but that ended up giving me the same results as my first block of code. Leads me to believe my issues are somehow tied to OrderBy.</p> <p>====================================</p> <h1>PROBLEM SOLVED</h1> <p>Had to wrap the incoming lambda function in Expression: </p> <pre><code>Expression&lt;Func&lt;Store,string&gt;&gt; sort </code></pre>
3,874,717
6
3
null
2010-10-06 06:56:04.02 UTC
17
2019-12-26 12:47:36.073 UTC
2010-10-06 18:08:18.373 UTC
null
139,694
null
139,694
null
1
52
c#|.net|linq-to-sql|sql-server-2008|entity-framework-4
88,093
<p>The following works and accomplishes the simplicity I was looking for:</p> <pre><code>public IEnumerable&lt;Store&gt; ListStores(Expression&lt;Func&lt;Store, string&gt;&gt; sort, bool desc, int page, int pageSize, out int totalRecords) { List&lt;Store&gt; stores = new List&lt;Store&gt;(); using (var context = new TectonicEntities()) { totalRecords = context.Stores.Count(); int skipRows = (page - 1) * pageSize; if (desc) stores = context.Stores.OrderByDescending(sort).Skip(skipRows).Take(pageSize).ToList(); else stores = context.Stores.OrderBy(sort).Skip(skipRows).Take(pageSize).ToList(); } return stores; } </code></pre> <p>The main thing that fixed it for me was changing the Func sort parameter to:</p> <pre><code>Expression&lt;Func&lt;Store, string&gt;&gt; sort </code></pre>
4,005,728
hide default keyboard on click in android
<p>i want to hide the soft keyboard when i click out side of editbox in a screen. how can i do this?</p>
4,009,104
10
2
null
2010-10-23 19:41:47.607 UTC
13
2016-05-27 06:58:19.543 UTC
2010-10-23 20:42:43.18 UTC
null
30,618
null
307,585
null
1
16
android
34,813
<p>To forcibly hide the keyboard you would use the following code... I put it in a method called 'hideSoftKeyboard()'. As mentioned by Falmarri, the softkeyboard <em>should</em> hide itself when you click out of it. However, if you call this method in an 'onClick()' of another item, it will forcibly close the keyboard.</p> <pre><code>private void hideSoftKeyboard(){ if(getCurrentFocus()!=null &amp;&amp; getCurrentFocus() instanceof EditText){ InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(yourEditTextHere.getWindowToken(), 0); } } </code></pre>
3,636,052
HTML book-like pagination
<p>How can I split the content of a HTML file in screen-sized chunks to "paginate" it in a WebKit browser? </p> <p>Each "page" should show a complete amount of text. This means that a line of text must not be cut in half in the top or bottom border of the screen.</p> <p><strong>Edit</strong></p> <p>This question was originally tagged "Android" as my intent is to build an Android ePub reader. However, it appears that the solution can be implemented just with JavaScript and CSS so I broadened the scope of the question to make it platform-independent.</p>
3,859,331
10
5
null
2010-09-03 13:11:23.827 UTC
59
2019-08-04 20:50:56.477 UTC
2010-10-03 10:40:38.647 UTC
null
143,378
null
143,378
null
1
62
javascript|html|css|webkit|pagination
26,615
<p>Building on Dan's answer here is my solution for this problem, with which I was struggling myself until just now. (this JS works on iOS Webkit, no guarantees for android, but please let me know the results)</p> <pre><code>var desiredHeight; var desiredWidth; var bodyID = document.getElementsByTagName('body')[0]; totalHeight = bodyID.offsetHeight; pageCount = Math.floor(totalHeight/desiredHeight) + 1; bodyID.style.padding = 10; //(optional) prevents clipped letters around the edges bodyID.style.width = desiredWidth * pageCount; bodyID.style.height = desiredHeight; bodyID.style.WebkitColumnCount = pageCount; </code></pre> <p>Hope this helps...</p>
3,965,676
Why did my Git repo enter a detached HEAD state?
<p>I ended up with a detached head today, the same problem as described in: <a href="https://stackoverflow.com/questions/999907/git-push-says-everything-up-to-date-even-though-i-have-local-changes">git push says everything up-to-date even though I have local changes</a></p> <p>As far as I know I didn't do anything out of the ordinary, just commits and pushes from my local repo. </p> <p>So how did I end up with a <code>detached HEAD</code>?</p>
3,965,714
14
8
null
2010-10-19 05:54:02.153 UTC
138
2022-09-14 17:04:14.68 UTC
2017-05-23 11:47:29.557 UTC
null
-1
null
182,603
null
1
458
git
310,657
<p>Any checkout of a commit that is not the name of one of <em>your</em> branches will get you a detached HEAD. A SHA1 which represents the tip of a branch still gives a detached HEAD. Only a checkout of a local branch <em>name</em> avoids that mode.</p> <p>See <a href="http://marklodato.github.com/visual-git-guide/index-en.html#detached" rel="noreferrer">committing with a detached HEAD</a></p> <blockquote> <p>When HEAD is detached, commits work like normal, except no named branch gets updated. (You can think of this as an anonymous branch.)</p> </blockquote> <p><img src="https://i.stack.imgur.com/YwJDh.png" alt="alt text" /></p> <p>For example, if you checkout a &quot;remote branch&quot; without tracking it first, you can end up with a detached HEAD.</p> <p>See <a href="https://stackoverflow.com/questions/471300/git-switch-branch-without-detaching-head">git: switch branch without detaching head</a></p> <p>Meaning: <code>git checkout origin/main</code> (or <a href="https://stackoverflow.com/a/62983443/6309"><code>origin/master</code> in the old days</a>) would result in:</p> <pre class="lang-sh prettyprint-override"><code>Note: switching to 'origin/main'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c &lt;new-branch-name&gt; Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at a1b2c3d My commit message </code></pre> <p>That is why you should not use <a href="https://git-scm.com/docs/git-checkout" rel="noreferrer"><code>git checkout</code></a> anymore, but the new <a href="https://git-scm.com/docs/git-switch" rel="noreferrer"><code>git switch</code></a> command.</p> <p>With <code>git switch</code>, the same attempt to &quot;checkout&quot; (switch to) a remote branch would fail immediately:</p> <pre class="lang-sh prettyprint-override"><code>git switch origin/main fatal: a branch is expected, got remote branch 'origin/main' </code></pre> <hr /> <p>To add more on <code>git switch</code>:</p> <p>With Git 2.23 (August 2019), you don't have to use the <a href="https://stackoverflow.com/a/57066202/6309">confusing <code>git checkout</code> command</a> anymore.</p> <p><a href="https://git-scm.com/docs/git-switch" rel="noreferrer"><code>git switch</code></a> can also checkout a branch, and get a detach HEAD, except:</p> <ul> <li>it has an explicit <code>--detach</code> option</li> </ul> <blockquote> <p>To check out commit <code>HEAD~3</code> for temporary inspection or experiment without creating a new branch:</p> <pre><code>git switch --detach HEAD~3 HEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits' </code></pre> </blockquote> <ul> <li>it cannot detached by mistake a remote tracking branch</li> </ul> <p>See:</p> <pre><code>C:\Users\vonc\arepo&gt;git checkout origin/master Note: switching to 'origin/master'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. </code></pre> <p>Vs. using the new <code>git switch</code> command:</p> <pre><code>C:\Users\vonc\arepo&gt;git switch origin/master fatal: a branch is expected, got remote branch 'origin/master' </code></pre> <p>If you wanted to create a new local branch tracking a remote branch:</p> <pre><code>git switch &lt;branch&gt; </code></pre> <blockquote> <p>If <code>&lt;branch&gt;</code> is not found but there does exist a tracking branch in exactly one remote (call it <code>&lt;remote&gt;</code>) with a matching name, treat as equivalent to</p> <pre><code>git switch -c &lt;branch&gt; --track &lt;remote&gt;/&lt;branch&gt; </code></pre> </blockquote> <p>No more mistake!<br /> No more unwanted detached HEAD!</p> <p>And if you <code>git switch &lt;tag&gt;</code> instead of <code>git switch --detach &lt;tag&gt;</code>, <a href="https://stackoverflow.com/a/71428295/6309">Git 2.36 will help you to remember the missing <code>--detach</code> option</a>.</p>
3,701,646
How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
<p>I have a directory which hosts all of my Django apps (<code>C:\My_Projects</code>). I want to add this directory to my <code>PYTHONPATH</code> so I can call the apps directly.</p> <p>I tried adding <code>C:\My_Projects\;</code> to my Windows <code>Path</code> variable from the Windows GUI (<code>My Computer &gt; Properties &gt; Advanced System Settings &gt; Environment Variables</code>). But it still doesn't read the coltrane module and generates this error:</p> <blockquote> <p>Error: No module named coltrane</p> </blockquote>
4,855,685
23
3
null
2010-09-13 15:04:26.503 UTC
197
2022-07-05 16:03:11.47 UTC
2019-05-04 11:11:37.787 UTC
null
202,229
null
234,543
null
1
445
python|windows|environment-variables|pythonpath
1,759,319
<p>You know what has worked for me really well on windows.</p> <p><code>My Computer &gt; Properties &gt; Advanced System Settings &gt; Environment Variables &gt;</code> </p> <p>Just add the path as C:\Python27 (or wherever you installed python)</p> <p>OR</p> <p>Then under system variables I create a new Variable called <code>PythonPath</code>. In this variable I have <code>C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-folders-on-the-path</code></p> <p><img src="https://i.stack.imgur.com/ZGp36.png" alt="enter image description here"></p> <p>This is the best way that has worked for me which I hadn't found in any of the docs offered.</p> <p><strong>EDIT:</strong> For those who are not able to get it, Please add </p> <blockquote> <p>C:\Python27;</p> </blockquote> <p>along with it. Else it will <em>never work</em>.</p>
8,242,684
How to select a row in Jquery datatable
<p>I am using <a href="http://datatables.net/" rel="noreferrer">datatables</a> in my application. Whenever user click on any row I want to highlight it and pick some values from selected row.</p> <pre><code>"oTableTools": { "sRowSelect": "single", "fnRowSelected": function ( node ) { var s=$(node).children(); alert("Selected Row : " + $s[0]); } </code></pre> <p>I tried <code>sRowSelect</code> and <code>fnRowSelected</code> but no luck. The row is not highlighted and neither <code>fnRowSelected</code> is called. Even no error on console. </p> <p>Here is my complete code </p> <pre><code> var userTable = $('#users').dataTable({ "bPaginate": true, "bScrollCollapse": true, "iDisplayLength": 10, "bFilter": false, "bJQueryUI": true, "sPaginationType": "full_numbers", "oLanguage": { "sLengthMenu": "Display _MENU_ records per page", "sZeroRecords": "Enter a string and click on search", "sInfo": "Showing _START_ to _END_ of _TOTAL_ results", "sInfoEmpty": "Showing 0 to 0 of 0 results", "sInfoFiltered": "(filtered from _MAX_ total results)" }, "aaSorting": [[ 0, "asc" ]], "aoColumns": [/* Name */ null, /*Institution*/null, /*Email*/null], "oTableTools": { "sRowSelect": "single", "fnRowSelected": function ( node ) { alert("Clicked"); } } }); </code></pre> <p>Am I missing anything ? </p> <p><strong>EDIT:</strong><br> Now able to highlight selected row.Added class="display" to HTML table. Still wondering why I didn't find this in datatable docs. Now looking how to collect selected values. </p>
8,254,563
4
0
null
2011-11-23 13:06:48.53 UTC
3
2015-05-09 11:38:24.39 UTC
2011-11-23 16:58:07.14 UTC
null
705,773
null
705,773
null
1
11
javascript|jquery|datatables
41,953
<p>Here is how I do it</p> <p>just add this function to your page (if users is your table id)</p> <pre><code>$("#users tbody").delegate("tr", "click", function() { var iPos = userTable.fnGetPosition( this ); if(iPos!=null){ //couple of example on what can be done with the clicked row... var aData = userTable.fnGetData( iPos );//get data of the clicked row var iId = aData[1];//get column data of the row userTable.fnDeleteRow(iPos);//delete row } </code></pre>
8,085,785
Trying to "follow" someone on Twitter using new iOS 5 API, getting 406 return error. Why?
<p>Trying to "follow" someone on Twitter using new iOS 5 API, getting 406 return error. Why?</p> <p>Is my code correct? Need to find out why this isn't working....</p> <pre><code> - (void)followOnTwitter:(id)sender { ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) { if(granted) { // Get the list of Twitter accounts. NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; // For the sake of brevity, we'll assume there is only one Twitter account present. // You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present. if ([accountsArray count] &gt; 0) { // Grab the initial Twitter account to tweet from. ACAccount *twitterAccount = [accountsArray objectAtIndex:0]; NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init]; [tempDict setValue:@"sortitapps" forKey:@"screen_name"]; [tempDict setValue:@"true" forKey:@"follow"]; TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/friendships/create.format"] parameters:tempDict requestMethod:TWRequestMethodPOST]; [postRequest setAccount:twitterAccount]; [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]]; NSLog(@"%@", output); }]; } } }]; } </code></pre> <p>All of the code looks correct. Are the parameters incorrect? Is the URL correct? Need some direction here....</p>
8,145,402
4
2
null
2011-11-10 20:24:05.55 UTC
16
2016-06-21 15:07:31.513 UTC
null
null
null
null
546,509
null
1
28
iphone|objective-c|cocoa-touch|twitter|ios5
8,331
<p>Found the answer to my own question... I changed the URL to <a href="https://api.twitter.com/1/friendships/create.json" rel="noreferrer">https://api.twitter.com/1/friendships/create.json</a> and it worked.</p> <p>Don't forget it's https, not just http.</p>
7,708,373
Get ffmpeg information in friendly way
<p>Every time I try to get some information about my video files with ffmpeg, it pukes a lot of useless information mixed with good things.</p> <p>I'm using <code>ffmpeg -i name_of_the_video.mpg</code>.</p> <p>There are any possibilities to get that in a friendly way? I mean JSON would be great (and even ugly XML is fine).</p> <p>By now, I made my application parse the data with regex but there are lots of nasty corners that appear on some specific video files. I fixed all that I encountered, but there may be more.</p> <p>I wanted something like:</p> <pre><code>{ "Stream 0": { "type": "Video", "codec": "h264", "resolution": "720x480" }, "Stream 1": { "type": "Audio", "bitrate": "128 kbps", "channels": 2 } } </code></pre>
8,191,228
4
2
null
2011-10-10 03:50:47.367 UTC
42
2020-12-17 16:25:03.14 UTC
null
null
null
null
754,991
null
1
125
json|parsing|ffmpeg
88,585
<p>A bit late, but perhaps still relevant to someone..</p> <p><code>ffprobe</code> is indeed an excellent way to go. Note, though, that you need to tell <code>ffprobe</code> what information you want it to display (with the <code>-show_format</code>, <code>-show_packets</code> and <code>-show_streams</code> options) or it'll just give you blank output (like you mention in one of your comments).</p> <p>For example, <code>ffprobe -v quiet -print_format json -show_format -show_streams somefile.asf</code> would yield something like the following:</p> <pre><code>{ "streams": [{ "index": 0, "codec_name": "wmv3", "codec_long_name": "Windows Media Video 9", "codec_type": "video", "codec_time_base": "1/1000", "codec_tag_string": "WMV3", "codec_tag": "0x33564d57", "width": 320, "height": 240, "has_b_frames": 0, "pix_fmt": "yuv420p", "level": -99, "r_frame_rate": "30000/1001", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_time": "0.000", "duration": "300.066", "tags": { "language": "eng" } }], "format": { "filename": "somefile.asf", "nb_streams": 1, "format_name": "asf", "format_long_name": "ASF format", "start_time": "0.000", "duration": "300.066", "tags": { "WMFSDKVersion": "10.00.00.3646", "WMFSDKNeeded": "0.0.0.0000", "IsVBR": "0" } } } </code></pre>
8,244,827
How would I change the border color of a button?
<p>This is my code:</p> <pre><code>buttonName = "btn" + y.ToString() + x.ToString(); Control btn = this.Controls.Find(buttonName, true)[0] as Control; btn.BackColor = System.Drawing.Color.Blue; </code></pre> <p>However, I see no border color changing properties, or the like.</p> <p>I used this code because I have a lot of buttons on my form, and any of those buttons' properties can change, so rather than call them out individually, I just made up that code which could handle them.</p> <p>Is there a code similar to the one above, that would allow me to change the border color of the button?</p>
8,244,966
5
2
null
2011-11-23 15:32:27.087 UTC
3
2018-10-07 01:08:18.103 UTC
2015-04-21 18:35:52.203 UTC
null
2,718,186
null
865,796
null
1
34
c#|winforms
112,561
<p>I am not sure what sort of application you are working on, however in winforms there is no border property for a button directly on it, even in the designer. You can use a flat style button. And your type will have to be button.</p> <p>you can do it like:</p> <pre><code>buttonName = "btn" + y.ToString() + x.ToString(); Button btn = this.Controls.Find(buttonName, true)[0] as Button; btn.BackColor = System.Drawing.Color.Blue; btn.FlatStyle = FlatStyle.Flat btn.FlatAppearance.BorderColor = Color.Red; btn.FlatAppearance.BorderSize = 1; </code></pre> <p>Unfortunately, this will only work on button with a FlatStyle.</p>
8,068,317
How to develop iPhone MDM Server?
<p>I just read about Mobile Device Management Server for iOS devices, but all documentations refers to "third party MDM Server".</p> <p>My problem is how can I develop one "third party MDM Server" myself ? I failed to find any doc about this.</p>
8,153,598
7
9
null
2011-11-09 16:39:10.317 UTC
29
2017-05-22 13:08:00.593 UTC
2015-09-18 02:20:12.47 UTC
null
1,677,912
null
690,629
null
1
32
ios|iphone|mdm
30,392
<p>You have the easy way and the hard way.</p> <p><strong>Easy way</strong>: OSX Lion Server ships with a "Profile Manager" section which offers the whole MDM process (with the SCEP stack). This service is made up of ruby scripts so you can peek to see how it's done.</p> <p><strong>Hard way</strong>: implement your Profile Manager (profile generation and management), implement your Push server, add the SCEP stack (and the LDAP or Active Directory if you need to) and pray for everything to works together.</p> <p>I choose the easy way :)</p>
8,048,584
See changes to a specific file using git
<p>I know that I can use the <code>git diff</code> command to check the changes, but, as far as I understood, it is directory based. This means it gives all the changes of all files on the current directory.</p> <p><em>How can I check only the changes in one specific file?</em> Say, I have changed files <code>file_1.rb</code>, <code>file_2.rb</code>, ..., <code>file_N.rb</code>, but I am only interested in the changes in the file <code>file_2.rb</code>. How do I check these changes then (before I commit)?</p>
8,048,608
11
3
null
2011-11-08 09:55:06.51 UTC
89
2021-10-26 19:09:01.927 UTC
2018-10-14 18:58:12.147 UTC
null
3,924,118
null
475,850
null
1
635
git|git-svn
648,116
<p>Use a command like:</p> <pre><code>git diff file_2.rb </code></pre> <p>See the <a href="http://schacon.github.com/git/git-diff.html" rel="noreferrer"><code>git diff</code> documentation</a> for full information on the kinds of things you can get differences for.</p> <p>Normally, <code>git diff</code> by itself shows all the changes in the whole <em>repository</em> (not just the current directory).</p>
7,952,154
Spring RestTemplate - how to enable full debugging/logging of requests/responses?
<p>I have been using the Spring RestTemplate for a while and I consistently hit a wall when I'am trying to debug it's requests and responses. I'm basically looking to see the same things as I see when I use curl with the "verbose" option turned on. For example :</p> <pre><code>curl -v http://twitter.com/statuses/public_timeline.rss </code></pre> <p>Would display both the sent data and the received data (including the headers, cookies, etc.).</p> <p>I have checked some related posts like : <a href="https://stackoverflow.com/questions/3892018/how-do-i-log-response-in-spring-resttemplate">How do I log response in Spring RestTemplate?</a> but I haven't managed to solve this issue.</p> <p>One way to do this would be to actually change the RestTemplate source code and add some extra logging statements there, but I would find this approach really a last resort thing. There should be some way to tell Spring Web Client/RestTemplate to log everything in a much friendlier way.</p> <p>My goal would be to be able to do this with code like :</p> <pre><code>restTemplate.put("http://someurl", objectToPut, urlPathValues); </code></pre> <p>and then to get the same type of debug information (as I get with curl) in the log file or in the console. I believe this would be extremely useful for anyone that uses the Spring RestTemplate and has problems. Using curl to debug your RestTemplate problems just doesn't work (in some cases). </p>
7,964,142
29
7
null
2011-10-31 09:58:48.107 UTC
105
2022-07-16 03:55:02.16 UTC
2017-05-23 12:26:07.92 UTC
null
-1
null
619,596
null
1
254
java|debugging|logging|resttemplate
316,504
<p>I finally found a way to do this in the right way. Most of the solution comes from <a href="https://stackoverflow.com/questions/3387441/how-do-i-configure-spring-and-slf4j-so-that-i-can-get-logging">How do I configure Spring and SLF4J so that I can get logging?</a></p> <p>It seems there are two things that need to be done :</p> <ol> <li>Add the following line in log4j.properties : <code>log4j.logger.httpclient.wire=DEBUG</code></li> <li>Make sure spring doesn't ignore your logging config</li> </ol> <p>The second issue happens mostly to spring environments where slf4j is used (as it was my case). As such, when slf4j is used make sure that the following two things happen :</p> <ol> <li><p>There is no commons-logging library in your classpath : this can be done by adding the exclusion descriptors in your pom :</p> <pre><code> &lt;exclusions&gt;&lt;exclusion&gt; &lt;groupId&gt;commons-logging&lt;/groupId&gt; &lt;artifactId&gt;commons-logging&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; </code></pre></li> <li><p>The log4j.properties file is stored somewhere in the classpath where spring can find/see it. If you have problems with this, a last resort solution would be to put the log4j.properties file in the default package (not a good practice but just to see that things work as you expect)</p></li> </ol>
4,404,725
Why do some includes need the .h and others not?
<p>Why is map imported as <code>#include &lt;map&gt;</code>, but stdio imported as <code>#include &lt;stdio.h&gt;</code>?</p>
4,404,753
3
13
null
2010-12-10 01:02:51.31 UTC
11
2010-12-10 14:19:51.06 UTC
null
null
null
null
165,495
null
1
34
c++|include
8,219
<p>All standard C++ headers don't want the <code>.h</code> in the end. I read somewhere that the concept is that they don't need to be actual files, <s>even if I never saw an implementation do it in another manner</s> <strong><em>edit:</em></strong> <i>actually the compiler intrinsics should work considering the headers included but not actually including them as files; see <em>@Yttrill</em>'s comment</i>.</p> <p>For the <code>stdio.h</code> thing, in a C++ application you shouldn't include <code>&lt;stdio.h&gt;</code>, but you should instead include <code>&lt;cstdio&gt;</code>. In general, you shouldn't include the "normal" C headers, but their C++-ized counterparts, which haven't got the <code>.h</code> in the end, have a <code>c</code> in front and <em>put all the symbols defined in them in the <code>std</code> namespace</em>. So, <code>&lt;math.h&gt;</code> becomes <code>&lt;cmath&gt;</code>, <code>&lt;stdlib.h&gt;</code> becomes <code>&lt;cstdlib&gt;</code>, and so on.</p> <p>In general, you should use the C++-ized versions of C headers both to avoid to pollute the global namespace (assuming you're not one of those guys who put <code>using namespace std;</code> everywhere) and to benefit of some C++ improvements to the standard C headers (e.g. added overloading to some math functions). <hr /> In general, the implementation of this whole thing is simply done by having such files without extension in the directory in which the compiler looks for the header files. In my g++ 4.4 installation, for example, you have:</p> <pre><code>matteo@teoubuntu:/usr/include/c++/4.4$ ls algorithm cstdarg functional sstream array cstdatomic initializer_list stack backward cstdbool iomanip stdatomic.h bits cstddef ios stdexcept bitset cstdint iosfwd streambuf c++0x_warning.h cstdio iostream string cassert cstdlib istream system_error ccomplex cstring iterator tgmath.h cctype ctgmath limits thread cerrno ctime list tr1 cfenv cwchar locale tr1_impl cfloat cwctype map tuple chrono cxxabi-forced.h memory typeinfo cinttypes cxxabi.h mutex type_traits ciso646 debug new unordered_map climits deque numeric unordered_set clocale exception ostream utility cmath exception_defines.h parallel valarray complex exception_ptr.h queue vector complex.h ext random x86_64-linux-gnu condition_variable fenv.h ratio csetjmp forward_list regex csignal fstream set </code></pre> <p>The C++-ized C headers <em>in theory</em> could just be a</p> <pre><code>namespace std { #include &lt;original_C_header.h&gt; }; </code></pre> <p>but in general they are more complicated to deal with implementation-specific problems (especially regarding macros) and to add C++-related functionality (see e.g. the previous example of added overloads in <code>&lt;cmath&gt;</code>).</p> <p><hr /> By the way, the C++ standard (§D.5) do not say that the <code>&lt;c***&gt;</code> headers should behave as if they included the <code>&lt;***.h&gt;</code> headers in a <code>namespace std</code> directive, but the opposite:</p> <blockquote> <p>For compatibility with the Standard C library, the C++ Standard library provides the 18 C headers [...] Each C header, whose name has the form name.h, behaves as if each name placed in the Standard library namespace by the corresponding cname header is also placed within the namespace scope of the name-space std and is followed by an explicit using-declaration (7.3.3)</p> </blockquote> <p>Notice that such headers are considered deprecated (§C.2.1), so this is the main reason you shouldn't use them:</p> <blockquote> <p><strong>C.2.1 Modifications to headers</strong> For compatibility with the Standard C library, the C++ Standard library provides the 18 C headers (D.5), but their use is deprecated in C++.</p> </blockquote>
14,866,418
Self resize and center a window using javascript (no jquery) on page load
<p>This is not something we'd normally do but we're trying load a video into the blank window opened by a clickTag (from a banner ad) - and make it feel like a modal window as much as possible.</p> <p><strong>Is it possible to use javascript to self-resize the blank window opened by the clickTag and center it on the screen?</strong></p> <ul> <li>We can't apply anything to the link that is clicked so...</li> <li>Everything has to self-run as the page loads</li> <li>If possible, it would be nice to not see the browser tabs and address bar</li> <li>We're not loading jquery</li> <li>Are browser security alerts a potential problem?</li> </ul> <p>Essentially the user clicks to watch a video and we'd like them to watch the video without them feeling like they've gone to a completely different site.</p> <p>So far I can resize the window but can't figure out how to center it with:</p> <pre><code>&lt;script language="javascript"&gt; function resizeVideoPage(){ resizeTo(400,390); window.focus(); } &lt;/script&gt; // Then... &lt;body onload="resizeVideoPage();"&gt;&lt;/body&gt; </code></pre> <p>Any pointers in the right direction would be much appreciated.</p> <p>Cheers</p> <p>Ben</p>
14,866,769
2
0
null
2013-02-14 01:35:23.247 UTC
3
2014-08-14 16:10:54.543 UTC
2013-02-14 01:42:47.53 UTC
null
854,987
null
854,987
null
1
5
javascript|resize|window|center
55,213
<p>I personally would advice against Popups an Javascript window manipulation. (due to Popup Blockers, Javascript errors, ...) A Overlay would probably be better.</p> <p>Here would be an other Solution.</p> <p>File one(Link should point to this Helper, that opens the Video HTML)</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script&gt; var windowWidth = 400; var windowHeight = 200; var xPos = (screen.width/2) - (windowWidth/2); var yPos = (screen.height/2) - (windowHeight/2); window.open("popup.html","POPUP","width=" + windowWidth+",height="+windowHeight +",left="+xPos+",top="+yPos); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>File Two (Video that closes Helper)</p> <pre><code>&lt;html&gt; &lt;body onload="window.opener.close();"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
14,448,606
Sync Emacs AUCTeX with Sumatra PDF
<p>With these lines in my <code>init.el</code> I am able to sync the Emacs LaTeX buffer with Sumatra:</p> <pre><code>(setq TeX-source-correlate-mode t) (setq TeX-source-correlate-method 'synctex) (setq TeX-view-program-list '(("Sumatra PDF" ("\"C:/bin86/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o")))) (setq TeX-view-program-selection '(((output-dvi style-pstricks) "dvips and start") (output-dvi "Yap") (output-pdf "Sumatra PDF") (output-html "start"))) </code></pre> <p>To set a double click on the PDF to get me to the related LaTeX code, I also set in Sumatra options <code>Set inverse search command line</code> to:</p> <pre><code>"c:\bin86\GNU Emacs 24.2\bin\emacsclient.exe" --no-wait +%l "%f" </code></pre> <p>Despite the sync works, I’d like to code it differently.</p> <p>If I didn’t set the last expression, <code>(setq TeX-view-program-selection...</code>, I would get the default values, which are the same as above, apart from the value for the PDF output that would be: <code>(output-pdf "start")</code>. I’d like to change this one to "Sumatra PDF" and leave the other values to their default, that is, I’d like to ask Emacs the default values for the viewers and change only the PDF value. </p> <p>It is mostly an ELisp question concerning the manipulation of the variable <code>TeX-view-program-selection</code>. Thanks for helping. </p> <p>P.S. Please tell me if this question is best fit on <a href="http://tex.stackexchange.com">tex.stackexchange</a> </p> <h2>Update based on lunaryorn comments/answer</h2> <p>To update <code>TeX-view-program-selection</code> I could use:</p> <pre><code>(assq-delete-all 'output-pdf TeX-view-program-selection) (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")) </code></pre> <p>The first line is optional, but it makes the list look "cleaner". </p> <p>In both cases (with or without <code>assq-delete-all</code>) I now need to insert the code in the proper hook, since <code>TeX-view-program-selection</code> is void in <code>init.el</code>.</p>
14,629,767
5
4
null
2013-01-21 22:47:07.367 UTC
9
2015-01-29 02:39:52.973 UTC
2013-01-23 14:23:37.963 UTC
null
1,851,270
null
1,851,270
null
1
6
emacs|latex|elisp|auctex
6,111
<p>My credits to lunaryorn for suggestions! I am repackaging the steps involved to the benefits of the others. </p> <h2>Emacs side</h2> <p>Add to your <code>init.el</code>:</p> <pre><code>(setq TeX-PDF-mode t) (setq TeX-source-correlate-mode t) (setq TeX-source-correlate-method 'synctex) (setq TeX-view-program-list '(("Sumatra PDF" ("\"path/to/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o")))) (eval-after-load 'tex '(progn (assq-delete-all 'output-pdf TeX-view-program-selection) (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")))) </code></pre> <h2>Sumatra side</h2> <p>In Settings->Options dialog set <code>Set inverse search command line</code> to:</p> <pre><code>"path\to\GNU Emacs ver\bin\emacsclient.exe" --no-wait +%l "%f" </code></pre> <h2>How to use</h2> <p>In your LaTeX document in Emacs type <code>C-c C-v</code> or double click the related PDF in Sumatra and ... enjoy))</p>
4,247,772
Can I use .delay() together with .animate() in jQuery?
<p>I have this code, which slides open a basket preview on a website I am working on. It stays open if the user is hovered on it, but I want it to have a two second delay before the callback for my hover is triggered. This is just in case the user didn't want the mouse to leave the basket area.</p> <p>Below is the code I am using to animate the basket:</p> <pre><code>$('.cart_button, .cart_module').hover(function(){ $(".cart_module").stop().animate({top:'39px'},{duration:500}); }, function(){ $('.cart_module').stop().animate({top: -cartHeight},{duration:500}) }); </code></pre> <p>Here is the code I tried to use, but had no affect:</p> <pre><code>$('.cart_button, .cart_module').hover(function(){ $(".cart_module").delay().animate({top:'39px'},{duration:500}); }, function(){ $('.cart_module').delay().animate({top: -cartHeight},{duration:500}) }); </code></pre>
4,248,051
4
2
null
2010-11-22 16:37:59.133 UTC
5
2015-05-05 16:03:24.027 UTC
2012-12-04 20:32:29.577 UTC
null
63,550
null
300,329
null
1
19
jquery|jquery-animate|delay
88,053
<p>I've always managed this kind of things with the help of core <code>setTimeout</code> and <code>clearTimeout</code> js functions.</p> <p>Here is an <a href="http://www.jsfiddle.net/Semqg/" rel="nofollow">example on jsFiddle</a></p> <p>Take a look at <a href="http://cherne.net/brian/resources/jquery.hoverIntent.html" rel="nofollow">jquery.hoverIntent plugin</a> too, it gives you a timeout on hover and out events</p>
4,447,081
how to send asynchronous email using django
<p>This is my code:</p> <pre><code>class EmailThread(threading.Thread): def __init__(self, subject, html_content, recipient_list): self.subject = subject self.recipient_list = recipient_list self.html_content = html_content threading.Thread.__init__(self) def run (self): msg = EmailMultiAlternatives(self.subject, self.html_content, EMAIL_HOST_USER, self.recipient_list) #if self.html_content: msg.attach_alternative(True, "text/html") msg.send() def send_mail(subject, html_content, recipient_list): EmailThread(subject, html_content, recipient_list).start() </code></pre> <p>It doesn't send email. What can I do?</p>
4,447,147
4
0
null
2010-12-15 05:48:21.54 UTC
16
2022-09-10 11:56:49.083 UTC
2011-08-03 16:32:44.187 UTC
null
179,386
null
420,840
null
1
25
python|django|email|asynchronous
17,547
<p>it is ok now ;</p> <pre><code>import threading from threading import Thread class EmailThread(threading.Thread): def __init__(self, subject, html_content, recipient_list): self.subject = subject self.recipient_list = recipient_list self.html_content = html_content threading.Thread.__init__(self) def run (self): msg = EmailMessage(self.subject, self.html_content, EMAIL_HOST_USER, self.recipient_list) msg.content_subtype = "html" msg.send() def send_html_mail(subject, html_content, recipient_list): EmailThread(subject, html_content, recipient_list).start() </code></pre>
4,195,089
What does "invalid statement in fillWindow()" in Android cursor mean?
<p>I sometimes see this error in my <code>logcat</code> output, </p> <pre><code>Cursor: invalid statement in fillWindow(). </code></pre> <p>It sometimes happens when I press the back key and then it goes to the default Android <code>listview</code> before going to my custom <code>listview</code>. </p> <p>What does it mean? How do I solve it? Because it does not point to any line of code where the problem is coming from.</p>
4,927,777
5
1
null
2010-11-16 14:22:19.377 UTC
6
2021-12-22 22:50:10.173 UTC
2021-12-22 22:50:10.173 UTC
null
4,294,399
null
316,843
null
1
31
android|android-cursor
14,899
<p>When dealing with ListActivities, this issue has to do with the Cursor objects, CursorAdapter objects, and Database objects not being closed properly when the Activity stops, and not being set properly when the Activity starts or resumes.</p> <p>I had to make sure that I closed my SimpleListAdapter, my Cursors, and then my Database objects in that respective order, in the onStop method of the Activity that is called when the TabActivity resumes.</p> <p>I had already been closing the Cursor and Database objects, but had not been closing my SimpleListAdapter Cursor.</p> <pre><code>/** * onStop method * * Perform actions when the Activity is hidden from view * * @return void * */ @Override protected void onStop() { try { super.onStop(); if (this.mySimpleListAdapterObj !=null){ this.mySimpleListAdapterObj.getCursor().close(); this.mySimpleListAdapterObj= null; } if (this.mActivityListCursorObj != null) { this.mActivityListCursorObj.close(); } if (this.myDatabaseClassObj != null) { this.myDatabaseClassObj.close(); } } catch (Exception error) { /** Error Handler Code **/ }// end try/catch (Exception error) }// end onStop </code></pre>
4,155,996
SQL Insert Into Temp Table in both If and Else Blocks
<p>I'm trying to populate a temp table based on the result of a condition in SQL 2005. The temp table will have the same structure either way, but will be populated using a different query depending on the condition. The simplified example script below fails in syntax checking of the <code>ELSE</code> block <code>INSERT INTO</code> with the error of:</p> <blockquote> <p>There is already an object named '#MyTestTable' in the database.</p> </blockquote> <pre><code>DECLARE @Id int SET @Id = 1 IF OBJECT_ID('tempdb..#MyTestTable') IS NOT NULL DROP TABLE #MyTestTable IF (@Id = 2) BEGIN SELECT 'ABC' AS Letters INTO #MyTestTable; END ELSE BEGIN SELECT 'XYZ' AS Letters INTO #MyTestTable; END </code></pre> <p>I could create the temp table before the <code>IF/ELSE</code> statement and then just do <code>INSERT SELECT</code> statements in the conditional blocks, but the table will have lots of columns and I was trying to be efficient about it. Is that the only option? Or is there some way to make this work?</p> <p>Thanks, Matt</p>
4,158,246
9
0
null
2010-11-11 15:23:13.673 UTC
3
2021-09-11 05:44:48.73 UTC
null
null
null
null
34,440
null
1
18
sql|sql-server-2005|temp-tables|insert-into
48,332
<p>The problem you’re having is not that you are populating the temp table, but that you’re trying to <em>create</em> the table. SQL parses your script and finds that you are attempting to create it in two different places, and so raises an error. It is not clever enough to realize that the “execution path” cannot possibly hit both of the create statemements. Using dynamic SQL will not work; I tried</p> <pre><code>DECLARE @Command varchar(500) DECLARE @Id int SET @Id = 2 IF OBJECT_ID('tempdb..#MyTestTable') IS NOT NULL DROP TABLE #MyTestTable IF (@Id = 2) BEGIN SET @Command = 'SELECT ''ABC'' AS Letters INTO #MyTestTable' END ELSE BEGIN SET @Command = 'SELECT ''XYZ'' AS Letters INTO #MyTestTable' END EXECUTE (@Command) select * from #MyTestTable </code></pre> <p>but the temp table only lasts as long as the dynamic session. So, alas, it looks like you’ll have to first declare the table and then populate it. Awkward code to write and support, perhaps, but it will perform efficiently enough.</p>
4,799,553
How to update one file in a zip archive
<p>Is it possible to replace a file in a zip file without unzipping?</p> <p>The file to update is an XML file that resides in a huge zip archive. To update this XML file, I have to unzip the archive, delete the old XML file, add the new one and then rezip. This takes a considerable amount of time. So want to be able to replace that one XML through a script. I already have the one that checks for updates on the XML I have.</p> <p><em>using zip command</em><br /> Sorry, I would use the zip command to do things like that but the problem is the script is actually for an android phone and zip is not a command I can use unfortunately sorry I left that out. I would have used zip definitely if i could but I only have unzip for droid and then there is tar in busybox but tar doesn't do what I need</p>
4,799,569
10
1
null
2011-01-25 22:24:48.77 UTC
14
2022-07-26 15:38:58.353 UTC
2022-07-26 15:38:58.353 UTC
null
12,862,712
null
577,732
null
1
114
bash|shell|zip
140,142
<p>From <a href="http://linux.die.net/man/1/zip" rel="noreferrer">zip(1)</a>:</p> <blockquote> <p>When given the name of an existing zip archive, zip will replace identically named entries in the zip archive or add entries for new names.</p> </blockquote> <p>So just use the <code>zip</code> command as you normally would to create a new .zip file containing only that one file, except the .zip filename you specify will be the existing archive.</p>
14,867,473
ios - UICollectionView change default offset when horizontal paging
<p>I'm trying to use UICollectionView to display the view to the left and right of the current view that is centered in the screen.</p> <p>I have this displaying properly but the horizontal paging does not center on the subsequent views because it defaults to the width of the frame, which is 320.0.</p> <p>Where is UICollectionView calculating the default offset value it uses when clipping to the next pages?</p> <p>I would like to change this value. Is there a better way to do this? Essentially I am trying to recreate the experience being used in the search results for the app store on the iphone.</p>
14,885,659
3
3
null
2013-02-14 03:46:13.07 UTC
9
2016-03-21 06:02:12.85 UTC
null
null
null
null
1,390,385
null
1
7
iphone|ios|ios6|uicollectionview
13,785
<p>It turned out that I had to set <code>pagingEnabled = NO</code> and overrode <code>(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView</code> with the following:</p> <pre><code>- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView { if (self.lastQuestionOffset &gt; scrollView.contentOffset.x) self.currentPage = MAX(self.currentPage - 1, 0); else if (self.lastQuestionOffset &lt; scrollView.contentOffset.x) self.currentPage = MIN(self.currentPage + 1, 2); float questionOffset = 290.0 * self.currentPage; self.lastQuestionOffset = questionOffset; [self.collectionView setContentOffset:CGPointMake(questionOffset, 0) animated:YES]; } </code></pre> <p>This answer helped: <a href="https://stackoverflow.com/questions/5089510/paging-uiscrollview-with-different-page-widths">Paging UIScrollView with different page widths</a></p>
14,851,285
How to get datepicker value in date format?
<p>I have a problem with my Datapicker </p> <p>i use the code for getting date,month &amp; year shown below</p> <pre><code> DatePicker datePicker; datePicker = (DatePicker) findViewById(R.id.dateselect); int day = datePicker.getDayOfMonth(); int month= datePicker.getMonth() + 1; int year = datePicker.getYear(); </code></pre> <p>but when i print the date it shows the value 7 not 07 and for month it shows the value 2 not 02</p> <p>I want these integer data in a date format ie; eg: 02-02-2013, 24-12-2013<br> Is there any possible way????</p>
14,851,427
5
0
null
2013-02-13 10:22:37.163 UTC
4
2017-12-15 12:00:32.56 UTC
2013-02-13 10:30:07.11 UTC
null
2,024,761
null
1,954,939
null
1
11
android|date|datepicker|date-conversion
54,498
<pre><code> public String checkDigit(int number) { return number&lt;=9?"0"+number:String.valueOf(number); } </code></pre> <p>basic use:</p> <pre><code>month=checkDigit(month); input 7 output 07 String date=checkDigit(monthOfYear+1)+"/"+checkDigit(dayOfMonth)+"/"+year; </code></pre>
14,773,142
Is a float guaranteed to be preserved when transported through a double in C/C++?
<p>Assuming <a href="http://en.wikipedia.org/wiki/IEEE_floating_point">IEEE-754</a> conformance, is a float guaranteed to be preserved when transported through a double?</p> <p>In other words, will the following assert always be satisfied?</p> <pre><code>int main() { float f = some_random_float(); assert(f == (float)(double)f); } </code></pre> <p>Assume that <code>f</code> could acquire any of the special values defined by IEEE, such as NaN and Infinity.</p> <p>According to IEEE, is there a case where the assert will be satisfied, but the exact bit-level representation is not preserved after the transportation through double?</p> <p>The code snippet is valid in both C and C++.</p>
14,773,502
3
14
null
2013-02-08 13:00:04.42 UTC
null
2013-02-13 20:32:52.33 UTC
2013-02-12 22:00:00.54 UTC
null
63,550
null
1,698,548
null
1
36
c++|c|floating-point|double|ieee-754
1,778
<p>You don't even need to assume IEEE. C89 says in 3.1.2.5:</p> <blockquote> <p>The set of values of the type <code>float</code> is a subset of the set of values of the type <code>double</code></p> </blockquote> <p>And every other C and C++ standard says equivalent things. As far as I know, NaNs and infinities are "values of the type <code>float</code>", albeit values with some special-case rules when used as operands.</p> <p>The fact that the float -> double -> float conversion restores the original value of the <code>float</code> follows (in general) from the fact that numeric conversions all preserve the value if it's representable in the destination type.</p> <p>Bit-level representations are a slightly different matter. Imagine that there's a value of <code>float</code> that has two distinct bitwise representations. Then nothing in the C standard prevents the float -> double -> float conversion from switching one to the other. In IEEE that won't happen for "actual values" unless there are padding bits, but I don't know whether IEEE rules out a single NaN having distinct bitwise representations. NaNs don't compare equal to themselves anyway, so there's also no standard way to tell whether two NaNs are "the same NaN" or "different NaNs" other than maybe converting them to strings. The issue may be moot.</p> <p>One thing to watch out for is non-conforming modes of compilers, in which they keep super-precise values "under the covers", for example intermediate results left in floating-point registers and reused without rounding. I don't think that would cause your example code to fail, but as soon as you're doing floating-point <code>==</code> it's the kind of thing you start worrying about.</p>
2,254,504
How to add default value in SQLite?
<p>I had a table modified to add status column to it in this fashion</p> <pre><code>ALTER TABLE ITEM ADD COLUMN STATUS VARCHAR DEFAULT 'N'; </code></pre> <p>However SQLite doesnt seem to add N to the column for any new ITEM created. Is the syntax wrong or is there any issue with SQLite and its support for defaults.</p> <p>I am using SQLite 3.6.22</p>
2,254,582
1
3
null
2010-02-12 19:22:35.67 UTC
6
2011-11-06 19:44:10.163 UTC
2011-11-06 19:44:10.163 UTC
null
438,992
null
13,046
null
1
47
sql|database|sqlite
94,082
<p>Looks good to me. <a href="http://www.sqlite.org/lang_createtable.html" rel="noreferrer">Here are the Docs</a>.</p> <pre><code>sqlite&gt; create table t1 (id INTEGER PRIMARY KEY, name TEXT, created DATE); sqlite&gt; .table t1 sqlite&gt; .dump PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE t1 (id INTEGER PRIMARY KEY, name TEXT, created DATE); COMMIT; sqlite&gt; alter table t1 add column status varchar default 'N'; sqlite&gt; .dump PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE t1 (id INTEGER PRIMARY KEY, name TEXT, created DATE, status varchar default 'N'); COMMIT; sqlite&gt; insert into t1 (name) values ("test"); sqlite&gt; select * from t1; 1|test||N </code></pre> <p><strong>Dump your schema and verify</strong> that your table structure is there after calling ALTER TABLE but before the INSERT. If it's in a transaction, <strong>make sure to COMMIT the transaction</strong> before the insert.</p> <pre><code>$ sqlite3 test.db ".dump" </code></pre>
33,783,947
script to restore database sql server from bak file, doesn't work
<p>I have an empty database: </p> <p><code>DB_Clients</code></p> <p>And I want to restore the database from a <code>.bak</code> file: </p> <pre><code>OldDBClients.bak </code></pre> <p>This is the path:</p> <pre><code>C:\OldDBClients.bak </code></pre> <p>And this is my script:</p> <pre><code>USE [master] GO RESTORE DATABASE DB_Clients FROM DISK = 'C:\OldDBClients.bak' </code></pre> <p>When I execute it, I get this error message:</p> <blockquote> <p>Msg 3154, Level 16, State 4, Line 15<br> The backup set holds a backup of a database other than the existing 'DB_Clients' database.<br> Msg 3013, Level 16, State 1, Line 15<br> RESTORE DATABASE is terminating abnormally.</p> </blockquote> <p>Can someone tell me why this happen? I have to point that the file has the permissions to read and write. </p> <p>Thank's.</p>
33,784,180
3
0
null
2015-11-18 15:25:08.127 UTC
6
2019-10-20 06:11:06.193 UTC
2015-11-18 15:32:17.57 UTC
null
5,292,714
null
5,292,714
null
1
25
sql-server|database-restore|sql-scripts
77,844
<p>You need to use <code>WITH REPLACE</code> option in order to overwrite the existing database.</p> <pre><code>RESTORE DATABASE DB_Clients FROM DISK = 'C:\OldDBClients.bak' WITH REPLACE </code></pre> <p>Probably you also need to specify <code>WITH MOVE</code> options; in this case:</p> <ul> <li>use <code>RESTORE FILELISTONLY FROM DISK = 'C:\OldDBClients.bak'</code> to know logical name of your MDF/LDF</li> <li>use <code>WITH MOVE</code> options in your RESTORE</li> </ul> <p>For example:</p> <pre><code>RESTORE DATABASE DB_Clients FROM DISK = 'C:\OldDBClients.bak' WITH REPLACE, MOVE 'YourMDFLogicalName' TO '&lt;MDF file path&gt;', MOVE 'YourLDFLogicalName' TO '&lt;LDF file path&gt;' </code></pre> <p>Please note that you can also <code>DROP</code> your empty <code>DB_Clients</code> database and use a simple <code>RESTORE</code>.</p>
27,499,147
reading specific column of excel into java program
<p>I need to read specific column of an excel sheet and then declare the variables in java. The program that I have done reads the entire content of excel sheet. But I need to read a fixed column like C.</p> <p>This is what I have done:</p> <pre><code>import java.io.File; import java.io.IOException; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; public class JavaApplication4 { private String inputFile; String[][] data = null; public void setInputFile(String inputFile) { this.inputFile = inputFile; } public String[][] read() throws IOException { File inputWorkbook = new File(inputFile); Workbook w; try { w = Workbook.getWorkbook(inputWorkbook); // Get the first sheet Sheet sheet = w.getSheet(0); data = new String[sheet.getColumns()][sheet.getRows()]; // Loop over first 10 column and lines // System.out.println(sheet.getColumns() + " " +sheet.getRows()); for (int j = 0; j &lt;sheet.getColumns(); j++) { for (int i = 0; i &lt; sheet.getRows(); i++) { Cell cell = sheet.getCell(j, i); data[j][i] = cell.getContents(); // System.out.println(cell.getContents()); } } for (int j = 0; j &lt; data.length; j++) { for (int i = 0; i &lt;data[j].length; i++) { System.out.println(data[j][i]); } } } catch (BiffException e) { e.printStackTrace(); } return data; } public static void main(String[] args) throws IOException { JavaApplication4 test = new JavaApplication4(); test.setInputFile("C://users/admin/Desktop/Content.xls"); test.read(); } } </code></pre> <p>Here is my excel sheet,</p> <p>From a bowl of chits numbered <code>/@v1@/</code> to <code>/@v2@/</code> , a single chit is randomly drawn. Find the probability that the chit drawn is a number that is a multiple of <code>/@v3@/</code> or <code>/@ v4@/</code>?</p> <p>I need to read this data and by matching the pattern <code>/@v1@1</code>, I need to declare the variables. How can I do this?</p>
27,524,657
4
0
null
2014-12-16 06:56:08.607 UTC
1
2020-02-13 03:18:02.543 UTC
2014-12-16 07:04:53.333 UTC
user180100
null
null
4,269,299
null
1
0
java|excel|jxl
43,866
<p>What you can do, you should first get all the columns from the sheet by using sheet.getColumns() and store all columns in a list . Then you can match get all values based on columns. or you can get for only column "C".try using below code. let me know if this works.</p> <pre><code>int masterSheetColumnIndex = sheet.getColumns(); List&lt;String&gt; ExpectedColumns = new ArrayList&lt;String&gt;(); for (int x = 0; x &lt; masterSheetColumnIndex; x++) { Cell celll = sheet.getCell(x, 0); String d = celll.getContents(); ExpectedColumns.add(d); } LinkedHashMap&lt;String, List&lt;String&gt;&gt; columnDataValues = new LinkedHashMap&lt;String, List&lt;String&gt;&gt;(); List&lt;String&gt; column1 = new ArrayList&lt;String&gt;(); // read values from driver sheet for each column for (int j = 0; j &lt; masterSheetColumnIndex; j++) { column1 = new ArrayList&lt;String&gt;(); for (int i = 1; i &lt; sheet.getRows(); i++) { Cell cell = sheet.getCell(j, i); column1.add(cell.getContents()); } columnDataValues.put(ExpectedColumns.get(j), column1); } </code></pre>
44,713,501
Flutter - FloatingActionButton in the center
<p>Is it possible to make the <code>FloatingActionButton</code> in the centre instead of the right side?</p> <pre><code>import 'package:flutter/material.dart'; import 'number.dart'; import 'keyboard.dart'; class ContaPage extends StatelessWidget { @override Widget build(BuildContext context) =&gt; new Scaffold( body: new Column( children: &lt;Widget&gt;[ new Number(), new Keyboard(), ], ), floatingActionButton: new FloatingActionButton( elevation: 0.0, child: new Icon(Icons.check), backgroundColor: new Color(0xFFE57373), onPressed: (){} ) ); } </code></pre> <p><a href="https://i.stack.imgur.com/wlEnM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wlEnM.png" alt="enter image description here"></a></p>
44,725,787
14
0
null
2017-06-23 05:12:41.653 UTC
11
2022-08-07 17:40:03.747 UTC
2019-08-21 15:07:32.76 UTC
null
4,997,239
null
2,744,242
null
1
56
dart|flutter|floating-action-button|center-align
144,693
<p>Try wrapping it in a <code>Center</code> widget or use a <code>crossAxisAlignment</code> of <code>CrossAxisAlignment.center</code> on your <code>Column</code>.</p> <p>You should pick one part of your <code>Column</code> to be wrapped in a <code>Flexible</code> that will collapse to avoid overflow, or replace some or all of it with a <code>ListView</code> so users can scroll to see the parts that are hidden.</p>
34,097,048
Selecting only the first few characters in a string C++
<p>I want to select the first 8 characters of a string using C++. Right now I create a temporary string which is 8 characters long, and fill it with the first 8 characters of another string.</p> <p>However, if the other string is not 8 characters long, I am left with unwanted whitespace.</p> <pre><code>string message = " "; const char * word = holder.c_str(); for(int i = 0; i&lt;message.length(); i++) message[i] = word[i]; </code></pre> <p>If <code>word</code> is <code>"123456789abc"</code>, this code works correctly and <code>message</code> contains <code>"12345678"</code>.</p> <p>However, if <code>word</code> is shorter, something like <code>"1234"</code>, message ends up being <code>"1234 "</code></p> <p>How can I select either the first eight characters of a string, or the entire string if it is shorter than 8 characters?</p>
34,097,078
5
0
null
2015-12-04 20:41:19.943 UTC
2
2018-06-22 17:33:19.243 UTC
2018-06-22 17:33:19.243 UTC
null
3,483,203
null
3,483,203
null
1
21
c++|string|c-strings
62,589
<p>Just use <code>std::string::substr</code>:</p> <pre><code>std::string str = "123456789abc"; std::string first_eight = str.substr(0, 8); </code></pre>
21,314,206
Full-width vimeo wrapper background
<p>I am trying to create a full-width iframe vimeo background covered by a pattern located in my body div. The video is covered by an overlay so it becomes unclickable. Ive tried giving the video 100% width and height yet no luck on covering the screen.. I am trying to have the videos pop up at 500x250 px.</p> <p>Html </p> <pre><code> &lt;div class="video"&gt; &lt;iframe src="//player.vimeo.com/video/82123812?title=0&amp;amp;byline=0&amp;amp;portrait=0&amp;amp;color=3a6774&amp;amp;autoplay=1&amp;amp;loop=1" width="960" height="540" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt; &lt;div class="overlay"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>.video { position: absolute; left: 0; top: 0; width: 100%; height: 100% } .video .overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: url(../img/overlay-pattern.png) repeat; } </code></pre>
21,314,451
2
0
null
2014-01-23 16:41:04.243 UTC
8
2017-02-02 14:28:33.997 UTC
2017-02-02 14:27:39.993 UTC
null
199,700
null
2,634,224
null
1
11
html|css|iframe|video|fluid-layout
50,225
<p>You need to set the width and height of the iframe as well as its wrapper. I've also added some z-indexes for luck! </p> <p>Hey diddle diddle, here is a fiddle: <a href="http://jsfiddle.net/n28Ef/1/" rel="noreferrer">http://jsfiddle.net/n28Ef/1/</a></p> <pre><code>.video { position: absolute; left: 0; top: 0; width: 100%; height: 100%; } .video iframe { position: absolute; z-index: 1; width: 100%; height: 100%; } .video .overlay { position: absolute; z-index: 2; left: 0; top: 0; width: 100%; height: 100%; background: url(../img/overlay-pattern.png) repeat; } </code></pre>
21,129,912
ng-show="true" but still has class="ng-hide"
<p>I'm new to AngularJS, so there may be a simple resolution to my problem. I've been working on this form. I have two inputs - one is for the number of doors and one is for the number of windows. I then have several divs that I want to show if they meet a certain number of total doors and windows. When I enter numbers into the input, the ng-show resolves to "true". But the element still has the class of "ng-hide" on it which still leaves it hidden.</p> <p>Here's a sample of my code:</p> <pre><code>&lt;body ng-app&gt; Doors: &lt;input type="number" ng-model="doors"&gt;&lt;br&gt; Windows: &lt;input type="number" ng-model="windows"&gt;&lt;br&gt; &lt;div ng-show="{{(doors + windows) &lt; 6}}"&gt; Shows if you have 0-5 doors and windows combined. &lt;/div&gt; &lt;div ng-show="{{(doors + windows) &gt; 5 &amp;&amp; (doors + windows) &lt; 11}}"&gt; Shows if you have 6-10 doors and windows combined. &lt;/div&gt; &lt;div ng-show="{{(doors + windows) &gt; 10 }}"&gt; Shows if you have more than 10 doors and windows combined. &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Here's the output when I enter 3 doors and 4 windows:</p> <pre><code>&lt;div ng-show="false" class="ng-hide"&gt; Shows if you have 0-5 doors and windows combined. &lt;/div&gt; &lt;div ng-show="true" class="ng-hide"&gt; Shows if you have 6-10 doors and windows combined. &lt;/div&gt; &lt;div ng-show="false" class="ng-hide"&gt; Shows if you have more than 10 doors and windows combined. &lt;/div&gt; </code></pre>
21,130,002
1
0
null
2014-01-15 05:43:08.003 UTC
14
2015-01-12 10:22:17.297 UTC
null
null
null
null
2,232,605
null
1
48
forms|angularjs|ng-show
35,420
<p><a href="http://docs.angularjs.org/api/ng.directive%3angShow"><code>ngShow</code></a> takes an Angular expression so you don't want the double curly braces.</p> <p>This will work for you:</p> <pre><code>&lt;div ng-show="(doors + windows) &lt; 6"&gt; Shows if you have 0-5 doors and windows combined. &lt;/div&gt; &lt;div ng-show="(doors + windows) &gt; 5 &amp;&amp; (doors + windows) &lt; 11"&gt; Shows if you have 6-10 doors and windows combined. &lt;/div&gt; &lt;div ng-show="(doors + windows) &gt; 10"&gt; Shows if you have more than 10 doors and windows combined. &lt;/div&gt; </code></pre> <p><a href="http://jsfiddle.net/TWc7u/">demo fiddle</a></p> <p>To understand why let's look at the <a href="https://github.com/angular/angular.js/blob/aba0fe683040f753f60a0f8030777d94aa9f58bf/src/ng/directive/ngShowHide.js"><code>ngShow</code> source code</a>:</p> <pre><code>var ngShowDirective = ['$animate', function($animate) { return function(scope, element, attr) { scope.$watch(attr.ngShow, function ngShowWatchAction(value){ $animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide'); }); }; }]; </code></pre> <p>The key is that it puts a watch on <code>attr.ngShow</code>. When you set that attribute to <code>{{(doors + windows) &lt; 6}}</code> the first thing that happens is the expression in the double curly braces is evaluated. In your case, doors and windows start out <code>undefined</code> so the expression evaluates to <code>false</code>. Then <code>false</code> is passed in to the attribute. So a <code>$watch</code> is placed on <code>false</code> and every <code>$digest</code> cycle <code>false</code> is checked, and <code>false</code> keeps being <code>false</code> so the watch function never runs. </p> <p>The important thing to note is that the attribute itself isn't being watched, but the value that was initially passed in is watched. So even though you later change the attribute to "true", and see that change in the html, that's never noticed by the watch.</p> <p>When, instead, we pass in <code>(doors + windows) &lt; 6</code> as <code>attr.ngShow</code> then on each <code>$digest</code> the <code>$watch</code> evaluates that expression. And whenever the result of the expression changes the watch function is called and the appropriate class set.</p>
47,743,472
How to use grid-template-areas in react inline style?
<p>So, I've been playing with <code>css-grids</code> in react when I noticed that <code>grid-template-areas</code> has a bit different syntax which might not be compatible in inline react styles. I'm not using any libraries just plain old react inline styles with style prop. </p> <p>So what I'm aiming to do is similar to this.</p> <pre><code>.wrapper { display: grid; grid-template-columns: 100px 100px; grid-template-areas: "header header" "aside main" "footer footer" } .header { grid-area: header; border: 1px solid red; } .main { grid-area: main; border: 1px solid green; } .aside { grid-area: aside } .footer { grid-area: footer; border: 1px solid yellow; } </code></pre> <p><em>Fidde: <a href="https://jsbin.com/lejaduj/2/edit?html,css,output" rel="noreferrer">https://jsbin.com/lejaduj/2/edit?html,css,output</a></em></p> <p>The layout is simple, "header" and "footer" covering all the columns and "aside" and "main" covering the half. This is just for demo purpose so I kept it simple.<br> Notice particularly how <code>grid-template-areas</code> has multiple values separated just by double quotes.</p> <p>After some thought I thought we could use arrays in <code>gridTemplateAreas</code> in react inline styles. That didn't seem to work.</p> <p>I again tried with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" rel="noreferrer"><code>template-literals</code></a> which didn't work either.</p> <p><em>Sandbox: <a href="https://codesandbox.io/s/zx4nokmr5l" rel="noreferrer">https://codesandbox.io/s/zx4nokmr5l</a></em></p> <p>So, is it just me that's hitting this obstacle or is this not supported yet in react? </p> <p>I'd rather not use any extra library or framework in react to achieve this as much as possible.</p>
47,743,556
4
0
null
2017-12-10 21:07:15.047 UTC
4
2019-08-22 09:18:50.807 UTC
2017-12-10 21:20:35.42 UTC
null
3,597,276
null
1,204,312
null
1
29
css|reactjs|css-grid
34,833
<p>If the goal is to use <code>grid-template-areas</code> with the HTML <code>style</code> attribute (i.e., CSS inline styles), then use single instead of double quotes.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.wrapper { display: grid; grid-template-columns: 100px 100px; /* grid-template-areas: "header header" "aside main" "footer footer"; */ } .header { grid-area: header; background-color: aqua; } .main { grid-area: main; background-color: lightgreen; } .aside { grid-area: aside; background-color: yellow; } .footer { grid-area: footer; background-color: pink; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body class="wrapper" style="grid-template-areas: 'header header' 'aside main' 'footer footer' "&gt; &lt;div class="header"&gt;header&lt;/div&gt; &lt;div class="main"&gt;main&lt;/div&gt; &lt;div class="aside"&gt;aside&lt;/div&gt; &lt;div class="footer"&gt;footer&lt;/div&gt; &lt;/body&gt;</code></pre> </div> </div> </p>
31,573,041
Recover deleted file from PhpStorm and SourceTree
<p>I have an open project in PhpStorm that I manage using SourceTree. I was trying to remove some image files from a commit using SourceTree, but accidentally selected a file that should not be deleted. I haven't changed anything (in either PhpStorm or SourceTree) since deleting the file. I tried to do <kbd>Ctrl</kbd>+<kbd>Z</kbd> in SourceTree but nothing happened. I then checked in PhpStorm Vcs -> local history, but it didn't show the file. How can I recover this file?</p>
31,573,110
2
0
null
2015-07-22 20:09:31.737 UTC
11
2021-06-24 19:11:36.573 UTC
2017-04-03 14:18:43.367 UTC
null
1,667,868
null
1,667,868
null
1
55
phpstorm|webstorm|atlassian-sourcetree
17,887
<p>Try to right click on project main folder in phpStorm and select Local history / Show History in context menu (not vcs / local history). The file should be at the list as "Deleting".</p>
41,990,023
How to save uploaded image to Storage in laravel?
<p>I am using Image intervention to save an image to the storage folder. I have the code below and it seems to just save a file name with a blank image. I think I need a way for the file contents to be written to the folder but struggling for the snippet. </p> <pre><code>if ($request-&gt;hasFile('photo')) { $image = $request-&gt;file('photo'); $fileName = time() . '.' . $image-&gt;getClientOriginalExtension(); $img = Image::make($image-&gt;getRealPath()); $img-&gt;resize(120, 120, function ($constraint) { $constraint-&gt;aspectRatio(); }); //dd(); Storage::disk('local')-&gt;put('images/1/smalls'.'/'.$fileName, $img, 'public'); </code></pre>
41,991,445
4
0
null
2017-02-01 21:24:40.843 UTC
7
2020-11-11 12:59:43.303 UTC
null
null
null
null
6,274,817
null
1
10
php|laravel|laravel-5
78,129
<p>You need to do</p> <pre><code>if ($request-&gt;hasFile('photo')) { $image = $request-&gt;file('photo'); $fileName = time() . '.' . $image-&gt;getClientOriginalExtension(); $img = Image::make($image-&gt;getRealPath()); $img-&gt;resize(120, 120, function ($constraint) { $constraint-&gt;aspectRatio(); }); $img-&gt;stream(); // &lt;-- Key point //dd(); Storage::disk('local')-&gt;put('images/1/smalls'.'/'.$fileName, $img, 'public'); } </code></pre>
5,991,186
How to delete local Hg repository
<p>it's a simple question but i didn't found answers elsewhere. I need to delete a local Hg repository and all related files without deleting the code, is there a proper command? i thought that deleting the .hg folder wasn't enough. thanks</p>
5,991,272
1
0
null
2011-05-13 11:27:07.23 UTC
1
2013-01-21 17:55:13.7 UTC
null
null
null
null
641,321
null
1
31
mercurial|repository|tortoisehg
12,199
<p>Removing the .hg folder is sufficient. You will lose the VCS metadata (project history, previous versions of all files), which is stored there.</p>
30,737,262
Swift 2: Call can throw, but it is not marked with 'try' and the error is not handled
<p>After I installed Xcode 7 beta and convert my swift code to Swift 2, I got some issue with the code that I can't figure out. I know Swift 2 is new so I search and figure out since there is nothing about it, I should write a question.</p> <p><strong>Here is the error:</strong></p> <blockquote> <p>Call can throw, but it is not marked with 'try' and the error is not handled</p> </blockquote> <p><strong>Code:</strong></p> <pre><code>func deleteAccountDetail(){ let entityDescription = NSEntityDescription.entityForName("AccountDetail", inManagedObjectContext: Context!) let request = NSFetchRequest() request.entity = entityDescription //The Line Below is where i expect the error let fetchedEntities = self.Context!.executeFetchRequest(request) as! [AccountDetail] for entity in fetchedEntities { self.Context!.deleteObject(entity) } do { try self.Context!.save() } catch _ { } } </code></pre> <p><strong>Snapshot:</strong> <img src="https://i.stack.imgur.com/GVdm3.png" alt="enter image description here"></p>
30,737,454
2
0
null
2015-06-09 16:03:17.42 UTC
28
2020-05-17 00:27:33.22 UTC
null
null
null
null
2,556,515
null
1
174
ios|xcode|swift
124,786
<p>You have to catch the error just as you're already doing for your <code>save()</code> call and since you're handling multiple errors here, you can <code>try</code> multiple calls sequentially in a single do-catch block, like so:</p> <pre><code>func deleteAccountDetail() { let entityDescription = NSEntityDescription.entityForName("AccountDetail", inManagedObjectContext: Context!) let request = NSFetchRequest() request.entity = entityDescription do { let fetchedEntities = try self.Context!.executeFetchRequest(request) as! [AccountDetail] for entity in fetchedEntities { self.Context!.deleteObject(entity) } try self.Context!.save() } catch { print(error) } } </code></pre> <p>Or as @bames53 pointed out in the comments below, it is often better practice not to catch the error where it was thrown. You can mark the method as <code>throws</code> then <code>try</code> to call the method. For example:</p> <pre><code>func deleteAccountDetail() throws { let entityDescription = NSEntityDescription.entityForName("AccountDetail", inManagedObjectContext: Context!) let request = NSFetchRequest() request.entity = entityDescription let fetchedEntities = try Context.executeFetchRequest(request) as! [AccountDetail] for entity in fetchedEntities { self.Context!.deleteObject(entity) } try self.Context!.save() } </code></pre>
2,433,118
Zend Framework url redirect
<pre><code>&lt;?php class PI_Controller_Plugin_AssetGrabber extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { /* The module name */ $moduleName = $request-&gt;getModuleName(); /* This modules requires the user to be loggedin in order to see the web pages! */ $loginRequiredModules = array('admin'); if (in_array($moduleName,$loginRequiredModules)) { $adminLogin = new Zend_Session_Namespace('adminLogin'); if (!isset($adminLogin-&gt;loggedin)) { /*-------------------------------------- Here I want to redirect the user */ $this-&gt;_redirect('/something'); } } } } </code></pre> <p>I'm trying to do a redirect <code>$this-&gt;_redirect('/something')</code> but doesn't work! Do you know how can I do a redirect in this case?</p> <p>Best Regards,</p>
2,433,264
3
2
null
2010-03-12 13:52:13.26 UTC
0
2012-03-29 16:34:00.75 UTC
null
null
null
null
58,839
null
1
2
php|zend-framework
45,047
<p>Either use <code>Zend_Controller_Action_HelperBroker</code> to get the redirect helper or do the redirect directly from the Request object.</p> <p>See the examples given in</p> <ul> <li><a href="https://stackoverflow.com/questions/2357732/redirect-in-front-controller-plugin-zend">Redirect in Front Controller plugin Zend</a></li> </ul>
59,077,079
How to get pull request number within GitHub Actions workflow
<p>I want to access the Pull Request number in a Github Actions workflow. I can access the GITHUB_REF environment variable that is available. Although on a Pull Request action it has the value: "refs/pull/125/merge". I need to extract just the "125". </p> <p>I have found a similar post <a href="https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions">here</a> that shows how to get the current branch using this variable. Although in this case, what I am parsing is different and I have been unable to isolate the Pull Request number. </p> <p>I have tried using {GITHUB_REF##*/} which resolves to "merge" I have also tried {GITHUB_REF#*/} which resolves to "pull/125/merge"</p> <p>I only need the Pull Request number (which in my example is 125)</p>
62,436,027
5
1
null
2019-11-27 19:13:51.98 UTC
6
2022-04-05 10:08:54.697 UTC
null
null
null
null
7,553,610
null
1
30
github|github-actions
14,442
<p>Although it is already answered, the easiest way I found is using the github context. The following example shows how to set it to an environment variable.</p> <pre><code>env: PR_NUMBER: ${{ github.event.number }} </code></pre>
50,008,296
Facebook JSON badly encoded
<p>I downloaded my Facebook messenger data (in your Facebook account, go to <em>settings,</em> then to <em>Your Facebook information</em>, then <em>Download your information</em>, then create a file with at least the <em>Messages</em> box checked) to do some cool statistics</p> <p>However there is a small problem with encoding. I'm not sure, but it looks like Facebook used bad encoding for this data. When I open it with text editor I see something like this: <code>Rados\u00c5\u0082aw</code>. When I try to open it with python (UTF-8) I get <code>RadosÅ\x82aw</code>. However I should get: <code>Radosław</code>.</p> <p>My python script:</p> <pre><code>text = open(os.path.join(subdir, file), encoding='utf-8') conversations.append(json.load(text)) </code></pre> <p>I tried a few most common encodings. Example data is:</p> <pre><code>{ "sender_name": "Rados\u00c5\u0082aw", "timestamp": 1524558089, "content": "No to trzeba ostatnie treningi zrobi\u00c4\u0087 xD", "type": "Generic" } </code></pre>
50,011,987
9
7
null
2018-04-24 18:10:47.077 UTC
9
2022-08-29 14:40:08.203 UTC
2018-09-05 11:08:20.39 UTC
null
100,297
null
8,345,375
null
1
48
python|python-3.x|unicode|mojibake
11,120
<p>I can indeed confirm that the Facebook download data is incorrectly encoded; a <a href="http://en.wikipedia.org/wiki/Mojibake" rel="nofollow noreferrer">Mojibake</a>. The original data is UTF-8 encoded but was decoded as Latin-1 instead. I’ll make sure to file a bug report.</p> <p>What this means is that any non-ASCII character in the string data was encoded <em>twice</em>. First to UTF-8, and then the UTF-8 bytes were encoded <em>again</em> by interpreting them as Latin-1 encoded data (which maps exactly 256 characters to the 256 possible byte values), by using the <code>\uHHHH</code> JSON escape notation (so a literal backslash, a literal lowercase letter <code>u</code>, followed by 4 hex digits, 0-9 and a-f). Because the second step encoded byte values in the range 0-255, this resulted in a series of <code>\u00HH</code> sequences (a literal backslash, a literal lower case letter <code>u</code>, two <code>0</code> zero digits and two hex digits).</p> <p>E.g. the Unicode character <a href="https://codepoints.net/U+0142" rel="nofollow noreferrer">U+0142 LATIN SMALL LETTER L WITH STROKE</a> in the name <em>Radosław</em> was encoded to the UTF-8 byte values C5 and 82 (in hex notation), and then encoded <em>again</em> to <code>\u00c5\u0082</code>.</p> <p>You can repair the damage in two ways:</p> <ol> <li><p>Decode the data as JSON, then re-encode any string values as Latin-1 binary data, and then decode again as UTF-8:</p> <pre><code> &gt;&gt;&gt; import json &gt;&gt;&gt; data = r'&quot;Rados\u00c5\u0082aw&quot;' &gt;&gt;&gt; json.loads(data).encode('latin1').decode('utf8') 'Radosław' </code></pre> <p>This would require a full traversal of your data structure to find all those strings, of course.</p> </li> <li><p>Load the whole JSON document as binary data, replace all <code>\u00hh</code> JSON sequences with the byte the last two hex digits represent, then decode as JSON:</p> <pre><code> import re from functools import partial fix_mojibake_escapes = partial( re.compile(rb'\\u00([\da-f]{2})').sub, lambda m: bytes.fromhex(m[1].decode()), ) with open(os.path.join(subdir, file), 'rb') as binary_data: repaired = fix_mojibake_escapes(binary_data.read()) data = json.loads(repaired) </code></pre> <p>(If you are using Python 3.5 or older, you'll have to decode the <code>repaired</code> <code>bytes</code> object from UTF-8, so use <code>json.loads(repaired.decode())</code>).</p> <p>From your sample data this produces:</p> <pre><code> {'content': 'No to trzeba ostatnie treningi zrobić xD', 'sender_name': 'Radosław', 'timestamp': 1524558089, 'type': 'Generic'} </code></pre> <p>The regular expression matches against all <code>\u00HH</code> sequences in the binary data and replaces those with the bytes they represent, so that the data can be decoded correctly as UTF-8. The second decoding is taken care of by the <code>json.loads()</code> function when given binary data.</p> </li> </ol>
2,336,091
T-SQL UNION On 3 Tables?
<p>Is this possible? Using SQL Server 2005.......</p> <pre><code>SELECT * FROM Data0304 UNION SELECT * FROM Data0506 UNION SELECT * FROM Data0708 </code></pre>
2,336,104
3
1
null
2010-02-25 17:24:29.057 UTC
1
2016-03-23 09:29:20.753 UTC
2010-05-17 02:50:43.79 UTC
null
164,901
null
99,900
null
1
11
tsql|union
66,190
<p>As long as the columns are the same in all three tables, but you might want to use UNION ALL to ensure duplicates are included.</p>
3,066,027
bash script code help to make zip/tar of several folders
<p>I am very new in bash and never coded in before but this task is stuck so need to get rid of it . I need to make bash script to make a single compressed file with several dirs.</p> <p>Like -</p> <pre><code>/home/code/bots/ /var/config/ . . . /var/system/ </code></pre> <p>and all will be compressed to single file /var/file/bkup.[zip][tar.gz]</p> <p>Thanks in advance</p>
3,066,054
3
0
null
2010-06-17 22:08:57.71 UTC
8
2022-01-21 18:07:18.367 UTC
2010-06-17 23:17:27.153 UTC
null
26,428
null
349,297
null
1
13
bash|zip|gzip
51,001
<pre><code># tar: (c)reate g(z)ip (v)erbose (f)ile [filename.tar.gz] [contents]... tar -czvf /var/file/bkup.tar.gz /home/code/bots /var/config /var/system # zip: (r)ecursive [filename.zip] [contents]... zip -r /var/file/bkup.zip /home/code/bots /var/config /var/system </code></pre>
2,341,576
Updating MySQL primary key
<p>I have a table <code>user_interactions</code> with 4 columns: </p> <pre><code> user_1 user_2 type timestamp </code></pre> <p>The primary key is <code>(user_1,user_2,type)</code><br> and I want to change to <code>(user_2,user_1,type)</code> </p> <p>So what I did was : </p> <pre><code>drop primary key ... add primary key (user_2,user_1,type)... </code></pre> <p>and voila... </p> <p>The problem is that database is live on a server. </p> <p>So before I could update the primary key, many duplicates already crept in, and they are continuously creeping in. </p> <p>What to do? </p> <p>What I want to do now is to remove duplicates and keep the ones with the latest <code>timestamp</code> (which is a column in the table). </p> <p>And then somehow update the primary key again. </p>
2,342,193
3
6
null
2010-02-26 12:42:19.063 UTC
32
2015-08-11 12:56:34.737 UTC
2010-05-20 20:25:18.693 UTC
null
17,343
null
49,560
null
1
129
mysql|primary-key
222,211
<p>Next time, use a single "alter table" statement to update the primary key.</p> <pre><code>alter table xx drop primary key, add primary key(k1, k2, k3); </code></pre> <p>To fix things:</p> <pre><code>create table fixit (user_2, user_1, type, timestamp, n, primary key( user_2, user_1, type) ); lock table fixit write, user_interactions u write, user_interactions write; insert into fixit select user_2, user_1, type, max(timestamp), count(*) n from user_interactions u group by user_2, user_1, type having n &gt; 1; delete u from user_interactions u, fixit where fixit.user_2 = u.user_2 and fixit.user_1 = u.user_1 and fixit.type = u.type and fixit.timestamp != u.timestamp; alter table user_interactions add primary key (user_2, user_1, type ); unlock tables; </code></pre> <p>The lock should stop further updates coming in while your are doing this. How long this takes obviously depends on the size of your table.</p> <p>The main problem is if you have some duplicates with the same timestamp.</p>
3,040,677
Locale codes for iPhone lproj folders
<p>Where would I find a list of locale name abbreviations for my project localization folders? (Such as <code>en</code> for English, <code>fr</code> for French).</p> <p>I am looking to do German, Spanish and others.</p>
3,040,725
4
0
null
2010-06-14 20:30:14.897 UTC
23
2017-04-11 17:57:07.94 UTC
2011-05-19 15:53:54.763 UTC
null
99,834
null
224,988
null
1
29
iphone|localization|internationalization|locale
29,762
<p>You can just call them <code>English.lproj</code>, <code>Spanish.lproj</code>, etc.</p> <p>The "abbreviated names" are actually <a href="http://en.wikipedia.org/wiki/IETF_language_tag" rel="noreferrer">IETF language tags</a> (i.e. <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt" rel="noreferrer">BCP 47</a>), except that you use <code>pt_PT.lproj</code> instead of <code>pt-PT.lproj</code>.</p> <hr> <p>The actual interpretation routine is in <a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/PlugIn.subproj/CFBundle_Locale.c" rel="noreferrer">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/PlugIn.subproj/CFBundle_Locale.c</a>, determined by the <code>CFBundleGetLocalizationInfoForLocalization</code> function. Replicated here:</p> <pre class="lang-none prettyprint-override"><code>| lproj identifiers | L# | C# | Display name | |:-------------------------------|:----|:----|:---------------------------| | en_US = en = English | 0 | 0 | English (United States) | | en_GB | 0 | 2 | English (United Kingdom) | | en_AU | 0 | 15 | English (Australia) | | en_CA | 0 | 82 | English (Canada) | | en_SG | 0 | 100 | English (Singapore) | | en_IE | 0 | 108 | English (Ireland) | | fr_FR = fr = French | 1 | 1 | French (France) | | fr_CA | 1 | 11 | French (Canada) | | fr_CH | 1 | 18 | French (Switzerland) | | fr_BE | 1 | 98 | French (Belgium) | | de_DE = de = German | 2 | 3 | German (Germany) | | de_CH | 2 | 19 | German (Switzerland) | | de_AT | 2 | 92 | German (Austria) | | it_IT = it = Italian | 3 | 4 | Italian (Italy) | | it_CH | 3 | 36 | Italian (Switzerland) | | nl_NL = nl = Dutch | 4 | 5 | Dutch (Netherlands) | | nl_BE | 34 | 6 | Dutch (Belgium) | | sv_SE = sv = Swedish | 5 | 7 | Swedish (Sweden) | | es_ES = es = Spanish | 6 | 8 | Spanish (Spain) | | es_XL | 6 | 86 | Spanish (Latin America) | | da_DK = da = Danish | 7 | 9 | Danish (Denmark) | | pt_BR = pt = Portuguese | 8 | 71 | Portuguese (Brazil) | | pt_PT | 8 | 10 | Portuguese (Portugal) | | nb_NO = nb = no = Norwegian | 9 | 12 | Norwegian Bokmål (Norway) | | nn_NO = nn = Nynorsk | 151 | 101 | Norwegian Nynorsk (Norway) | | he_IL = he = Hebrew | 10 | 13 | Hebrew (Israel) | | ja_JP = ja = Japanese | 11 | 14 | Japanese (Japan) | | ar = Arabic | 12 | 16 | Arabic | | fi_FI = fi = Finnish | 13 | 17 | Finnish (Finland) | | el_GR = el = Greek | 14 | 20 | Greek (Greece) | | el_CY | 14 | 23 | Greek (Cyprus) | | is_IS = is = Icelandic | 15 | 21 | Icelandic (Iceland) | | mt_MT = mt = Maltese | 16 | 22 | Maltese (Malta) | | tr_TR = tr = Turkish | 17 | 24 | Turkish (Turkey) | | hr_HR = hr = Croatian | 18 | 68 | Croatian (Croatia) | | zh_TW = zh-Hant | 19 | 53 | Chinese (Taiwan) | | zh_CN = zh = zh-Hans = Chinese | 33 | 52 | Chinese (China) | | ur_PK = ur = Urdu | 20 | 34 | Urdu (Pakistan) | | ur_IN | 20 | 96 | Urdu (India) | | hi_IN = hi = Hindi | 21 | 33 | Hindi (India) | | th_TH = th = Thai | 22 | 54 | Thai (Thailand) | | ko_KR = ko = Korean | 23 | 51 | Korean (South Korea) | | lt_LT = lt = Lithuanian | 24 | 41 | Lithuanian (Lithuania) | | pl_PL = pl = Polish | 25 | 42 | Polish (Poland) | | hu_HU = hu = Hungarian | 26 | 43 | Hungarian (Hungary) | | et_EE = et = Estonian | 27 | 44 | Estonian (Estonia) | | lv_LV = lv = Latvian | 28 | 45 | Latvian (Latvia) | | se = Sami | 29 | 46 | Northern Sami | | fo_FO = fo = Faroese | 30 | 47 | Faroese (Faroe Islands) | | fa_IR = fa = Farsi | 31 | 48 | Persian (Iran) | | ru_RU = ru = Russian | 32 | 49 | Russian (Russia) | | ga_IE = ga = Irish | 35 | 50 | Irish (Ireland) | | sq = Albanian | 36 | -1 | Albanian | | ro_RO = ro = Romanian | 37 | 39 | Romanian (Romania) | | cs_CZ = cs = Czech | 38 | 56 | Czech (Czech Republic) | | sk_SK = sk = Slovak | 39 | 57 | Slovak (Slovakia) | | sl_SI = sl = Slovenian | 40 | 66 | Slovenian (Slovenia) | | yi = Yiddish | 41 | -1 | Yiddish | | sr_CS = sr = Serbian | 42 | 65 | Serbian (Serbia) | | mk_MK = mk = Macedonian | 43 | 67 | Macedonian (Macedonia) | | bg_BG = bg = Bulgarian | 44 | 72 | Bulgarian (Bulgaria) | | uk_UA = uk = Ukrainian | 45 | 62 | Ukrainian (Ukraine) | | be_BY = be = Byelorussian | 46 | 61 | Belarusian (Belarus) | | uz_UZ = uz = Uzbek | 47 | 99 | Uzbek (Uzbekistan) | | kk = Kazakh | 48 | -1 | Kazakh | | hy_AM = hy = Armenian | 51 | 84 | Armenian (Armenia) | | ka_GE = ka = Georgian | 52 | 85 | Georgian (Georgia) | | mo = Moldavian | 53 | -1 | Moldavian | | ky = Kirghiz | 54 | -1 | Kyrgyz | | tg = Tajiki | 55 | -1 | Tajik | | tk = Turkmen | 56 | -1 | Turkmen | | mn = Mongolian | 58 | -1 | Mongolian | | ps = Pashto | 59 | -1 | Pashto | | ku = Kurdish | 60 | -1 | Kurdish | | ks = Kashmiri | 61 | -1 | Kashmiri | | sd = Sindhi | 62 | -1 | Sindhi | | bo = Tibetan | 63 | 105 | Tibetan | | ne_NP = ne = Nepali | 64 | 106 | Nepali (Nepal) | | sa = Sanskrit | 65 | -1 | Sanskrit | | mr_IN = mr = Marathi | 66 | 104 | Marathi (India) | | bn = Bengali | 67 | 60 | Bengali | | as = Assamese | 68 | -1 | Assamese | | gu_IN = gu = Gujarati | 69 | 94 | Gujarati (India) | | pa = Punjabi | 70 | 95 | Punjabi | | or = Oriya | 71 | -1 | Oriya | | ml = Malayalam | 72 | -1 | Malayalam | | kn = Kannada | 73 | -1 | Kannada | | ta = Tamil | 74 | -1 | Tamil | | te = Telugu | 75 | -1 | Telugu | | si = Sinhalese | 76 | -1 | Sinhala | | my = Burmese | 77 | -1 | Burmese | | km = Khmer | 78 | -1 | Khmer | | lo = Lao | 79 | -1 | Lao | | vi_VN = vi = Vietnamese | 80 | 97 | Vietnamese (Vietnam) | | id = Indonesian | 81 | -1 | Indonesian | | tl = Tagalog | 82 | -1 | Tagalog | | ms = Malay | 83 | -1 | Malay | | am = Amharic | 85 | -1 | Amharic | | ti = Tigrinya | 86 | -1 | Tigrinya | | om = Oromo | 87 | -1 | Oromo | | so = Somali | 88 | -1 | Somali | | sw = Swahili | 89 | -1 | Swahili | | rw = Kinyarwanda | 90 | -1 | Kinyarwanda | | rn = Rundi | 91 | -1 | Rundi | | Nyanja | 92 | -1 | Nyanja | | mg = Malagasy | 93 | -1 | Malagasy | | eo = Esperanto | 94 | 103 | Esperanto | | cy = Welsh | 128 | 79 | Welsh | | eu = Basque | 129 | -1 | Basque | | ca_ES = ca = Catalan | 130 | 73 | Catalan (Spain) | | la = Latin | 131 | -1 | Latin | | qu = Quechua | 132 | -1 | Quechua | | gn = Guarani | 133 | -1 | Guarani | | ay = Aymara | 134 | -1 | Aymara | | tt = Tatar | 135 | -1 | Tatar | | ug = Uighur | 136 | -1 | Uyghur | | dz_BT = dz = Dzongkha | 137 | 83 | Dzongkha (Bhutan) | | jv = Javanese | 138 | -1 | Javanese | | su = Sundanese | 139 | -1 | Sundanese | | gl = Galician | 140 | -1 | Galician | | af_ZA = af = Afrikaans | 141 | 102 | Afrikaans (South Africa) | | br = Breton | 142 | 77 | Breton | | iu_CA = iu = Inuktitut | 143 | 78 | Inuktitut (Canada) | | gd = Scottish | 144 | 75 | Scottish Gaelic | | gv = Manx | 145 | 76 | Manx | | to_TO = to = Tongan | 147 | 88 | Tongan (Tonga) | | grc | 148 | 40 | Ancient Greek | | kl = Greenlandic | 149 | 107 | Kalaallisut | | az = Azerbaijani | 150 | -1 | Azerbaijani | </code></pre> <p>Here:</p> <ul> <li>L# is the <em>language code</em> and C# is the <em>country code</em>. I consider two identifier identical if they share the same language and country code.</li> <li>I have only listed strings appearing the source file. It also recognizes something like <code>zh_HK</code> and <code>Traditional Chinese</code> (both have same code number as <code>zh_TW</code>), probably through the more sophisticated CFLocale list. </li> </ul> <hr> <p>As of iOS 10.3.1, the following list of lproj names are actually used by Apple:</p> <ul> <li>Danish, Dutch, English, French, German, Italian, Japanese, Polish, Portuguese, Russian, Spanish, Swedish</li> <li>ar, bo, ca, cs, da, de, el, en, es, fi, fr, he, hi, hr, hu, id, it, ja, ko, ms, nb, nl, no, pa, pl, pt, ro, ru, sk, sv, th, tr, uk, ur, vi, chr (<em>Note: chr = Cherokee</em>)</li> <li>en_AU, en_CA, en_CN, en_GB, en_ID, en_IN, en_JP, en_MY, en_NZ, en_SG</li> <li>es_419, es_AR, es_CL, es_CO, es_CR, es_GT, es_MX, es_PA, es_PE, es_US</li> <li>ar_SA, da_DK, de_AT, de_CH, fi_FI, fr_BE, fr_CA, fr_CH, he_IL, it_CH, ms_MY, nb_NO, nl_BE, nl_NL, pt_BR, pt_PT, ru_RU, sv_SE, th_TH, tr_TR, yue_CN, zh_CN, zh_HK, zh_TW</li> </ul>
2,650,041
Emacs under Windows and PNG files
<p>Would anyone have any pointers on getting PNG images to display in Emacs 23 under Win32?.. I have installed the gnuwin32 set of utilities, including libpng and zlib; C:\Program Files\GnuWin32\bin is in path. JPG files started working but not PNGs. I'd appreciate any hints on getting this to work.</p> <p>EDIT: PNG thumbnails actually display fine (e.g. in dired via C-t C-t). However, opening them fails (opens as garbage in fundamental mode, and M-x image-mode says "invalid image specification").</p>
2,650,970
4
0
null
2010-04-16 01:30:06.17 UTC
13
2017-12-20 09:55:06.54 UTC
2010-04-16 01:54:27.087 UTC
null
133,234
null
133,234
null
1
32
windows|emacs
14,247
<p>You have to copy one of these dlls "libpng12d.dll" "libpng12.dll" "libpng.dll" "libpng13d.dll" "libpng13.dll" to your emacs-23.1/bin/ directory. They require zlib1.dll which you have to copy as well. I did the same thing for jpeg62.dll and giflib4.dll and now my emacs supports jpg, gif and png files. For some reason it does not work if I simply put these dlls in the path.</p> <p>You can check <code>(image-type-available-p 'png)</code> to see if png is supported. <code>image-library-alist</code> maps image type to a list of dlls which support it.</p>
29,152,881
What is the Big O analysis of this algorithm?
<p>I'm working on a data structures course and I'm not sure how to proceed w/ this Big O analysis:</p> <pre><code>sum = 0; for(i = 1; i &lt; n; i++) for(j = 1; j &lt; i*i; j++) if(j % i == 0) for(k = 0; k &lt; j; k++) sum++; </code></pre> <p>My initial idea is that this is O(n^3) after reduction, because the innermost loop will only run when <code>j</code>/<code>i</code> has no remainder and the multiplication rule is inapplicable. Is my reasoning correct here?</p>
29,152,994
1
1
null
2015-03-19 19:00:30.47 UTC
13
2015-03-23 08:28:36.633 UTC
2015-03-23 08:28:36.633 UTC
null
572,670
null
2,986,376
null
1
44
algorithm|loops|big-o|time-complexity
2,050
<p>Let's ignore the outer loop for a second here, and let's analyze it in terms of <code>i</code>.</p> <p>The mid loop runs <code>i^2</code> times, and is invoking the inner loop whenever <code>j%i == 0</code>, that means you run it on <code>i, 2i, 3i, ...,i^2</code>, and at each time you run until the relevant <code>j</code>, this means that the inner loop summation of running time is:</p> <pre><code>i + 2i + 3i + ... + (i-1)*i = i(1 + 2 + ... + i-1) = i* [i*(i-1)/2] </code></pre> <p>The last equality comes from <a href="http://en.wikipedia.org/wiki/Arithmetic_progression#Sum">sum of arithmetic progression</a>. <br>The above is in <code>O(i^3)</code>.</p> <p>repeat this to the outer loop which runs from <code>1</code> to <code>n</code> and you will get running time of <code>O(n^4)</code>, since you actually have:</p> <pre><code>C*1^3 + C*2^3 + ... + C*(n-1)^3 = C*(1^3 + 2^3 + ... + (n-1)^3) = = C/4 * (n^4 - 2n^3 + n^2) </code></pre> <p>The last equation comes from <a href="http://www.wolframalpha.com/input/?i=1%5E3+%2B+2%5E3+%2B+3%5E3+%2B+...+%2B+%28n-1%29%5E3">sum of cubes</a> <br>And the above is in <strong><code>O(n^4)</code></strong>, which is your complexity.</p>
51,449,195
Dynamically add a set of fields to a reactive form
<p>I have 2 input fields: name and last name. I have 2 buttons: submit and 'add a person'. Clicking on 'add a person' should add a new set of fields (name and last name). How to achieve that? I found solutions how to add single input fields dynamically, but here I need to add a set</p> <p>My code now without 'add a person' functionality:</p> <pre><code>import { FormControl, FormGroup, Validators } from '@angular/forms'; export class AppComponent implements OnInit { form: FormGroup; constructor(){} ngOnInit(){ this.form = new FormGroup({ name: new FormControl('', [Validators.required, Validators.minLength(2)]), lname: new FormControl('', [Validators.required, Validators.minLength(2)]) }); } .... } </code></pre> <p>template: </p> <pre><code>&lt;form [formGroup]="form" (ngSubmit)="submit()"&gt; Name: &lt;input type="text" formControlName="name"&gt; Last Name: &lt;input type="text" formControlName="lname"&gt; &lt;button type="button"&gt;Add a Person&lt;/button&gt; &lt;button type="submit"&gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre>
51,449,923
1
0
null
2018-07-20 19:26:56.483 UTC
8
2018-07-20 20:28:55.5 UTC
null
null
null
null
8,364,939
null
1
8
angular|angular-reactive-forms
16,881
<p>What you need is <code>FormArray</code>. Given multiple elements with two FormControls name and surname like in your example you could do this: <a href="https://stackblitz.com/edit/angular-ztueuu" rel="noreferrer">https://stackblitz.com/edit/angular-ztueuu</a></p> <p>Here is what's happening:</p> <p>You define form group as you did but create it with one field of <code>FormArray</code> type</p> <pre><code>ngOnInit() { this.form = this.fb.group({ items: this.fb.array([this.createItem()]) }) } </code></pre> <p>Next you define helper method we use above <code>createItem()</code> to make us group with set of controls you want to multiply</p> <pre><code>createItem() { return this.fb.group({ name: ['Jon'], surname: ['Doe'] }) } </code></pre> <p>And lastly the method you wanted to multiply items in this set:</p> <pre><code>addNext() { (this.form.controls['items'] as FormArray).push(this.createItem()) } </code></pre> <p>Combine this with html below. We are iterating over array items and displaying fields from group. Form group name here is index of array.</p> <pre><code>&lt;form [formGroup]="form" (ngSubmit)="submit()"&gt; &lt;div formArrayName="items" *ngFor="let item of form.controls['items'].controls; let i = index"&gt; &lt;div [formGroupName]="i"&gt; &lt;input formControlName='name'&gt; &lt;input formControlName='surname'&gt; &lt;/div&gt; &lt;/div&gt; &lt;button type="button" (click)="addNext()"&gt;Add Next&lt;/button&gt; &lt;button type="submit"&gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre> <p>And you can create form with expanding set of items.</p>
992,431
Comparing dates in rails
<p>Suppose I have a standard <code>Post.first.created_at</code> datetime. Can I compare that directly with a datetime in the format <code>2009-06-03 16:57:45.608000 -04:00</code> by doing something like:</p> <pre><code>Post.first.created_at &gt; Time.parse("2009-06-03 16:57:45.608000 -04:00") </code></pre> <p><strong>Edit:</strong> Both fields are <strong>datetimes</strong>, <strong>not dates</strong>.</p>
992,477
2
0
null
2009-06-14 08:20:34.68 UTC
4
2016-09-16 18:30:26.077 UTC
2016-09-16 18:30:26.077 UTC
null
2,097,529
null
25,068
null
1
36
ruby-on-rails|datetime|date-math
77,872
<p>Yes, you can use comparison operators to compare dates e.g.:</p> <pre><code>irb(main):018:0&gt; yesterday = Date.new(2009,6,13) =&gt; #&lt;Date: 4909991/2,0,2299161&gt; irb(main):019:0&gt; Date.today &gt; yesterday =&gt; true </code></pre> <p>But are you trying to compare a date to a datetime?</p> <p>If that's the case, you'll want to convert the datetime to a date then do the comparison.</p> <p>I hope this helps.</p>
605,828
Does it matter what I choose for serialVersionUID when extending Serializable classes in Java?
<p>I'm extending a class (ArrayBlockingQueue) that implements the <a href="http://java.sun.com/javase/6/docs/api/java/io/Serializable.html" rel="noreferrer">Serializable interface</a>. Sun's documentation (and my IDE) advises me that I should set this value in order to prevent mischief:</p> <blockquote> <p>However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization.</p> </blockquote> <p>Now, I couldn't care less about what value to put in there. Does it matter?</p>
605,832
2
0
null
2009-03-03 10:06:21.427 UTC
6
2011-09-06 08:14:42.3 UTC
null
null
null
Hanno Fietz
2,077
null
1
45
java|serialization
10,914
<p>No - so long as you change it at the right time (i.e. when you make a change which affects serialization, e.g. removing a field) it shouldn't matter what value you use.</p> <p>For simplicity I'd suggest starting with 0 and increasing it by 1 each time you need to.</p> <p>The <a href="http://download.oracle.com/javase/1.5.0/docs/guide/serialization/spec/version.html#6678" rel="noreferrer">serialization spec</a> has more details.</p>
2,338,690
WPF: AutoComplete TextBox, ...again
<p><a href="https://stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf">This other SO question</a> asks about an autocomplete textbox in WPF. Several people have built these, and one of the answers given there suggests <a href="http://www.codeproject.com/KB/WPF/autocomplete-textbox.aspx" rel="nofollow noreferrer">this codeproject article</a>.</p> <p>But I've not found any WPF Autocomplete Textbox that compares with the WinForms autocomplete textbox. The codeproject sample works, sort of, ...</p> <p><a href="https://i.stack.imgur.com/VBMV8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VBMV8.png" alt="alt text"></a> </p> <p>...but</p> <ul> <li>it isn't structured as a re-usable control or DLL. It's code I need to embed in every app. </li> <li>It works only with directories. it doesn't have properties for setting whether the autocomplete source is filesystem directories only, or filesystem files, or ....etc. I could write code to do this, of course, but...I'd rather use someone else's code already written. </li> <li>it doesn't have properties to set the popup size, etc.</li> <li>there's a popup listbox that presents the posible completions. When navigating through that list, the textbox doesn't change. Typing a character while focused in the listbox doesn't cause the textbox to get updated. </li> <li>navigating focus away from the listbox doesn't make the popup listbox disappear. This is confusing. </li> </ul> <p>So, my question:</p> <p>*Does anyone have a FREE WPF AutoComplete textbox <strong><em>that works</em></strong>, and provides a quality UI experience?*</p> <hr> <p><strong>ANSWER</strong></p> <p>Here's how I did it: </p> <p>.0. get the <a href="http://wpf.codeplex.com/releases/view/40535" rel="nofollow noreferrer">WPF Toolkit</a></p> <p>.1. run the MSI for the WPF Toolkit</p> <p>.2. Within Visual Studio, Drag/drop from the toolbox - specifically the Data Visualization group - into the UI Designer. It looks like this in the VS toolbox: </p> <p><a href="https://i.stack.imgur.com/cdK7o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cdK7o.png" alt="alt text"></a> </p> <p>If you don't want to use the designer, hand-craft the xaml. It looks like this: </p> <hr> <pre><code>&lt;toolkit:AutoCompleteBox ToolTip="Enter the path of an assembly." x:Name="tbAssembly" Height="27" Width="102" Populating="tbAssembly_Populating" /&gt; </code></pre> <p>...where the toolkit namespace is mapped this way: </p> <pre><code>xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" </code></pre> <hr> <p>.3. Provide the code for the <code>Populating</code> event. Here's what I used: </p> <hr> <pre><code>private void tbAssembly_Populating(object sender, System.Windows.Controls.PopulatingEventArgs e) { string text = tbAssembly.Text; string dirname = Path.GetDirectoryName(text); if (Directory.Exists(Path.GetDirectoryName(dirname))) { string[] files = Directory.GetFiles(dirname, "*.*", SearchOption.TopDirectoryOnly); string[] dirs = Directory.GetDirectories(dirname, "*.*", SearchOption.TopDirectoryOnly); var candidates = new List&lt;string&gt;(); Array.ForEach(new String[][] { files, dirs }, (x) =&gt; Array.ForEach(x, (y) =&gt; { if (y.StartsWith(dirname, StringComparison.CurrentCultureIgnoreCase)) candidates.Add(y); })); tbAssembly.ItemsSource = candidates; tbAssembly.PopulateComplete(); } } </code></pre> <hr> <p>It works, just the way you'd expect. It feels professional. There are none of the anomalies that the codeproject control exhibits. This is what it looks like: </p> <p><a href="https://i.stack.imgur.com/pclvE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pclvE.png" alt="alt text"></a> </p> <hr> <p><a href="https://stackoverflow.com/questions/2338690/wpf-autocomplete-textbox-again/2338707#2338707">Thanks to Matt for the pointer</a> to the WPF toolkit.</p>
2,338,707
5
0
null
2010-02-26 00:31:12.753 UTC
28
2021-03-04 16:07:42.887 UTC
2019-06-22 07:05:21.053 UTC
null
4,751,173
null
48,082
null
1
46
wpf|textbox|autocomplete
52,554
<p>The newest drop of the <a href="http://wpf.codeplex.com/releases/view/40535" rel="noreferrer">WPF Toolkit</a> includes an AutoCompleteBox. It's a free set of controls from Microsoft, some of which will be included in .NET 4.</p> <p><a href="http://www.jeff.wilcox.name/2008/10/introducing-autocompletebox/" rel="noreferrer">Jeff Wilcox - Introducing the AutoCompleteBox</a></p>
2,860,394
What do dot and hash symbols mean in JQuery?
<p>I feel confused of the dot and hash symbols in the following example:</p> <pre><code>&lt;DIV ID="row"&gt; &lt;DIV ID="c1"&gt; &lt;Input type="radio" name="testing" id="testing" VALUE="1"&gt;testing1 &lt;/DIV&gt; &lt;/DIV&gt; </code></pre> <p>Code 1:<br/></p> <pre><code> $('#row DIV').mouseover(function(){ $('#row DIV').addClass('testing'); }); </code></pre> <p>Code 2<br/></p> <pre><code> $('.row div').mouseover(function(){ $(this).addClass('testing'); });​ </code></pre> <p>Codes 1 and 2 look very similar, and so it makes me so confused that<br/> when I should use ".row div" to refer to a specific DIV instead of using "#row div" ?</p>
2,860,420
5
2
null
2010-05-18 19:25:54.817 UTC
8
2013-08-26 17:20:38.933 UTC
2013-08-26 17:20:38.933 UTC
null
15,055
null
327,712
null
1
71
jquery
60,040
<p>The hash (#) specifies to select elements by their ID's</p> <p>The dot (.) specifies to select elements by their classname</p> <p>You can read more about the selectors here: <a href="http://api.jquery.com/category/selectors/basic-css-selectors/" rel="noreferrer">http://api.jquery.com/category/selectors/basic-css-selectors/</a></p>
3,140,974
How to use sed in a Makefile
<p>I have tried putting the following in my Makefile:</p> <pre><code>@if [ $(DEMO) -eq 0 ]; then \ cat sys.conf | sed -e "s#^public_demo[\s=].*$#public_demo=0#" &gt;sys.conf.temp; \ else \ cat sys.conf | sed -e "s#^public_demo[\s=].*$#public_demo=1#" &gt;sys.conf.temp; \ fi </code></pre> <p>but when I run <em>make</em>, I get the following error:</p> <pre><code>sed: -e expression #1, char 30: unterminated `s' command </code></pre> <p>If I run the exact lines that contain <code>sed</code> in the console, they behave correctly.</p> <p>Why am I getting this error and how can the problem be fixed?</p>
3,141,015
6
2
null
2010-06-29 13:17:41.21 UTC
5
2021-06-15 07:14:58.293 UTC
2020-09-22 12:50:07.493 UTC
null
4,603,507
null
26,155
null
1
29
bash|sed|makefile
31,814
<p><em>TL;DR: Use single quotes <strong>and</strong> use two $ signs. The expression is expanded twice, once by <code>make</code> and once by <code>bash</code>. The rest of this answer provides further context.</em></p> <p>It might be the $ sign in the substitution that is interpreted by make as a variable. Try using two of them like <strong>.*$$#public_demo</strong>. Then make will expand that to a single $.</p> <p>EDIT: This was only half the answer. As cristis answered: the other part is that one needs to use single quotes to prevent bash from expanding the $ sign too.</p>
2,694,644
How to revert (Roll Back) a checkin in TFS 2010
<p>Can anyone tell me how to revert (roll back) a checkin in TFS 2010?</p>
7,124,274
7
0
null
2010-04-22 21:28:31.19 UTC
22
2016-06-23 15:16:48.3 UTC
2011-08-22 12:26:38.117 UTC
null
20,553
null
206,463
null
1
112
tfs|rollback
90,664
<p>You have two options for rolling back (reverting) a changeset in <strong>Team Foundation Server 2010</strong> Version Control. First option is using the User Interface (if you have the latest version of the <a href="http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f" rel="noreferrer">TFS 2010 Power Tools</a> installed).</p> <p><img src="https://i.stack.imgur.com/mfKMy.png" alt="Rollback Changeset in UI for TFS 2010"></p> <p>The other option is using the <a href="http://blog.meidianto.com/2010/06/24/where-the-heck-is-visual-studio-command-prompt/" rel="noreferrer">TFS 2010 version control command-line application</a>:</p> <pre><code>tf.exe rollback </code></pre> <p>I have information about both approaches on my <a href="http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx" rel="noreferrer">blog post</a>.</p> <p>For <strong>Team Foundation Server 2012, 2013, or Visual Studio Online</strong>, rollback is now built-in directly to Source Control Explorer and when you are opening a changeset's details in the Team Explorer Window. You do not need to install any release of the Power Tools for this functionality when using Visual Studio 2012 or later. There is a great MSDN article discussing details about rolling back a changeset now available here: <a href="http://msdn.microsoft.com/en-us/library/ms194956(v=vs.110).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms194956(v=vs.110).aspx</a></p>
2,662,268
How do I store an array in a file to access as an array later with PHP?
<p>I just want to quickly store an array which I get from a remote API, so that i can mess around with it on a local host.</p> <p>So:</p> <ol> <li>I currently have an array.</li> <li>I want to people to use the array without having to get it from the API.</li> </ol> <p>There are no needs for efficiency etc here, this isnt for an actual site just for getting some sanitizing/formatting methods made etc</p> <p>Is there a function like <em><code>store_array()</code></em> or <em><code>restore_arrray()</code></em> ?!</p>
2,662,338
8
1
null
2010-04-18 12:46:31.743 UTC
15
2021-09-02 18:39:59.217 UTC
2014-12-24 14:35:22.28 UTC
null
439,427
null
289,666
null
1
69
php
97,244
<p>The best way to do this is JSON serializing. It is human readable and you'll get better performance (file is smaller and faster to load/save). The code is very easy. Just two functions</p> <ul> <li><a href="http://www.php.net/manual/en/function.json-encode.php" rel="noreferrer">json_encode</a></li> <li><a href="http://www.php.net/manual/en/function.json-decode.php" rel="noreferrer">json_decode</a></li> </ul> <p>Example code:</p> <pre><code>$arr1 = array ('a'=&gt;1,'b'=&gt;2,'c'=&gt;3,'d'=&gt;4,'e'=&gt;5); file_put_contents(&quot;array.json&quot;,json_encode($arr1)); # array.json =&gt; {&quot;a&quot;:1,&quot;b&quot;:2,&quot;c&quot;:3,&quot;d&quot;:4,&quot;e&quot;:5} $arr2 = json_decode(file_get_contents('array.json'), true); $arr1 === $arr2 # =&gt; true </code></pre> <p>You can write your own store_array and restore_array functions easily with this example.</p> <p>For speed comparison see <a href="https://3v4l.org/abfKH" rel="noreferrer">benchmark</a> originally from <a href="https://stackoverflow.com/questions/804045/preferred-method-to-store-php-arrays-json-encode-vs-serialize/804089#804089">Preferred method to store PHP arrays (json_encode vs serialize)</a>.</p>
2,389,540
jQuery "hasParent"
<p>The JQuery "has" method effectively selects all elements where they have particular descendants.</p> <p>I want to select elements based on the fact they have particular ancestors. I know about parent([selector]) and parents([selector]) but these select the parents and not the children with the parents.</p> <p>So is there an ancestor equivalent of "has"?</p> <p><strong>Note:</strong> I already have the context of an element further down the hierarchy and I will be selecting based on this so I can't do a "top down" query.</p> <p><strong>Update</strong></p> <p>I've obviously explained myself really badly here, so I'll try and clarify:</p> <pre><code>&lt;ul class="x"&gt; &lt;li&gt;1&lt;/li&gt; &lt;li&gt;2&lt;/li&gt; &lt;li&gt;3&lt;/li&gt; &lt;/ul&gt; &lt;ul class="y"&gt; &lt;li&gt;4&lt;/li&gt; &lt;li&gt;5&lt;/li&gt; &lt;li&gt;6&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I have a jQuery object that already consists of elements 2,3,4 and 5. I want to select those elements who have a parent with the class = x.</p> <p>Hope that makes more sense.</p>
2,389,549
10
0
null
2010-03-05 19:50:47.25 UTC
14
2018-07-10 19:13:42.9 UTC
2014-01-30 11:20:57.987 UTC
null
2,902,661
null
28,896
null
1
53
javascript|jquery
60,900
<p>For a clean re-usable solution, consider extending the <code>jQuery.fn</code> object with a custom method used for determining the presence of a particular ancestor for any given element:</p> <pre><code>// Extend jQuery.fn with our new method jQuery.extend( jQuery.fn, { // Name of our method &amp; one argument (the parent selector) within: function( pSelector ) { // Returns a subset of items using jQuery.filter return this.filter(function(){ // Return truthy/falsey based on presence in parent return $(this).closest( pSelector ).length; }); } }); </code></pre> <p>This results in a new method, <code>$.fn.within</code>, that we can use to filter our results:</p> <pre><code>$("li").within(".x").css("background", "red"); </code></pre> <p>This selects all list items on the document, and then filters to only those that have <code>.x</code> as an ancestor. Because this uses jQuery internally, you could pass in a more complicated selector:</p> <pre><code>$("li").within(".x, .y").css("background", "red"); </code></pre> <p>This will filter the collection to items that descend from either <code>.x</code> or <code>.y</code>, or both.</p> <p>Fiddle: <a href="http://jsfiddle.net/jonathansampson/6GMN5/" rel="noreferrer">http://jsfiddle.net/jonathansampson/6GMN5/</a></p>
3,159,791
Is there way to expand all folders in Eclipse project view and search results?
<p>I'm spending a lot of time manually expanding deeply-nested folders in tree views like the Project Explorer and the File Search result tree. Is there a keyboard shortcut or menu command to expand all folders? </p>
3,159,851
12
2
null
2010-07-01 16:35:51.33 UTC
15
2021-11-18 18:48:39.937 UTC
null
null
null
null
275,629
null
1
53
eclipse|search|treeview|directory|expand
41,922
<p>In "File Seach Result", right click on the top level folder, there is an "expand all" menu entry.</p> <p>In the project view, I didn't find the feature.</p>
10,751,603
How to insert values in two dimensional array programmatically?
<p>I want to do this dynamically in java. I know how to insert values in single dimensional array. I am bit confused in two dimensional array. </p> <pre><code>static final String shades[][] = { // Shades of grey { "lightgrey", "dimgray", "sgi gray 92", }, // Shades of blue { "dodgerblue 2", "steelblue 2", "powderblue", }, // Shades of yellow { "yellow 1", "gold 1", "darkgoldenrod 1", }, // Shades of red { "indianred 1", "firebrick 1", "maroon", } }; </code></pre>
10,751,663
6
0
null
2012-05-25 09:11:19.497 UTC
2
2019-01-16 20:33:43.427 UTC
2017-11-21 08:40:56.98 UTC
null
1,033,581
null
1,216,003
null
1
8
java|android|arrays|multidimensional-array|arraylist
175,198
<pre><code>String[][] shades = new String[intSize][intSize]; // print array in rectangular form for (int r=0; r&lt;shades.length; r++) { for (int c=0; c&lt;shades[r].length; c++) { shades[r][c]="hello";//your value } } </code></pre>
23,087,980
How to remove nodes from the Render Tree?
<p>I feel like I'm missing something obvious, but how do I remove nodes from the render tree and destroy them correctly?</p> <p>It looks like I can just do something like <code>mainCtx._node._child.splice(2,1)</code>, but this doesn't work in all cases (Scrollviews seem to stick around), and assume there's something relevant in the API but I can't seem to find it.</p>
23,105,923
1
0
null
2014-04-15 15:20:35.09 UTC
9
2014-07-08 13:03:32.027 UTC
null
null
null
null
1,839,099
null
1
18
famo.us
2,475
<p>You never remove renderNodes - you use smart RenderNodes to manipulate what is rendered.</p> <p>The solution depends on what you want to accomplish:</p> <h2>1) I want to manipulate the layout</h2> <p>The easiest way to show / hide / swap parts of the RenderTree is to use a <code>RenderController</code>. You can even specify in/out transitions</p> <pre><code>var renderController = new RenderController(); renderController.show( .... ); renderController.hide( .... ); </code></pre> <p>See the <a href="https://github.com/Famous/examples/blob/master/src/examples/views/RenderController/example.js">official example</a></p> <h2>2) I want to manage performance (and remove stuff I don't need)</h2> <p>Don't worry about removing nodes. Famo.us will manage this for you. </p> <p>If you want to take control of rendered nodes, write a custom <code>View</code> with a <code>render</code> function. The <a href="https://github.com/Famous/views/blob/master/Flipper.js">Flipper class</a> is a simple example (and the RenderController is a complex example of this pattern)</p> <p><strong>In depth explanation:</strong> </p> <ol> <li>Every <code>RenderNode</code> has a <code>render</code> function which creates a <strong>renderSpec</strong>. </li> <li>The <strong>renderSpec</strong> contains information about a <code>Modifier</code> or <code>Surface</code>. <ul> <li>The <code>Modifier</code> specs are used to calculate the final CSS properties.</li> <li>The <code>Surface</code> specs are coupled to DOM elements.</li> </ul></li> <li>Every tick of the <code>Engine</code>, the <strong>renderSpec</strong> is rendered using the <code>RenderNode.commit</code> function.</li> <li>The <code>commit</code> function uses the <code>ElementAllocator</code> (from the <code>Context</code>) to allocate/deallocate DOM elements. (Which actually recycles DOM nodes to conserve memory)</li> </ol> <p>Therefore: Just return the correct <strong>renderSpec</strong> in your custom <code>View</code>, and famo.us will manage memory and performance for you. </p> <p>BTW, you don't need to use the <code>View</code> class - an object with a <code>render</code> function will suffice. The <code>View</code> class simply adds events and options which is a nice way to create encapsulated, reusable components.</p> <h2>Update: Ready-made Solutions</h2> <p><strong><a href="https://gist.github.com/markmarijnissen/13ba9224719fc0ab14b4">ShowModifier (gist)</a></strong> a simple modifier to show/hide parts of the rendering tree</p> <pre><code> var mod = new ShowModifier({visible:true}); mod.visible = true; mod.show(); mod.hide(); </code></pre> <p>or, as alternative, use <strong><a href="https://gist.github.com/markmarijnissen/6bf208f88f34bf47ba94">this gist</a></strong> to add visibility functions to <code>Modifier</code> and <code>StateModifier</code></p> <pre><code> modifier.visibleFrom(function(){ return true; }) // function, getter object or value stateModifier.setVisible(true); // or false </code></pre> <p><strong>WARNING:</strong> Adding/removing DOM-nodes by manipulating the renderspec might cause a performance penalty!</p>
19,456,397
AngularJS ngChange trigger onblur
<p>for <code>ng-Change</code>, is there way to trigger it only when on <code>blur</code>? Similar to jquery <code>on('change')</code>?</p> <p>I am seeking for a pure <code>angular</code> way of doing this.</p>
19,456,433
3
0
null
2013-10-18 18:13:43.433 UTC
1
2016-01-18 10:03:51.25 UTC
2016-01-18 10:03:51.25 UTC
null
863,110
null
2,821,224
null
1
39
angularjs|angularjs-directive
42,916
<p>Starting with <a href="https://github.com/angular/angular.js/blob/master/CHANGELOG.md#120rc1-spooky-giraffe-2013-08-13" rel="noreferrer">release 1.2.0rc1</a> there is an <code>ng-blur</code> directive</p> <p>jsfiddle: <a href="http://jsfiddle.net/9mvt8/6/" rel="noreferrer">http://jsfiddle.net/9mvt8/6/</a></p> <p>HTML:</p> <pre><code>&lt;div ng-controller="MyCtrl"&gt; &lt;input type='text' ng-blur='blurCount = blurCount + 1'/&gt; &lt;input type='text' ng-blur='blurCount = blurCount + 1' /&gt; blur count: {{blurCount}} &lt;/div&gt; </code></pre> <p>Script:</p> <pre><code>function MyCtrl($scope) { $scope.blurCount = 0; $scope.name = 'Superhero'; } </code></pre>
35,680,979
Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes - Android studio 2.0 beta 6
<p>I updated to the last version of Android studio 2.0 Beta 6 with the gradle :</p> <pre><code>dependencies { classpath 'com.android.tools.build:gradle:2.0.0-beta6' } </code></pre> <p>The app works perfectly fine on emulator and devices I tested every thing and it works fine.</p> <p>I got many errors only when I try to Generate Signed APK,</p> <p>I got some errors in dependencies, all of them solved when i excluded vector drawable, vector animate drawable and Support-v4 library</p> <p>Now i dont have any dependencies error.</p> <p>now my gradle.build for the app module looks like this:</p> <pre><code>apply plugin: 'com.android.application' android { configurations { //all*.exclude group: 'com.android.support', module: 'support-v4' all*.exclude module: 'animated-vector-drawable' all*.exclude module: 'support-vector-drawable' //all*.exclude module: 'support-v4' } repositories { maven { url "https://jitpack.io" } } compileSdkVersion 23 buildToolsVersion '23.0.2' defaultConfig { applicationId "com.test.test" minSdkVersion 11 targetSdkVersion 23 versionCode 1 versionName "1" // multiDexEnabled true vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile('com.github.afollestad.material-dialogs:commons:0.8.5.5@aar') { transitive = true exclude module: 'support-v4' exclude module: 'appcompat-v7' exclude module: 'recyclerview-v7' } compile('com.google.android.gms:play-services-ads:8.4.0') { exclude module: 'support-v4' } compile('com.google.android.gms:play-services-analytics:8.4.0') { exclude module: 'support-v4' } compile('com.android.support:appcompat-v7:23.2.0') { exclude module: 'support-v4' exclude module: 'animated-vector-drawable' exclude module: 'support-vector-drawable' } compile('com.android.support:support-v4:23.2.0') { exclude module: 'animated-vector-drawable' exclude module: 'support-vector-drawable' } compile('com.android.support:palette-v7:23.2.0') { exclude module: 'support-v4' } compile('com.android.support:cardview-v7:23.2.0') { exclude module: 'support-v4' } compile('com.android.support:recyclerview-v7:23.2.0') { exclude module: 'support-v4' } compile('com.android.support:design:23.2.0') { exclude module: 'support-v4' } compile('com.nineoldandroids:library:2.4.0') { exclude module: 'support-v4' } compile('com.baoyz.swipemenulistview:library:1.2.1') { exclude module: 'support-v4' exclude module: 'appcompat-v7' exclude module: 'recyclerview-v7' } compile('com.squareup.picasso:picasso:2.5.2') { exclude module: 'support-v4' } compile('com.nononsenseapps:filepicker:2.5.0') { exclude module: 'support-v4' exclude module: 'appcompat-v7' exclude module: 'recyclerview-v7' } compile 'com.google.code.gson:gson:2.6.1' } </code></pre> <p>The errors shows up only when I build for release:</p> <p>This is the error when i turn on multiDex:</p> <pre><code>Error:Execution failed for task ':app:transformClassesWithMultidexlistForRelease'. &gt; com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 </code></pre> <p>And this is the error when i turn it off:</p> <pre><code>:app:transformClassesWithDexForRelease Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes Error:Execution failed for task ':app:transformClassesWithDexForRelease'. &gt; com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 </code></pre> <p>I tried to change the <code>buildToolsVersion '23.0.2'</code> to every possible version and nothing changed.</p> <p>when i put the version 22.0.1 i got this error:</p> <pre><code>Error:Error converting bytecode to dex: Cause: com.android.dx.cf.iface.ParseException: name already added: string{"a"} Error:Execution failed for task ':app:transformClassesWithDexForRelease'. &gt; com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 </code></pre> <p>I tried with all possible support libraries version and same result.</p> <p>I tried with Java 1.6 and 1.7 and nothing has changed !</p> <p>what can be other possible solution please ?</p>
35,771,904
14
1
null
2016-02-28 09:47:15.61 UTC
8
2018-12-24 10:56:42.86 UTC
2016-02-28 13:55:53.313 UTC
null
2,296,787
null
2,296,787
null
1
23
android|gradle|android-gradle-plugin|build.gradle
71,214
<p>I also faced the same error, and i was searching through many existing answers with duplicate dependencies or multidex etc. but none worked. (Android studio 2.0 Beta 6, Build tools 23.0.2, no multidex)</p> <p>It turned out that i once used a package names which didn't match the package name that is depicted in the Manifest.</p> <p>In other ParseException lines, i found out that i had files in different modules whith similiar package names/paths that possibly conflicted the dexer.</p> <p><strong>Example:</strong></p> <p>Module A: <em>com.example.xyz.ticketing.modulea.Interface.java</em></p> <p>Module B: <em>com.example.Xyz.ticketing.moduleb.Enumerations.java</em></p> <p>Module C: Has dependencies on A and B</p> <p>After fixing "Xyz" to lowercase, the dexer was fine again.</p> <p><strong>How to find out:</strong></p> <p>When i looked through the output of the gradle console for the <strong>ParseExceptions</strong> that looks like this:</p> <p><em>AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: java.lang.RuntimeException: Exception parsing classes"</em></p> <p>I scrolled close to the end of the exception. There is a part in that long exception line that actually mentions the cause:</p> <p><em>Caused by: com.android.dx.cf.iface.ParseException: class name (at/dummycompany/mFGM/hata/hwp/BuildConfig) does not match path (at/dummycompany/mfgm/hata/hwp/BuildConfig.class)</em></p> <p>This way i found out where to search for missmatching package names/paths</p>
53,219,113
Where can I make API call with hooks in react?
<p>Basically we do API calls in <code>componentDidMount()</code> life cycle method in React class components like below</p> <pre><code> componentDidMount(){ //Here we do API call and do setState accordingly } </code></pre> <p>But after hooks are introduced in React v16.7.0, its all like functional components mostly</p> <p>My query is, where exactly do we need to make API call in functional component with hooks? </p> <p>Do we have any method for it similar like <code>componentDidMount()</code>?</p>
53,219,430
5
0
null
2018-11-09 02:43:46.433 UTC
28
2022-06-21 16:01:31.82 UTC
2019-08-07 13:57:27.45 UTC
null
6,903,497
null
6,903,497
null
1
77
javascript|reactjs|react-native|react-hooks
89,846
<p>Yes, there's a similar (but not the same!) substitute for <code>componentDidMount</code> with hooks, and it's the <code>useEffect</code> hook.</p> <p>The other answers don't really answer your question about where you can make API calls. You can make API calls by using <code>useEffect</code> and <strong>passing in an empty array or object as the second argument</strong> as a replacement for <code>componentDidMount()</code>. The key here is the second argument. If you don't provide an empty array or object as the second argument, the API call will be called on every render, and it effectively becomes a <code>componentDidUpdate</code>.</p> <p>As mentioned in the docs:</p> <blockquote> <p>Passing in an empty array [] of inputs tells React that your effect doesn’t depend on any values from the component, so that effect would run only on mount and clean up on unmount; it won’t run on updates.</p> </blockquote> <p>Here are some examples for scenarios where you will need to make API calls:</p> <h2>API Call Strictly on Mount</h2> <p>Try running the code below and see the result.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function User() { const [firstName, setFirstName] = React.useState(null); const [lastName, setLastName] = React.useState(null); React.useEffect(() =&gt; { fetch('https://randomuser.me/api/') .then(results =&gt; results.json()) .then(data =&gt; { const {name} = data.results[0]; setFirstName(name.first); setLastName(name.last); }); }, []); // &lt;-- Have to pass in [] here! return ( &lt;div&gt; Name: {!firstName || !lastName ? 'Loading...' : `${firstName} ${lastName}`} &lt;/div&gt; ); } ReactDOM.render(&lt;User /&gt;, document.querySelector('#app'));</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/[email protected]/umd/react.development.js"&gt;&lt;/script&gt; &lt;script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"&gt;&lt;/script&gt; &lt;div id="app"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <h2>API Call Whenever Some Prop/State Changes</h2> <p>If you are for example displaying a profile page of a user where each page has a userID state/prop, you should pass in that ID as a value into the second parameter of <code>useEffect</code> so that the data will be refetched for a new user ID. <code>componentDidMount</code> is insufficient here as the component might not need remounting if you go directly from user A to user B's profile.</p> <p>In the traditional classes way, you would do:</p> <pre><code>componentDidMount() { this.fetchData(); } componentDidUpdate(prevProps, prevState) { if (prevState.id !== this.state.id) { this.fetchData(); } } </code></pre> <p>With hooks, that would be:</p> <pre><code>useEffect(() =&gt; { this.fetchData(); }, [id]); </code></pre> <p>Try running the code below and see the result. Change the id to 2 for instance to see that <code>useEffect</code> is run again.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function Todo() { const [todo, setTodo] = React.useState(null); const [id, setId] = React.useState(1); React.useEffect(() =&gt; { if (id == null || id === '') { return; } fetch(`https://jsonplaceholder.typicode.com/todos/${id}`) .then(results =&gt; results.json()) .then(data =&gt; { setTodo(data); }); }, [id]); // useEffect will trigger whenever id is different. return ( &lt;div&gt; &lt;input value={id} onChange={e =&gt; setId(e.target.value)}/&gt; &lt;br/&gt; &lt;pre&gt;{JSON.stringify(todo, null, 2)}&lt;/pre&gt; &lt;/div&gt; ); } ReactDOM.render(&lt;Todo /&gt;, document.querySelector('#app'));</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/[email protected]/umd/react.development.js"&gt;&lt;/script&gt; &lt;script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"&gt;&lt;/script&gt; &lt;div id="app"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>You should read up on <a href="https://reactjs.org/docs/hooks-reference.html#useeffect" rel="noreferrer"><code>useEffect</code></a> so that you know what you can/cannot do with it.</p> <h2>Suspense</h2> <p>As Dan Abramov said on <a href="https://github.com/facebook/react/issues/14326" rel="noreferrer">this GitHub Issue</a>:</p> <blockquote> <p>Longer term we'll discourage this (useEffect) pattern because it encourages race conditions. Such as — anything could happen between your call starts and ends, and you could have gotten new props. Instead, we'll recommend Suspense for data fetching</p> </blockquote> <p>So stay tuned for Suspense!</p>
25,772,750
Sierpinski triangle recursion using turtle graphics
<p>I am trying to write a program that draws a sierpinski tree with python using turtle. Here is my idea:</p> <pre><code>import turtle def draw_sierpinski(length,depth): window = turtle.Screen() t = turtle.Turtle() if depth==0: for i in range(0,3): t.fd(length) t.left(120) else: draw_sierpinski(length/2,depth-1) t.fd(length/2) draw_sierpinski(length/2,depth-1) t.bk(length/2) t.left(60) t.fd(length/2) t.right(60) draw_sierpinski(length/2,depth-1) window.exitonclick() draw_sierpinski(500,1) </code></pre> <p>The program does not reach the 2nd line after the else statement and I don't know why. Can anyone help me?</p>
25,772,897
8
0
null
2014-09-10 18:41:42.71 UTC
3
2021-11-22 19:50:20.797 UTC
2016-10-17 07:27:56.553 UTC
null
355,230
null
3,812,925
null
1
7
python|recursion|turtle-graphics
40,364
<p>I don't think you should be creating the turtle or window object inside the function. Since <code>draw_sierpinski</code> gets called four times if you originally call it with depth 1, then you'll create four separate windows with four separate turtles, each one drawing only a single triangle. Instead, I think you should have only one window and one turtle.</p> <pre><code>import turtle def draw_sierpinski(length,depth): if depth==0: for i in range(0,3): t.fd(length) t.left(120) else: draw_sierpinski(length/2,depth-1) t.fd(length/2) draw_sierpinski(length/2,depth-1) t.bk(length/2) t.left(60) t.fd(length/2) t.right(60) draw_sierpinski(length/2,depth-1) window = turtle.Screen() t = turtle.Turtle() draw_sierpinski(500,1) window.exitonclick() </code></pre> <p>Result:</p> <p><img src="https://i.stack.imgur.com/AKz7V.png" alt="enter image description here"></p> <hr> <p>These results look pretty good for a depth 1 triangle, but what about when we call <code>draw_sierpinski(100,2)</code>?</p> <p><img src="https://i.stack.imgur.com/advqh.png" alt="enter image description here"></p> <p>Ooh, not so good. This occurs because the function should draw the shape, and then return the turtle to its original starting position and angle. But as is evident from the depth 1 image, the turtle doesn't return to its starting position; it ends up halfway up the left slope. You need some additional logic to send it back home.</p> <pre><code>import turtle def draw_sierpinski(length,depth): if depth==0: for i in range(0,3): t.fd(length) t.left(120) else: draw_sierpinski(length/2,depth-1) t.fd(length/2) draw_sierpinski(length/2,depth-1) t.bk(length/2) t.left(60) t.fd(length/2) t.right(60) draw_sierpinski(length/2,depth-1) t.left(60) t.bk(length/2) t.right(60) window = turtle.Screen() t = turtle.Turtle() draw_sierpinski(100,2) window.exitonclick() </code></pre> <p>Result:</p> <p><img src="https://i.stack.imgur.com/CTXVM.png" alt="enter image description here"></p>
43,235,179
How to execute ssh-keygen without prompt
<p>I want to automate generate a pair of ssh key using shell script on Centos7, and I have tried</p> <pre><code>yes "y" | ssh-keygen -t rsa echo "\n\n\n" | ssh-keygen... echo | ssh-keygen.. </code></pre> <p>all of these command doesn't work, just input one 'enter' and the shell script stopped on "Enter passphrase (empty for no passphrase)", I just want to know how to simulate mutiple 'enter' in shell continuously.</p> <p>Many thanks if anyone can help !</p>
43,235,320
7
0
null
2017-04-05 15:11:19.973 UTC
24
2021-08-27 05:58:52.89 UTC
2019-05-10 12:42:31.107 UTC
null
2,214,693
null
5,412,341
null
1
106
linux|bash|shell|ssh
77,457
<p>We need to accomplish <strong>two steps</strong> automatically:</p> <ol> <li><p><strong>Enter a passphrase</strong>. Use the <code>-N</code> flag (void string for this example):</p> <p><code>ssh-keygen -t rsa -N ''</code></p> </li> <li><p><strong>Overwrite the key file</strong>:</p> </li> </ol> <p>Use <code>-f</code> to enter the path (in this example <code>id_rsa</code>) plus a <strong>here-string</strong> to answer <em>yes</em> to the following question:</p> <pre><code>ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa &lt;&lt;&lt;y &gt;/dev/null 2&gt;&amp;1 </code></pre> <p>Or, under a <code>bash</code> like shell, If you <strong>certainly want to overwrite the previous one</strong>, use just a <strong>here-string</strong> to <em>feed the command</em> with all the need <em>input</em>:</p> <pre><code>ssh-keygen -q -t rsa -N '' &lt;&lt;&lt; $'\ny' &gt;/dev/null 2&gt;&amp;1 </code></pre> <p>From <code>ssh-keygen</code> <em>man</em> page:</p> <blockquote> <pre><code> -N new_passphrase provides the new passphrase. -q silence ssh-keygen. -f filename specifies the filename of the key file. </code></pre> </blockquote> <hr /> <p><strong>Step by step explanation</strong></p> <pre><code>$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/klashxx/.ssh/id_rsa): </code></pre> <p><strong>1</strong>) To avoid entering the key use <code>-f</code>:</p> <pre><code>$ ssh-keygen -t rsa -f ~/.ssh/id_rsa Generating public/private rsa key pair. /home/klashxx/.ssh/id_rsa already exists. Overwrite (y/n)? </code></pre> <p><strong>ATTENTION</strong>: If you don't care about the RSA file name and certainly want to overwrite the previous one, check the instructions below point four.</p> <p><strong>2</strong>) Now we need to answer &quot;<strong>y</strong>&quot; automatically to the <em>overwrite question</em> (let's use a <a href="https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Here-Strings" rel="noreferrer"><em>here-string</em></a> for that job):</p> <pre><code>$ ssh-keygen -t rsa -f ~/.ssh/id_rsa &lt;&lt;&lt; y Generating public/private rsa key pair. /home/klashxx/.ssh/id_rsa already exists. Overwrite (y/n)? Enter passphrase (empty for no passphrase): </code></pre> <p><strong>3</strong>) Finally we're going to use the <code>-N</code> flag to enter a void pass:</p> <pre><code>$ ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa &lt;&lt;&lt; y Generating public/private rsa key pair. /home/klashxx/.ssh/id_rsa already exists. Overwrite (y/n)? Your identification has been saved in /home/klashxx/.ssh/id_rsa. Your public key has been saved in /home/klashxx/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Xo0t6caMB/8TSsigxfY28JIfqYjyqxRZrFrPncx5yiU klashxx@server The key's randomart image is: +---[RSA 2048]----+ | | | . | | o . | | + * = | | +. + BSo= o | |...o.+o+XO... | |.. .o.E==+B. . | |o . ...=.o... | |.+o. o .. | +----[SHA256]-----+ </code></pre> <p><strong>4</strong>) <em>Extra ball</em>, cleanup the output, just check the return code:</p> <pre><code>$ ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa &lt;&lt;&lt;y &gt;/dev/null 2&gt;&amp;1 $ echo $? 0 </code></pre> <hr /> <p><strong>An alternative path to overwrite the previous RSA file (no -f flag needed)</strong></p> <p><strong>NOTE</strong>: Only <code>bash</code> like shells.</p> <p>If you don't care about the RSA name and just want to overwrite it, we need to answer these two questions automatically:</p> <blockquote> <ol> <li><p>Enter file in which to save the key: /example/path/.ssh/id_rsa already exists.</p> </li> <li><p>Overwrite (y/n)?</p> </li> </ol> </blockquote> <p>If we do this by hand, for the first question we just need to hit <em>enter</em>, and for the second, type <code>y</code> and press <code>enter</code>.</p> <p>We can simulate these actions by using the following <a href="https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Here-Strings" rel="noreferrer"><em>here-string</em></a>:</p> <p><code>$'\ny'</code></p> <p>From the <code>bash</code> man page:</p> <blockquote> <p>Words of the form $'string' are treated specially. The word expands to &quot;string&quot;, with backslash-escaped characters replaced as specified by the ANSI C standard.</p> <p>\n new line</p> </blockquote> <p>So, if we use <code>od</code> to analyze our string:</p> <pre><code>cat - &lt;&lt;&lt; $'\ny' | od -c 0000000 \n y \n </code></pre> <p>We see that we're getting just what we need to answer the questions.</p> <p><strong>Points 1 and 2 can be summarized into</strong>:</p> <pre><code>ssh-keygen -q -t rsa &lt;&lt;&lt; $'\ny' </code></pre> <p>And the <strong>final command</strong> will be:</p> <pre><code>$ ssh-keygen -q -t rsa -N '' &lt;&lt;&lt; $'\ny' &gt;/dev/null 2&gt;&amp;1 $ echo $? 0 </code></pre> <hr /> <p><strong>Kudos</strong></p> <p>@lukasz-dynowski, @redochka, @mellow-yellow, @yeti and the rest of the folks in this thread.</p>
8,785,554
How do I insert a list at the front of another list?
<pre><code>&gt;&gt;&gt; a = ['foo.py'] &gt;&gt;&gt; k = ['nice', '-n', '10'] &gt;&gt;&gt; a.insert(0, k) &gt;&gt;&gt; a [['nice', '-n', '10'], 'foo.py'] </code></pre> <p>I want to list <code>k</code> to be on the same level as <code>foo.py</code>, rather than a sublist.</p>
8,785,579
6
0
null
2012-01-09 08:24:48.453 UTC
3
2014-09-15 19:26:15.17 UTC
null
null
null
null
834,839
null
1
29
python
28,422
<p>Apply slicing:</p> <pre><code>a[0:0] = k </code></pre> <p>Or do it manually:</p> <pre><code>a = k + a </code></pre> <p>The first approach remain the same for insertion at any place, i.e. <code>a[n:n] = k</code> would insert k at position n, but the second approach would not be the same, that will be</p> <pre><code>a = a[:n] + k + a[n:] </code></pre>
8,519,381
How does protocol buffer handle versioning?
<p>How does protocol buffers handle type versioning? </p> <p>For example, when I need to change a type definition over time? Like adding and removing fields.</p>
8,519,988
2
0
null
2011-12-15 11:30:10.453 UTC
8
2018-08-14 10:22:33.53 UTC
2018-08-14 10:22:33.53 UTC
null
834,521
null
1,051,956
null
1
49
protocol-buffers|protobuf-net
34,282
<p>Google designed protobuf to be pretty forgiving with versioning:</p> <ul> <li>unexpected data is either stored as "extensions" (making it round-trip safe), or silently dropped, depending on the implementation</li> <li>new fields are generally added as "optional", meaning that old data can be loaded successfully</li> </ul> <p>however:</p> <ul> <li>do not <em>renumber</em> fields - that would break existing data</li> <li>you should not normally change the way any given field is stored (i.e. from a fixed-with 32-bit int to a "varint")</li> </ul> <p>Generally speaking, though - it will <em>just work</em>, and you don't need to worry much about versioning.</p>
55,548,153
Flutter Navigator.of(context).pop vs Navigator.pop(context) difference
<p>What's the difference between <code>Navigator.of(context).pop</code> and <code>Navigator.pop(context)</code>?</p> <p>To me both seems to do the same work, what is the actual difference. Is one deprecated? </p>
57,457,578
3
0
null
2019-04-06 10:25:57.187 UTC
5
2022-03-25 12:22:23.94 UTC
null
null
null
user6274128
null
null
1
29
dart|flutter
29,139
<p><strong>Navigator.push(context, route) vs Navigator.of(context).push(route)</strong></p> <p>Navigator is used to manage the app's stack of pages(routes). When push the given route onto the screen(Navigator), We need to get the right Navigator and then push.</p> <p><code>Navigator.of(context).push(route)</code> splits <code>.of(context)</code> to get the right Navigator and <code>.push(route)</code>. <code>Navigator.of(context)</code> has optional parameters, if <code>rootNavigator</code> is set to true, the NavigatorState from the furthest is given instead. </p> <pre><code> static NavigatorState of( BuildContext context, { bool rootNavigator = false, bool nullOk = false, }) </code></pre> <p><code>Navigator.push(context, route)</code> is a static method and do both at the same time. It internally calls <code>Navigator.of(context).push(route)</code>. The navigator is most tightly encloses the given context.</p> <pre><code>static Future&lt;T&gt; push&lt;T extends Object&gt;(BuildContext context, Route&lt;T&gt; route) { return Navigator.of(context).push(route); } </code></pre> <p><code>pop()</code> is similar to <code>push()</code>.</p> <p>When multiple Navigators are nested in App. The dialog route created by <code>showDialog(...)</code> method is pushed to the root navigator. If the application has multiple Navigator objects, it may be necessary to call <code>Navigator.of(context, rootNavigator: true).pop(result)</code> to close the dialog rather than just <code>Navigator.pop(context, result)</code>.</p>
26,988,167
Swift Dictionary: Get values as array
<p>I have a dictionary containing <code>UIColor</code> objects hashed by an enum value, <code>ColorScheme</code>:</p> <pre><code>var colorsForColorScheme: [ColorScheme : UIColor] = ... </code></pre> <p>I would like to be able to extract an array of all the colors (the values) contained by this dictionary. I thought I could use the <code>values</code> property, as is used when iterating over dictionary values (<code>for value in dictionary.values {...}</code>), but this returns an error:</p> <pre><code>let colors: [UIColor] = colorsForColorSchemes.values ~~~~~~~~~~~~~~~~~~~~~^~~~~~~ 'LazyBidrectionalCollection&lt;MapCollectionView&lt;Dictionary&lt;ColorScheme, UIColor&gt;, UIColor&gt;&gt;' is not convertible to 'UIColor' </code></pre> <p>It seems that rather than returning an <code>Array</code> of values, the <code>values</code> method returns a more abstract collection type. Is there a way to get an <code>Array</code> containing the dictionary's values without extracting them in a <code>for-in</code> loop?</p>
26,988,168
7
1
null
2014-11-18 06:41:46.673 UTC
24
2021-02-22 14:50:55.187 UTC
null
null
null
null
429,427
null
1
191
arrays|dictionary|swift
116,080
<p>As of Swift 2.0, <code>Dictionary</code>’s <code>values</code> property now returns a <code>LazyMapCollection</code> instead of a <code>LazyBidirectionalCollection</code>. The <code>Array</code> type knows how to initialise itself using this abstract collection type:</p> <pre><code>let colors = Array(colorsForColorSchemes.values) </code></pre> <p>Swift's type inference already knows that these values are <code>UIColor</code> objects, so no type casting is required, which is nice!</p>
22,167,684
MapReduce or Spark?
<p>I have tested hadoop and mapreduce with cloudera and I found it pretty cool, I thought I was the most recent and relevant BigData solution. But few days ago, I found this : <a href="https://spark.incubator.apache.org/" rel="noreferrer">https://spark.incubator.apache.org/</a></p> <p>A "Lightning fast cluster computing system", able to work on the top of a Hadoop cluster, and apparently able to crush mapreduce. I saw that it worked more in RAM than mapreduce. I think that mapreduce is still relevant when you have to do cluster computing to overcome I/O problems you can have on a single machine. But since Spark can do the jobs that mapreduce do, and may be way more efficient on several operations, isn't it the end of MapReduce ? Or is there something more that MapReduce can do, or can MapReduce be more efficient than Spark in a certain context ?</p>
22,172,367
2
0
null
2014-03-04 09:23:28.157 UTC
13
2020-05-01 17:13:24.35 UTC
2020-05-01 17:13:24.35 UTC
null
4,157,124
null
2,790,593
null
1
28
apache-spark|hadoop|mapreduce
22,141
<p>MapReduce is batch oriented in nature. So, any frameworks on top of MR implementations like Hive and Pig are also batch oriented in nature. For iterative processing as in the case of Machine Learning and interactive analysis, Hadoop/MR doesn't meet the requirement. <a href="http://blog.cloudera.com/blog/2014/03/why-apache-spark-is-a-crossover-hit-for-data-scientists/" rel="noreferrer">Here</a> is a nice article from Cloudera on <code>Why Spark</code> which summarizes it very nicely.</p> <p>It's not an end of MR. As of this writing Hadoop is much mature when compared to Spark and a lot of vendors support it. It will change over time. Cloudera has started including Spark in CDH and over time more and more vendors would be including it in their Big Data distribution and providing commercial support for it. We would see MR and Spark in parallel for foreseeable future.</p> <p>Also with Hadoop 2 (aka YARN), MR and other models (including Spark) can be run on a single cluster. So, Hadoop is not going anywhere.</p>
6,781,110
How can I hide series from a HighCharts legend?
<p>I have 4 series in my chart. 2 are visible when the chart loads. 2 are hidden. </p> <p>When the user zooms in, the visibility switches.</p> <p>How can I have a legend that only displays the 2 visible series?</p>
6,786,323
1
0
null
2011-07-21 18:48:17.367 UTC
2
2011-07-22 06:16:49.78 UTC
null
null
null
null
545,447
null
1
28
javascript|highcharts
28,898
<p>Pass <code>showInLegend</code> parameter to series you don't want to be visible in legend like:</p> <pre><code>series.showInLegend = false; </code></pre>
6,555,600
Gaussian blur cutoff at edges
<p>I am working on an svg export utility for a drawing program on android. I am having a problem that the behind blur is cutoff past the shape boundaries - looks like i need to resize the viewBox or increase the margin or something. Does anyone know the best way?</p> <p>The test file url is <a href="http://www.robmunro.net/misc/test.svg" rel="noreferrer">here</a> - it downloads as the mime type isn't setup correctly on the server and I cant restart it at the moment :(. There are embedded images and fonts in the file, Which is why it's big. But if you save it to disk you can open in chrome, ff, etc...</p> <p>An enlarged example of this problem is given. Notice the square edges on the orange glow.</p> <p><img src="https://i.stack.imgur.com/Z1UWx.png"/></p>
6,556,655
1
0
null
2011-07-02 07:04:40.253 UTC
5
2013-11-08 17:08:47.947 UTC
2013-11-08 17:08:47.947 UTC
null
24,874
null
668,195
null
1
34
svg|svg-filters
9,308
<p>The filter canvas has default values : x=y=-10% and width=height=120%. You can change them with the x, y, width and height attributes on the filter element.</p> <p>Try to set a bigger canvas :</p> <pre><code>&lt;filter x="-50%" y="-50%" width="200%" height="200%"/&gt; </code></pre> <p>Yet, since the canvas is bigger, there will be performance loss.</p>
41,329,108
ASP.NET Core Get Json Array using IConfiguration
<p>In appsettings.json</p> <pre><code>{ "MyArray": [ "str1", "str2", "str3" ] } </code></pre> <hr> <p>In Startup.cs</p> <pre><code>public void ConfigureServices(IServiceCollection services) { services.AddSingleton&lt;IConfiguration&gt;(Configuration); } </code></pre> <hr> <p>In HomeController</p> <pre><code>public class HomeController : Controller { private readonly IConfiguration _config; public HomeController(IConfiguration config) { this._config = config; } public IActionResult Index() { return Json(_config.GetSection("MyArray")); } } </code></pre> <hr> <p>There are my codes above, I got null How to get the array?</p>
41,330,941
18
0
null
2016-12-26 09:34:05.697 UTC
39
2022-03-14 23:04:14.51 UTC
2019-03-01 08:24:38.223 UTC
null
9,020,340
null
7,324,189
null
1
319
c#|asp.net-core|asp.net-core-mvc
191,650
<p>If you want to pick value of first item then you should do like this-</p> <pre><code>var item0 = _config.GetSection("MyArray:0"); </code></pre> <p>If you want to pick value of entire array then you should do like this-</p> <pre><code>IConfigurationSection myArraySection = _config.GetSection("MyArray"); var itemArray = myArraySection.AsEnumerable(); </code></pre> <p>Ideally, you should consider using <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-2.1" rel="noreferrer">options pattern</a> suggested by official documentation. This will give you more benefits.</p>
20,198,137
Image label for input in a form not clickable in IE11
<h1>The problem</h1> <p>In IE11 the image in the following code is clickable to activate/toggle the input in the label:</p> <pre><code>&lt;label&gt; &lt;input type="checkbox"&gt; some text &lt;img src="http://placeimg.com/100/100/any" alt="some img"&gt; &lt;/label&gt; </code></pre> <p>While the image in the this exactly same code but inside of a <code>&lt;form&gt;</code> is not clickable to activate/toggle the input:</p> <pre><code>&lt;form&gt; &lt;label&gt; &lt;input type="checkbox"&gt; some text &lt;img src="http://placeimg.com/100/100/any" alt="some img"&gt; &lt;/label&gt; &lt;/form&gt; </code></pre> <p>(<a href="http://jsfiddle.net/GYNUS/">Demo at jsfiddle</a>)</p> <p><img src="https://i.imgur.com/FVpKLYb.gif" alt="Example"></p> <p><em>Note that in the example animation above I'm clicking the second image, which doesn't work, but clicking on the text works (just did that to demonstrate).</em></p> <p><strong>This was tested and reproduced on:</strong></p> <ul> <li>IE 11.0.9600.16428 on Windows 7 Pro SP1 x64.</li> <li>IE 11.0.9600.16438 on Windows RT 8.1 tablet.</li> <li>IE 11.0.9600.17105 on Windows 7 Pro SP1 x64.</li> <li>IE 11.0.10240.16431 on <em>Windows 10</em></li> </ul> <p>This issue does not occur in IE9, IE10, Microsoft <em>Edge</em>, and other browsers.</p> <h1>Questions:</h1> <ol> <li>Can this be solved <strong>without</strong> JS while still using image tags?</li> <li>If not, what other possible solutions are there?</li> <li><em>(Optional)</em> Why doesn't the image in the second example trigger the input element (while doing it in the first)?</li> </ol>
20,222,705
2
0
null
2013-11-25 16:30:47.563 UTC
18
2015-09-03 08:41:09.777 UTC
2015-09-03 08:41:09.777 UTC
null
107,152
null
107,152
null
1
68
html|css|internet-explorer-11
47,585
<p>One way to fix this is with <code>pointer-events: none</code> on the image, and adjusting the label with for example <code>display: inline-block</code>. (<code>pointer-events</code> <a href="http://caniuse.com/#feat=pointer-events" rel="noreferrer">is supported</a> in IE11.)</p> <pre><code>label{ display: inline-block; } label img{ pointer-events: none; } </code></pre> <p>(<a href="http://jsfiddle.net/VdJ9m/" rel="noreferrer">Demo at jsFiddle</a>)</p>
6,017,778
C# Regex: Checking for "a-z" and "A-Z"
<p>I want to check if a string inputted in a character between a-z or A-Z. Somehow my regular expression doesn't seem to pick it up. It always returns true. I am not sure why, I gather it has to do with how I am writing my regular expression. Any help would be appreciated. </p> <pre><code>private static bool isValid(String str) { bool valid = false; Regex reg = new Regex((@"a-zA-Z+")); if (reg.Match(str).Success) valid = false; else valid = true; return valid; } </code></pre>
6,017,834
3
2
null
2011-05-16 12:58:59.303 UTC
5
2018-10-07 09:44:26.403 UTC
2011-05-16 13:04:40.913 UTC
null
179,386
null
755,665
null
1
19
c#|regex
60,126
<p>The right way would be like so:</p> <pre><code>private static bool isValid(String str) { return Regex.IsMatch(str, @"^[a-zA-Z]+$"); } </code></pre> <p>This code has the following benefits:</p> <ul> <li>Using the static method instead of creating a new instance every time: The static method caches the regular expression</li> <li>Fixed the regex. It now matches any string that consists of one or more of the characters a-z or A-Z. No other characters are allowed.</li> <li>Much shorter and readable.</li> </ul>
5,916,565
Define git alias with the same name to shadow original command
<p>I'm trying to use to use the same name for an alias as the existing command, so that the alias shadows the original command (preventing me from deleting files off the working tree). </p> <pre><code>[alias] rm = rm --cached diff = diff --color </code></pre> <p>Unfortunatly this is not working. Does anyone know a workaround? Thanks.</p> <p><strong>Edit</strong> Setting <code>color.diff = true</code> gives colored output as default.</p>
5,917,211
4
2
null
2011-05-06 20:16:55.077 UTC
5
2021-09-21 00:45:57.99 UTC
2011-05-06 20:41:38.487 UTC
null
432,113
null
432,113
null
1
35
git|alias
4,822
<p>For commands like <code>rm --cached</code> that don't have configurable options, your best bet is to just make an alias named differently. For example:</p> <pre><code>[alias] rmc = rm --cached </code></pre> <p>You may have already figured this out, but Git aliases cannot shadow existing Git commands. From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-config.html" rel="noreferrer"><code>git-config</code> man page</a>:</p> <blockquote> <p>To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored.</p> </blockquote>
29,792,372
Apache2 WebSockets reverse proxy on same URL
<p>How to configure Apache2 to proxy WebSocket connection (BrowserSync for example), if it's made on the same URL, with only difference being header "Upgrade: websocket" and URL schema ws://?</p> <p>For example:</p> <pre><code>HTTP request: GET http://example.com/browser-sync/socket.io/?... HTTP/1.1 ... WebSocket request: GET ws://example.com/browser-sync/socket.io/?... HTTP/1.1 Connection: upgrade Upgrade: websocket Sec-WebSocket-Version: 13 ... </code></pre> <p>All examples I find, redirect some path only, like "&lt;Location /ws&gt;..." or "ProxyPass /ws/ ws://example.com/"</p> <p>My current config:</p> <pre><code>ProxyRequests off &lt;Location /&gt; ProxyPass http://127.0.0.1:3000/ ProxyPassReverse / &lt;/Location&gt; </code></pre> <p>mod_proxy, mod_proxy_http and mod_proxy_wstunnel are enabled.</p>
29,823,699
2
0
null
2015-04-22 08:52:59.04 UTC
8
2018-02-07 14:51:15.437 UTC
2015-04-23 12:25:58.563 UTC
null
296,066
null
296,066
null
1
16
apache|websocket|reverse-proxy
21,727
<p>Answering myself.</p> <p>Using RewriteEngine, hint given by <a href="https://serverfault.com/a/623027/283030">this post</a>, and WebSocket handshake specification:</p> <pre><code>RewriteEngine On RewriteCond %{HTTP:Connection} Upgrade [NC] RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteRule /(.*) ws://127.0.0.1:3000/$1 [P,L] ProxyRequests off &lt;Location /&gt; ProxyPass http://127.0.0.1:3000/ ProxyPassReverse / &lt;/Location&gt; </code></pre>
53,465,394
Flutter - Listview.builder inside another Listview
<p>I want my screen to be scrollable so I put everything in a Listview.</p> <p>Now I want to show another Listview inside to show details of a List. When I try this an error is thrown - " Expanded widgets must be placed inside Flex widgets." </p> <p><a href="https://i.stack.imgur.com/opZ7y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/opZ7y.png" alt="enter image description here"></a></p>
53,469,227
7
2
null
2018-11-25 07:05:26.787 UTC
3
2021-11-08 22:28:30.48 UTC
null
null
null
null
6,040,176
null
1
29
android|android-listview|flutter
45,048
<p>Add <code>shrinkWrap: true</code> in <code>listView.builder</code> &amp; Remove the top most <code>Container</code> or replace it with <code>Column</code>.</p>
28,973,554
Not possible to fast-forward even with no changes
<p>I ended up in a weird git state. I want to pull from server, only fast forwards.</p> <p>However, even when there were no changes, git keeps telling me "not possible fast-forward".</p> <pre><code>$ git pull -v --ff-only From github.com:username/repo = [up to date] branch -&gt; origin/branch = [up to date] branch2 -&gt; origin/branch2 = [up to date] branch3 -&gt; origin/branch3 fatal: Not possible to fast-forward, aborting. </code></pre> <p>How do I tell git to tell me more information about this "non-possibility" of fast-forward? I canot be more verbose...</p>
28,973,624
3
1
null
2015-03-10 20:32:25.947 UTC
4
2021-07-15 08:35:21.627 UTC
null
null
null
null
101,152
null
1
22
git
48,357
<p>This happens when (a) you committed something on that branch earlier, or (b) the history on the remote server changed in a non-standard way (this shouldn't normally happen but repository owners sometimes don't play by the rules).</p> <p>For the following I'm assuming you're on <code>foo</code> and the upstream branch is <code>origin/foo</code>.</p> <ul> <li>Use <code>git log ..origin/foo</code> to see what commits are new on the remote side.</li> <li>Use <code>git log origin/foo..</code> to see what commits exist on your side that don't exist on the remote side (this will show you any commits that are preventing fast-forwarding).</li> <li>If you conclude that those commits are not needed or already present in a different form on the remote side, <code>git reset --hard origin/foo</code> to force your branch to become equal to the remote one (this will destroy all uncommitted changes and any commits not contained in <code>remote/foo</code> will become unreachable).</li> </ul>
32,569,883
What is the syntax for writing comments in build.gradle file?
<p>Looking down this <code>build.gradle</code> file</p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "package.myapp" minSdkVersion 19 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.nineoldandroids:library:2.4.0' } </code></pre> <p>What if I would like to write a comment on <em>why did I chose this library for this project</em>,</p> <p>what is the syntax for writing comments in <code>build.gradle</code> file?</p>
32,569,925
2
1
null
2015-09-14 16:49:39.25 UTC
20
2019-07-22 12:01:43.6 UTC
2016-03-15 11:13:38.057 UTC
null
1,549,700
null
1,549,700
null
1
209
android|gradle|comments|android-gradle-plugin|build.gradle
101,234
<p>Easy:</p> <pre><code>// Single line comment /* Multi line comment */ </code></pre>
32,427,300
App Transport Security Xcode 7 beta 6
<p>I'm currently working on <strong>Xcode 7 beta 6</strong>. I'm trying to send a "DELETE" request to <a href="http://mySubdomain.herokuapp.com">http://mySubdomain.herokuapp.com</a> </p> <p>The error I receive is:</p> <blockquote> <p>App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.<br> Error making API call: Error Domain=NSURLErrorDomain Code=-1022 The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.<br> NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSUnderlyingError=0x796f7ef0 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}}</p> </blockquote> <p>In my actual API call I put "https" instead of "http" and that actually worked for my POST requests. But the DELETE request throws the above error.</p> <p>I've seen solutions on here that involve the pList file, but none of them have worked for me. I've listed my attempts below.</p> <p>First attempt:</p> <pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt; &lt;dict&gt; &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt; &lt;true/&gt; &lt;/dict&gt; </code></pre> <p>Second try:</p> <pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt; &lt;dict&gt; &lt;key&gt;NSExceptionDomains&lt;/key&gt; &lt;dict&gt; &lt;key&gt;herokuapp.com&lt;/key&gt; &lt;dict&gt; &lt;key&gt;NSIncludesSubdomains&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSExceptionAllowsInsecureHTTPLoads&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSExceptionRequiresForwardSecrecy&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSExceptionMinimumTLSVersion&lt;/key&gt; &lt;string&gt;TLSv1.2&lt;/string&gt; &lt;key&gt;NSThirdPartyExceptionAllowsInsecureHTTPLoads&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSThirdPartyExceptionRequiresForwardSecrecy&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSThirdPartyExceptionMinimumTLSVersion&lt;/key&gt; &lt;string&gt;TLSv1.2&lt;/string&gt; &lt;key&gt;NSRequiresCertificateTransparency&lt;/key&gt; &lt;false/&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt; </code></pre> <p>And finally, I even put all these temporary keys in like so:</p> <pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt; &lt;dict&gt; &lt;key&gt;NSExceptionDomains&lt;/key&gt; &lt;dict&gt; &lt;key&gt;herokuapp.com&lt;/key&gt; &lt;dict&gt; &lt;key&gt;NSIncludesSubdomains&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSTemporaryIncludesSubdomains&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSExceptionAllowsInsecureHTTPLoads&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSTemporaryExceptionAllowsInsecureHTTPLoads&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSExceptionRequiresForwardSecrecy&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSTemporaryExceptionRequiresForwardSecrecy&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSExceptionMinimumTLSVersion&lt;/key&gt; &lt;string&gt;TLSv1.2&lt;/string&gt; &lt;key&gt;NSTemporaryExceptionMinimumTLSVersion&lt;/key&gt; &lt;string&gt;TLSv1.2&lt;/string&gt; &lt;key&gt;NSThirdPartyExceptionAllowsInsecureHTTPLoads&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSTemporaryThirdPartyExceptionAllowsInsecureHTTPLoads&lt;/key&gt; &lt;true/&gt; &lt;key&gt;NSThirdPartyExceptionRequiresForwardSecrecy&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSTemporaryThirdPartyExceptionRequiresForwardSecrecy&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSThirdPartyExceptionMinimumTLSVersion&lt;/key&gt; &lt;string&gt;TLSv1.2&lt;/string&gt; &lt;key&gt;NSTemporaryThirdPartyExceptionMinimumTLSVersion&lt;/key&gt; &lt;string&gt;TLSv1.2&lt;/string&gt; &lt;key&gt;NSRequiresCertificateTransparency&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSTemporaryRequiresCertificateTransparency&lt;/key&gt; &lt;false/&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt; </code></pre> <p>All with no luck! I always get the same error. The DELETE request is formatted correctly because when I manually do it from Postman, I get the desired result. </p> <p>Here is what my actual API call method looks like, just in case there could be an issue here:</p> <pre><code>class func makeDELETEALLRequest(completion: (error:Bool) -&gt; Void) { let session = NSURLSession.sharedSession() let url = NSURL(string:"https://mysubdomain.herokuapp.com/42kh24kh2kj2g24/clean") let request = NSMutableURLRequest(URL: url!) request.HTTPMethod = "DELETE" let task = session.dataTaskWithRequest(request) { (data, response, error) -&gt; Void in if (error != nil) { print("Error making API call: \(error!)") completion(error: true) } else { let HTTPResponse = response as! NSHTTPURLResponse let statusCode = HTTPResponse.statusCode if (statusCode == 200){ print("Successfully deleted!") completion(error: false) } else { print("Different status code: \(statusCode)") completion(error: true) } } } task.resume() } </code></pre> <p>Once again, I'm using <strong>Xcode 7 beta 6</strong>. </p> <p><strong>ABOUT MY SELECTED ANSWER</strong> The answer I selected as correct was right for me because I made all these changes to the wrong pList file in my project and that answer was the only one that addressed the possibility. The solutions offered by the other answers are not wrong, so any other people experiencing this issue should give them a try, since they are valid. I hope this helps anyone having similar issues.</p>
32,684,910
6
2
null
2015-09-06 19:15:31.12 UTC
15
2022-05-27 13:01:36.347 UTC
2015-09-21 02:28:11.3 UTC
null
3,880,396
null
3,880,396
null
1
36
ios|xcode|swift
39,752
<p>I, too, had trouble overriding App Transport Security after upgrading to xCode 7.0, and tried the same kinds of solutions you have to no avail. After walking away from it for awhile, I noticed that I had made the changes to the Info.plist under Supporting Files of "MyAppName Tests" rather than the one in the project itself. The Supporting Files folder in my project wasn't expanded, so I hadn't even noticed the Info.plist in it.</p> <p>Typical amateur mistake, I'm sure, but they're only a couple of lines apart in the Project Navigator and it had me frustrated until I noticed the distinction. Thought I'd mention it in case you're having the same problem.</p>
5,977,718
Lots of garbage collection in a listview
<p>I have a ListView that uses a custom adapter. The custom adapter's getView uses all the recommended practices:</p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { SuscriptionsViewsHolder holder; ItemInRootList item = mItemsInList.get(position); if (convertView == null) { convertView = mInflater.inflate(R.layout.label, null); holder = new SuscriptionsViewsHolder(); holder.label = (TextView) convertView.findViewById(R.id.label_label); holder.icon = (ImageView) convertView.findViewById(R.id.label_icon); convertView.setTag(holder); } else { holder = (SuscriptionsViewsHolder) convertView.getTag(); } String text = String.format("%1$s (%2$s)", item.title, item.unreadCount); holder.label.setText(text); holder.icon.setImageResource(item.isLabel ? R.drawable.folder : R.drawable.file ); return convertView; } </code></pre> <p>However when I scroll, it is sluggish because of heavy garbage collection:</p> <pre><code>GC_EXTERNAL_ALLOC freed 87K, 48% free 2873K/5447K, external 516K/519K, paused 30ms GC_EXTERNAL_ALLOC freed 7K, 48% free 2866K/5447K, external 1056K/1208K, paused 29ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2866K/5447K, external 1416K/1568K, paused 28ms GC_EXTERNAL_ALLOC freed 5K, 48% free 2865K/5447K, external 1600K/1748K, paused 27ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2865K/5447K, external 1780K/1932K, paused 30ms GC_EXTERNAL_ALLOC freed 2K, 48% free 2870K/5447K, external 1780K/1932K, paused 26ms GC_EXTERNAL_ALLOC freed 2K, 48% free 2870K/5447K, external 1780K/1932K, paused 25ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 26ms GC_EXTERNAL_ALLOC freed 3K, 48% free 2870K/5447K, external 1780K/1932K, paused 25ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 29ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 29ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2871K/5447K, external 1780K/1932K, paused 28ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2871K/5447K, external 1780K/1932K, paused 26ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 27ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 29ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 26ms GC_EXTERNAL_ALLOC freed &lt;1K, 48% free 2870K/5447K, external 1780K/1932K, paused 34ms </code></pre> <p>What seems to be wrong?</p> <p>EDIT @12:47 GMT:</p> <p>In fact it's slightly more complicated than this. My app UI is based on 2 parts. One is the brain of a screen, creating the views, handling user input, etc. The other is a <code>Fragment</code> if the device has android 3.0, otherwise it's an <code>Activity</code>.</p> <p>The GC happened on my Nexus One 2.3.3 device, so using the <code>Activity</code>. I don't have my Xoom with me to test the behaviour with a <code>Fragment</code>.</p> <p>I could post the source if required, but let me try to explain it :</p> <ul> <li><code>RootList</code> is the brain of the UI. It contains : <ul> <li>a <code>List&lt;&gt;</code> of items that will be placed in the <code>ListView</code>.</li> <li>a method that builds this list from a SQLite db</li> <li>a custom BaseAdapter that contains basically only the getView method pasted above</li> </ul></li> <li><code>RootListActivity</code> is a <code>ListActivity</code>, which: <ul> <li>uses an XML layout</li> <li>the layout has of course a listview with id <code>android.id.list</code></li> <li>the <code>Activity</code> callbacks are forwarded to the <code>RootList</code> class using an instance of RootList created when the activity is created (constructor, not <code>onCreate</code>)</li> <li>in the <code>onCreate</code>, I call <code>RootList</code>'s methods that will create the list of items, and set the list data to a new instance of my custom class derived from <code>BaseAdapter</code></li> </ul></li> </ul> <p>EDIT on may 17th @ 9:36PM GMT:</p> <p>Here's the code of the Activity and the class that does the things. <a href="http://pastebin.com/EgHKRr4r">http://pastebin.com/EgHKRr4r</a></p>
6,081,749
9
7
null
2011-05-12 12:07:34.263 UTC
11
2014-06-28 20:53:01.38 UTC
2011-05-17 21:37:10.723 UTC
null
334,493
null
334,493
null
1
22
android|listview|garbage-collection
11,921
<p>I found the issue. My XML layout for the activity was:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;include android:id="@+id/rootlist_header" layout="@layout/pre_honeycomb_action_bar" /&gt; &lt;ListView android:id="@android:id/list" android:layout_below="@id/rootlist_header" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:textColor="#444444" android:divider="@drawable/list_divider" android:dividerHeight="1px" android:cacheColorHint="#00000000" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>If I remove the <code>android:cacheColorHint="#00000000"</code>, the heavy GC is out, and the scrolling is <strong><em>smooth</em></strong>! :)</p> <p>I don't really know why this parameter was set, because I don't need it. Maybe I copypasted too much instead of actually build my XML layout.</p> <p>THANK YOU for your support, I really appreciate your help.</p>
6,245,971
Accurate way to measure execution times of php scripts
<p>I want to know how many milliseconds a PHP for-loop takes to execute. </p> <p>I know the structure of a generic algorithm, but no idea how to implement it in PHP:</p> <pre><code>Begin init1 = timer(); // where timer() is the amount of milliseconds from midnight the loop begin some code the loop end total = timer() - init1; End </code></pre>
6,245,978
15
1
null
2011-06-05 21:25:41.85 UTC
81
2021-10-14 15:40:14.577 UTC
2016-01-08 18:22:03.36 UTC
null
445,131
null
310,648
null
1
334
php
333,529
<p>You can use the <a href="http://php.net/microtime" rel="noreferrer"><code>microtime</code></a> function for this. From <a href="http://php.net/microtime" rel="noreferrer">the documentation</a>:</p> <blockquote> <p><code>microtime</code> — Return current Unix timestamp with microseconds</p> <hr> <p>If <code>get_as_float</code> is set to <code>TRUE</code>, then <code>microtime()</code> returns a float, which represents the current time in seconds since the Unix epoch accurate to the nearest microsecond.</p> </blockquote> <p>Example usage:</p> <pre><code>$start = microtime(true); while (...) { } $time_elapsed_secs = microtime(true) - $start; </code></pre>
5,081,747
.htaccess, order allow, deny, deny from all: confusion
<p>In my .htaccess, I have the following:</p> <pre><code>&lt;Limit GET POST&gt; order deny,allow deny from all allow from all &lt;/Limit&gt; &lt;Limit PUT DELETE&gt; order deny,allow deny from all &lt;/Limit&gt; &lt;Files .htaccess&gt; order allow,deny deny from all &lt;/Files&gt; </code></pre> <p>I looked online and in the Apache documentation and don't understand the <code>limit get post put delete</code> etc., but I put it in thinking that whatever it's doing it is saying to allow then after allowing it is denying again. It just does not make sense to me and I am not sure if I should remove it from .htaccess. I guess the third one means deny access to .htaccess file but this order allow then deny seems like it first allows then immediately denies.</p>
5,088,967
1
1
null
2011-02-22 17:42:18.12 UTC
11
2022-03-02 20:47:20.387 UTC
2022-03-02 20:47:20.387 UTC
null
1,264,804
null
439,232
null
1
18
apache|.htaccess
119,948
<p>This is a quite confusing way of using Apache configuration directives.</p> <p>Technically, the first bit is equivalent to</p> <pre><code>Allow From All </code></pre> <p>This is because <code>Order Deny,Allow</code> makes the Deny directive evaluated before the Allow Directives. In this case, Deny and Allow conflict with each other, but Allow, being the last evaluated will match any user, and access will be granted.</p> <p>Now, just to make things clear, this kind of configuration is BAD and should be avoided at all cost, because it borders undefined behaviour.</p> <p>The Limit sections define which HTTP methods have access to the directory containing the .htaccess file.</p> <p>Here, GET and POST methods are allowed access, and PUT and DELETE methods are denied access. Here's a link explaining what the various HTTP methods are: <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html" rel="noreferrer">http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html</a></p> <p>However, it's more than often useless to use these limitations as long as you don't have custom CGI scripts or Apache modules that directly handle the non-standard methods (PUT and DELETE), since by default, Apache does not handle them at all.</p> <p>It must also be noted that a few other methods exist that can also be handled by Limit, namely CONNECT, OPTIONS, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, and UNLOCK.</p> <p>The last bit is also most certainly useless, since any correctly configured Apache installation contains the following piece of configuration (for Apache 2.2 and earlier):</p> <pre><code># # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # &lt;Files ~ "^\.ht"&gt; Order allow,deny Deny from all Satisfy all &lt;/Files&gt; </code></pre> <p>which forbids access to any file beginning by ".ht".</p> <p>The equivalent Apache 2.4 configuration should look like:</p> <pre><code>&lt;Files ~ "^\.ht"&gt; Require all denied &lt;/Files&gt; </code></pre>
5,217,108
How can I hide my application's form in the Windows Taskbar?
<p>How can I hide the name of my application in the Windows Taskbar, even when it is visible?</p> <p>Currently, I have the following code to initialize and set the properties of my form:</p> <pre><code>this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(0, 0); this.Controls.Add(this.eventlogs); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Form1"; this.Text = "Form1"; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); </code></pre>
5,217,132
1
1
null
2011-03-07 07:44:26.26 UTC
4
2015-04-03 18:54:41.17 UTC
2011-03-07 08:39:28.867 UTC
null
366,904
null
407,309
null
1
25
c#|.net|winforms|taskbar
51,207
<p>To prevent your form from appearing in the taskbar, set its <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showintaskbar.aspx" rel="noreferrer"><strong><code>ShowInTaskbar</code></strong> property</a> to False.</p> <pre><code>this.ShowInTaskbar = false; </code></pre>