pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
24,327,662 | 0 | <p>Post it as a string?</p> <pre><code>byte[] array = new byte[n]; array[0] = .. array[n] = .. String dataToSend = ""; For(int i = 0; i < array.length -1; i++){ dataToSend += (char) array[0]; } // your post code here ... pairs.add(new BasicNameValuePair("key1", dataToSend)); </code></pre> |
39,514,706 | 0 | <p>You need to update the default Android SDK <code>proguard.jar</code> with the latest version of Proguard found here:</p> <p><a href="https://sourceforge.net/projects/proguard/files/" rel="nofollow">https://sourceforge.net/projects/proguard/files/</a></p> <p>I would recommend that you install this on the side of the default version that Android ships in <code>android-sdk\tools\proguard</code>. Simply rename the existing folder to something else and add the new version of <code>proguard</code>.</p> <p>This is listed in the Xamarin.Android 7.0 release notes:</p> <p><a href="https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/" rel="nofollow">https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/</a></p> <p>In which the following bug was logged as well:</p> <p><a href="https://bugzilla.xamarin.com/show_bug.cgi?id=44187" rel="nofollow">https://bugzilla.xamarin.com/show_bug.cgi?id=44187</a></p> <p>Which is coordinated with a Pull Request in the Xamarin.Android repository:</p> <p><a href="https://github.com/xamarin/xamarin-android/pull/209" rel="nofollow">https://github.com/xamarin/xamarin-android/pull/209</a></p> |
28,598,345 | 0 | <p>I think it would be cleaner to use <code>defaultdict</code>:</p> <pre><code>from collections import defaultdict mydict = defaultdict(lambda: 0) for x in cleanList: mydict[x[0]] += float(x[1]) </code></pre> |
21,637,389 | 0 | <p>If you want to the particular value on click of particular link then you can use this code.</p> <pre><code>var data = document.getElementsByClassName("call"); var numbers = []; for (var i = 0; i < data.length; i++) { data[i].onclick = getNumber; } function getNumber(){ numbers.push(this.dataset['number']); alert(this.dataset['number']); } </code></pre> <p>Here is the <a href="http://jsfiddle.net/VykGN/2/" rel="nofollow">DEMO</a></p> <p>There is no <strong>number</strong> property on anchor tag, so for your need we can use <strong>data-*</strong> property which allows you to store needful information on html.</p> |
20,784,782 | 0 | <p>It is impossible or difficult to do it exactly in that format, but here is something close:</p> <pre><code>"1 and 2".scan(/\d/).reverse.join(" and ") # => "2 and 1" </code></pre> |
5,150,496 | 0 | <p>If you don't want the url to put it on option's value, i'll give u example :</p> <pre><code><select class="abc"> <option value="0" href="hello">Hell</option> <option value="1" href="dello">Dell</option> <option value="2" href="cello">Cell</option> </select> $("select").bind('change',function(){ alert($(':selected',this).attr('href')); }) </code></pre> |
21,952,252 | 0 | <pre><code>private static Random random = new Random((int)DateTime.Now.Ticks);//thanks to McAden public long LongBetween(long maxValue, long minValue) { return (long)Math.Round(random.NextDouble() * (maxValue - minValue - 1)) + minValue; } </code></pre> |
1,858,654 | 0 | <p>I guess you mean ASP.Net GridView? GridView sends javascript postback (__dopostback(...) navigate cursor to edit link and note in status bar) when edit link is clicked, to solve your problem you should send that postback in other js event</p> |
17,446,449 | 0 | <p>I do not know how to change chainde transation mode, but I want you to try "clear" JDBC and CallableStatemet. Such code looks like (I do not have Sybase so I cannot test it):</p> <pre><code>db = DriverManager.getConnection(db_url, usr, passwd) proc = db.prepareCall("{ ? = call usp_find(?) }"); proc.registerOutParameter(1, Types.INTEGER) proc.setString(2, "Apples"); proc.execute(); r = proc.getInt(1) print('result: %d' % (r)) </code></pre> |
37,672,675 | 0 | Curl "Failed to connect to example.com port 443: Connection timed out" (HTTPS host) <p>I am trying to send request using CURL but getting a connection timed out error:</p> <pre><code>curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_USERAGENT, 'ucn'); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000); curl_setopt($ch, CURLOPT_TIMEOUT, 1000); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); </code></pre> <p>The only problem I have is that it doesn't work for <code>https://</code>. What do I need to do to make this work for HTTPS?</p> |
15,490,568 | 0 | <p>Just use <code>isalpha</code> to ignore other kinds of characters:</p> <pre><code>#include <string.h> #include <stdio.h> #include <ctype.h> int main (void) { char input[] = "thanks for the add"; int alpha_count = 0; for (int i = 0, x = strlen(input); i < x; i++) { if (isalpha(input[i])) { if (alpha_count++ % 2 == 0 ) input [i] = toupper(input[i]); } } printf("%s\n", input); return 0; } </code></pre> |
37,982,225 | 0 | <p><code>FindSync<></code> does not return a single object. The answer to the question below may help you as well. <a href="http://stackoverflow.com/questions/30650722/difference-between-find-and-findasync">Difference between Find and FindAsync</a></p> |
23,501,946 | 0 | <p>Are you sure, that the <code>programacaoObject.programacaoNome</code>, <code>programacaoObject.programacaoData</code> and <code>programacaoObject.programacaoLocal</code> are not empty?</p> |
2,594,321 | 0 | How do I launch iBooks e-reader programmatically on iPad? <p>Just like <code>UIApplication.openURL</code>.</p> <p>Is there an API to launch iBooks with an ISBN?</p> |
30,117,807 | 0 | <p>If you need <code>Unicode</code> support and you are not able to use the <code>unescape</code> functionality implemented in <code>System.Web</code>, you can use the following replace statement instead:</p> <pre><code>string str = "%u0442%u043E%u0432%u0430%20%u0435%20text%20%14%u20AC"; //replace Unicode characters str = Regex.Replace(str, @"%U([0-9A-F]{4})", match => ((char)int.Parse( match.Groups[1].Value, NumberStyles.HexNumber ) ).ToString(),RegexOptions.IgnoreCase ); //now replace ASCII character str = Regex.Replace(str, @"%([0-9A-F]{2})", match => ((char)int.Parse( match.Groups[1].Value, NumberStyles.HexNumber ) ).ToString(),RegexOptions.IgnoreCase ); Console.WriteLine(str); </code></pre> |
36,309,387 | 0 | <p>use this.</p> <pre><code>$('button').on('click', function() { var nomesalone = $('#nomeSaloneInput').val(); var indirizzo = $('#indirizzoInput').val(); var cap = $('#capInput').val(); var citta = $('#cittaInput').val(); var provincia = $('#provinciaInput').val(); $('#defNomeSalone').text(nomesalone+' '+indirizzo+' '+cap+' '+citta+' '+provincia); }); </code></pre> |
31,497,168 | 0 | <p>In mongoid you can use between to do a search of records within a range. I don't recommend that you do the filtering directly in Ruby as this will be slow and memory intensive for larger data set.</p> <p>This post goes through a solution:</p> <p><a href="http://stackoverflow.com/questions/8136652/query-mongodb-on-month-day-year-of-a-datetime">Query Mongodb on month, day, year... of a datetime</a></p> <p>However, if you want to do it in pure ruby you could do:</p> <pre><code>start, finish = "06:00~09:00".split('~') start_hour = start.split(':')[0].to_i end_hour = finish.split(':')[0].to_i flights.select do |flight| flight.departure_time.hour >= start_hour && flight.departure_time.hour <= end_hour end </code></pre> <p>This will just query for hours. You can include minutes by doing:</p> <pre><code>start, finish = "06:00~09:00".split('~') start = start.split(':').map(&:to_i) finish = finish.split(':').map(&:to_i) # Work in minutes start_minutes = start[0] * 60 + start[1] finish_minutes = finish[0] * 60 + finish[1] flights.select do |flight| dep_mins = flight.departure_time.hour * 60 + flight.departure_time.min dep_mins >= start_minutes && dep_mins <= finish_minutes end </code></pre> |
8,859,207 | 0 | <p>Unless you are 100% rely on the user and it seems that you are not, it will be good not to blindly import uploaded file, but first to check if it's correct.</p> <p>To do it, you'll need to open and to read the file, e.g. with <code>fgetcsv</code> and to check the data consistency line-by-line.</p> <hr> <p>You can find a lot of examples on the web.</p> <p>Here are just some:</p> <ul> <li><a href="http://www.damnsemicolon.com/php/php-upload-csv-mysql" rel="nofollow">http://www.damnsemicolon.com/php/php-upload-csv-mysql</a></li> <li><a href="http://www.programmingfacts.com/import-csvexcel-data-mysql-database/" rel="nofollow">http://www.programmingfacts.com/import-csvexcel-data-mysql-database/</a></li> </ul> |
3,998,601 | 0 | SQL Server combining data question <p>Hey all I am trying to combine my data into one sum. This is my output right now:</p> <pre><code>Amount --------- $258.0 $400.0 $1011.0 $628.0 $628.0 $340.0 $340.0 $1764.0 </code></pre> <p>of course the total would be $5369. This is the type of output I <strong>need</strong></p> <pre><code>Description | Quantity | Price | Amount -------------------------------------------- Fees 8 $1.50 $12.00 Redep $5369.00 $5381.00 </code></pre> <p>Only information above I would really need is the <strong>8</strong>, <strong>12</strong>, <strong>5369.00</strong> and <strong>5381.00</strong>.</p> <p>And this is my query to get those values I first posted:</p> <pre><code>SELECT '$' + CONVERT(varchar(50),round((CONVERT(int,Points) * .1),0)) AS 'Amount' FROM tblHGP HGP, OrderDetails OD, tblInvoices i JOIN tblCS cs ON i.INumber = cs.INumber JOIN tblECI ac ON i.INumber = ac.INumber WHERE cs.SoldTo = HGP.ECard AND issued BETWEEN '2010-09-01' AND '2010-09-30 23:59:59' AND Country = 'US' AND HGP.iNumber = OD.orderdetail ORDER BY issued </code></pre> |
14,893,669 | 0 | <p>Your question now seems to focus on a object oriented cryptographic library for C++. For that question I can recommend <a href="http://botan.randombit.net/" rel="nofollow">Botan</a>. It does seem to focus on modern computing algorithms and includes PBKDF2.</p> <p>Note that I cannot vouch for the security of this library, I haven't used or evaluated it personally.</p> |
3,151,506 | 0 | <p>I'd use one of the private ranges, e.g. 192.168.1.1. I wouldn't use anyone's public IP space.</p> |
15,541,421 | 1 | Python: how to make form a string comprising of text and variable values in python 2.6 <p>Basically I'm looking for concatenating the strings and variable together. </p> <p>In Java: </p> <pre><code>String s = "HI my name is "+var_name+" I'm "+age+" years old"; </code></pre> <p>In PHP: </p> <pre><code>$s = "Hi my name is ".$var_name." I'm ".$age." years old"; </code></pre> <p>I want a similar thing in Python. I know the format function supported by Python 3.0 and above but I have a constraint of running it at Python version 2.6. I can't upgrade so please tell me the best method.</p> <p>P.S - I came to know that format works in Python 2.6 also. If you have any other method please let me know that also. It's always good to know more.</p> |
5,067,242 | 0 | <p>Devexpress has a <a href="http://documentation.devexpress.com/#WindowsForms/clsDevExpressUtilsImageCollectiontopic" rel="nofollow">ImageCollection</a> which is very similar and it supports GIF's. </p> |
31,063,211 | 0 | <p>Firebug displays pseudo-elements within the <a href="https://getfirebug.com/wiki/index.php/Style_Side_Panel" rel="nofollow noreferrer"><em>Style</em> side panel</a> for the selected element, not within the main HTML panel.</p> <p><img src="https://i.stack.imgur.com/TiznP.png" alt="<code>::before</code> pseudo-element shown in *Style* side panel"></p> |
12,593,367 | 0 | <p>Here's a simple JSON encoder in Qt -- should be relatively easy to recast into Java. All you really need to do is to make sure the keys are sorted when writing out -- can read in with another JSON package.</p> <pre><code>QString QvJson::encodeJson(const QVariant& jsonObject) { QVariant::Type type = jsonObject.type(); switch (type) { case QVariant::Map: return encodeObject(jsonObject); case QVariant::List: return encodeArray(jsonObject); case QVariant::String: return encodeString(jsonObject); case QVariant::Int: case QVariant::Double: return encodeNumeric(jsonObject); case QVariant::Bool: return encodeBool(jsonObject); case QVariant::Invalid: return encodeNull(jsonObject); default: return encodingError("encodeJson", jsonObject, ErrorUnrecognizedObject); } } QString QvJson::encodeObject(const QVariant& jsonObject) { QString result("{ "); QMap<QString, QVariant> map = jsonObject.toMap(); QMapIterator<QString, QVariant> i(map); while (i.hasNext()) { i.next(); result.append(encodeString(i.key())); result.append(" : "); result.append(encodeJson(i.value())); if (i.hasNext()) { result.append(", "); } } result.append(" }"); return result; } QString QvJson::encodeArray(const QVariant& jsonObject) { QString result("[ "); QList<QVariant> list = jsonObject.toList(); for (int i = 0; i < list.count(); i++) { result.append(encodeJson(list.at(i))); if (i+1 < list.count()) { result.append(", "); } } result.append(" ]"); return result; } QString QvJson::encodeString(const QVariant &jsonObject) { return encodeString(jsonObject.toString()); } QString QvJson::encodeString(const QString& value) { QString result = "\""; for (int i = 0; i < value.count(); i++) { ushort chr = value.at(i).unicode(); if (chr < 32) { switch (chr) { case '\b': result.append("\\b"); break; case '\f': result.append("\\f"); break; case '\n': result.append("\\n"); break; case '\r': result.append("\\r"); break; case '\t': result.append("\\t"); break; default: result.append("\\u"); result.append(QString::number(chr, 16).rightJustified(4, '0')); } // End switch } else if (chr > 255) { result.append("\\u"); result.append(QString::number(chr, 16).rightJustified(4, '0')); } else { result.append(value.at(i)); } } result.append('"'); QString displayResult = result; // For debug, since "result" often doesn't show Q_UNUSED(displayResult); return result; } QString QvJson::encodeNumeric(const QVariant& jsonObject) { return jsonObject.toString(); } QString QvJson::encodeBool(const QVariant& jsonObject) { return jsonObject.toString(); } QString QvJson::encodeNull(const QVariant& jsonObject) { return "null"; } QString QvJson::encodingError(const QString& method, const QVariant& jsonObject, Error error) { QString text; switch (error) { case ErrorUnrecognizedObject: text = QObject::tr("Unrecognized object type"); break; default: Q_ASSERT(false); } return QObject::tr("*** Error %1 in QvJson::%2 -- %3").arg(error).arg(method).arg(text); } </code></pre> |
20,914,509 | 0 | PHP validation using PDO not working <p>I am new to PDO. I have included validation in the following code but it doesnt seem to work and no message appears if users enter the wrong username/password. Please show me where I am going wrong. I have numerous times to get this working but no luck. Thanks</p> <pre><code><?php require("config.php"); $submitted_username = ''; if(!empty($_POST)){ $query = " SELECT id, username, password, salt, email FROM users WHERE username = :username "; $query_params = array( ':username' => $_POST['username'] ); try{ $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex){ die("Failed to run query: " . $ex->getMessage()); } $login_ok = false; $row = $stmt->fetch(); if($row){ $check_password = hash('sha256', $_POST['password'] . $row['salt']); for($round = 0; $round < 65536; $round++){ $check_password = hash('sha256', $check_password . $row['salt']); } if($check_password === $row['password']){ $login_ok = true; } } if($login_ok){ unset($row['salt']); unset($row['password']); $_SESSION['user'] = $row; header("Location: secret.php"); die("Redirecting to: secret.php"); } else{ print("Login Failed."); $submitted_username = htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8'); } } ?> </code></pre> <p><strong>Config.php</strong></p> <pre><code><?php // These variables define the connection information for your MySQL database $username = "xxxx"; $password = "xxxx"; $host = "xxxxxxx"; $dbname = "xxxxxx"; $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); try { $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options); } catch(PDOException $ex) { die("Failed to connect to the database: " . $ex->getMessage()); } $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); header('Content-Type: text/html; charset=utf-8'); session_start(); ?> </code></pre> |
14,507,064 | 0 | <p><code>GestureDetector</code> allows you to specify <code>OnDoubleTapListener</code> as well as <code>OnGestureListener</code>. The only thing you need to do is implement <code>OnDoubleTapListener</code> and override its <code>onDoubleTap</code> method.</p> <p>Also you can use <code>SimpleOnGestureListener</code> and override only what you want.</p> <pre><code>final Context context = this; final GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { Toast.makeText(context, "onDoubleTap", Toast.LENGTH_SHORT).show(); return true; } @Override public void onLongPress(MotionEvent e) { Toast.makeText(context, "onLongPress", Toast.LENGTH_SHORT).show(); } }; final GestureDetector detector = new GestureDetector(listener); detector.setOnDoubleTapListener(listener); detector.setIsLongpressEnabled(true); getWindow().getDecorView().setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { return detector.onTouchEvent(event); } }); </code></pre> |
22,430,130 | 0 | C# Linq-XML find match and replace elements <p>I am writing a quick tool to convert from text to XML.</p> <p>I've created a Dictionary that contains the note number and the new name.</p> <p>I would like to search in the XML for the "INote" value (in the example is "118") and find the corresponding key in the Dictionary and replace the "Name" value (in the example is "Sound 119")</p> <p>The XML structure looks like this </p> <pre><code> <list name="Quantize" type="list"> <item> <int name="Grid" value="4"/> <int name="Type" value="0"/> <float name="Swing" value="0"/> <int name="Unquantized" value="0"/> <int name="Legato" value="50"/> </item> </list> <list name="Map" type="list"> <item> <int name="INote" value="118"/> <int name="ONote" value="118"/> <int name="Channel" value="9"/> <float name="Length" value="200"/> <int name="Mute" value="0"/> <int name="DisplayNote" value="118"/> <int name="HeadSymbol" value="0"/> <int name="Voice" value="0"/> <int name="PortIndex" value="0"/> <string name="Name" value="Sound 119" wide="true"/> <int name="QuantizeIndex" value="0"/> </item> <item> .... </item> </list> <list name="Order" type="int"> <item value="0"/> <item value="1"/> <item value="2"/> </list> </code></pre> <p>And this is my code so far: </p> <pre><code> XDocument outFile = XDocument.Load(outputFile); var currItem = from item in outFile.Descendants("item") select item; foreach (var i in currItem) // this loop is executed many times { var node = i.Element("int"); if (node ==null) continue; var name = node.Attribute("name").Value; var value = i.Element("int").Attribute("value").Value; if (name == "INote") { var str = i.Element("string").Attribute("name").Value; if (str == "Name") { var snd = i.Element("string").Attribute("value").Value; MessageBox.Show(string.Format("{0} - {1} - {2} - {3}", name, value,str,snd)); } } } </code></pre> <p>I have 2 problems : </p> <ul> <li><p>The query : is there a way to perform the checks directly in the query itself instead than in the foreach loop? (as additional info not all the elements contain the element with the "INote" attribute)</p></li> <li><p>The foreach loop : the entire loop is repeated more n time so I get the Messagebox from 0 to n multiple times.</p></li> </ul> <p>Any help would be appreciated.</p> <p><strong>ANSWER :</strong> Thanks everybody, I think I've fixed the problem after some tests :</p> <pre><code> XDocument outFile = XDocument.Load(outputFile); var NamesData = outFile.Root.Elements("list") .Where(x => x.Attribute("name").Value == "Map") .Elements("item") .Select(y => new KeyValuePair<XAttribute,XAttribute> ( y.Elements("int").Where(c => c.Attribute("name").Value == "INote").Select(c => c.Attribute("value")).FirstOrDefault(), y.Elements("string").Where(c => c.Attribute("name").Value == "Name").Select(c => c.Attribute("value")).FirstOrDefault() ) ); </code></pre> <p>I create a KeyValuePair of XAttributes so i can save them back easily :</p> <p>this is the rest of the method btw (Notedefinition it's just a data container)</p> <pre><code> foreach (var data in NamesData) { NoteDefinition newName; if (internalDictionary.TryGetValue(Convert.ToInt32(data.Key.Value), out newName)) { data.Value.SetValue(newName.voiceName); } } outFile.Save(outputFile); </code></pre> |
25,277,657 | 0 | <p>Look carefully at this line of code:</p> <pre><code>s.send("".join(["NICK",NICK,"\r\n"]).encode()) </code></pre> <p>If you replaced <code>s.send</code> with <code>print</code>, you’d realize it was sending strings like this:</p> <pre><code>NICKnick<CR><LF> </code></pre> <p>There’s no space! That makes it an invalid command, and makes registration fail. At some point, the server gives up on receiving a valid registration from you, and so sends you an error and closes the connection. So make sure you include a space:</p> <pre><code>s.send("".join(["NICK ",NICK,"\r\n"]).encode()) </code></pre> <p>At least then you’d be sending a valid registration.</p> |
16,378,594 | 0 | PHP-FPM - upstream prematurely closed connection while reading response header <p>Already saw this same question - <a href="http://stackoverflow.com/questions/14193954/upstream-prematurely-closed-connection-while-reading-response-header-from-upstre">upstream prematurely closed connection while reading response header from upstream, client</a> But as Jhilke Dai said it not solved at all and i agree. Got same exact error on nginx+phpFPM installation. Current software versions: nginx 1.2.8 php 5.4.13 (cli) on FreeBSd9.1. Actually bit isolated this error and sure it happened when trying to import large files, larger than 3 mbs to mysql via phpMyadmin. Also counted that backend closing connection when 30 secs limit reached. Nginx error log throwing this</p> <pre><code> [error] 49927#0: *196 upstream prematurely closed connection while reading response header from upstream, client: 7X.XX.X.6X, server: domain.com, request: "POST /php3/import.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock2:", host: "domain.com", referrer: "http://domain.com/phpmyadmin/db_import.php?db=testdb&server=1&token=9ee45779dd53c45b7300545dd3113fed" </code></pre> <p>My php.ini limits raised accordingly</p> <pre><code>upload_max_filesize = 200M default_socket_timeout = 60 max_execution_time = 600 max_input_time = 600 </code></pre> <p>my.cnf related limit</p> <pre><code>max_allowed_packet = 512M </code></pre> <p>Fastcgi limits</p> <pre><code>location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/tmp/php5-fpm.sock2; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_ignore_client_abort on; fastcgi_connect_timeout 60s; fastcgi_send_timeout 200s; fastcgi_read_timeout 200s; fastcgi_buffer_size 128k; fastcgi_buffers 8 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; </code></pre> <p>Tried to change fastcgi timeouts as well buffer sizes, that's not helped. php error log doesn't show problem, enabled all notices, warning - nothing useful. Also tried disable APC - no effect.</p> |
13,921,007 | 0 | <p>use this instead to get the result of your request:</p> <pre><code>SoapObject result = (SoapObject)envelope.bodyIn; Log.v("TEST","runs ok attributes "+result.getProperty(0).toString()); </code></pre> |
40,993,656 | 0 | How to relocation the back stack on android <p>I want to <strong>relocation</strong> the back-stack on android application.</p> <p>When I press back key, I want to push history to bottom in back-stack. But I can't found Intent Flag about this.</p> <p>I want to relocation back-stack on android.</p> <p><a href="https://i.stack.imgur.com/lvLOc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lvLOc.png" alt="enter image description here"></a></p> <p><a href="https://developer.android.com/guide/components/tasks-and-back-stack.html" rel="nofollow noreferrer">https://developer.android.com/guide/components/tasks-and-back-stack.html</a></p> <p>When I press Navigate back, I want to push Activity3 in bottom of back-stack. </p> <p>minimize icon (like a Youtube minimize video) <a href="https://i.stack.imgur.com/C0ZPX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C0ZPX.jpg" alt="enter image description here"></a></p> <p>right|bottom minimize video view</p> |
23,610,681 | 0 | <p>Here is one solution I propose which may not be the solution you may want but here it is. Since it's a table and everything comes one after other, what you can do is, through appropriate Jsoup selectors get the following data one after another.</p> <pre><code>Mo Do Mi Do Fr Sa 8:00 9:30 9:45 11:45 Sem Wz J0122 11:30 13:30 CAE Wz J0122 1) SEM Wz J0122 DVI Eer J0326 2) </code></pre> <p>...and so on...</p> <p>Now since you know there are only six working days in a week. You can create a HashMap of String and a LinkedList. String for days of the week and LinkedList for the content which goes in it. In the LinkedList you can first put time and check whether that time has any course following it, then repeat that for all the other timings.</p> <p>So you now have the data structure that all you need to do is call the day of the week (and the timing if necessary) and get the required course.</p> |
12,451,312 | 0 | <p>That's because <code>~/</code> is supported by the command shell, not the file system APIs.</p> |
8,703,786 | 0 | <p>I was having this same problem after installing SCSS. I fixed the problem by removing the defult comments that rails places in the header. So this:</p> <pre><code>/* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's generally better to create a new file per style scope. * *= require_self *= require_tree . */ #wrapper { width: 980px; margin: 0 auto; } </code></pre> <p>Became this:</p> <pre><code>#wrapper { width: 980px; margin: 0 auto; } </code></pre> |
6,989,024 | 0 | How can I write a request spec with Capybara/RSpec for testing Sunspot/Solr searching? <p>I'd like to write my usual RSpec/Capybara request specs to test search functionality using Sunspot and Solr. I've been digging around but can't find how to get this working. I have the sunspot_test gem installed and have verified that the Products created do exist. The issue seems to be with the indexing, maybe? What am I missing?</p> <pre><code>require 'spec_helper' describe "search" do context "when searching by name/description" do let!(:super_mario_bros_3) { Factory(:product, :name => 'Super Mario Bros. 3') } let!(:legend_of_zelda) { Factory(:product, :name => 'Legend of Zelda') } before { Product.reindex; Sunspot.commit } it "should only find games matching the search text", :js => true, :search => true do # search_for fills in and submits the search form search_for("Super") # This yields an empty array p Product.search { keyword "super" }.results # These fail page.should have_content super_mario_bros_3.name page.should have_no_content legend_of_zelda.name end end end </code></pre> |
18,703,847 | 0 | <p>A simple code:</p> <pre><code>$source = "JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ=="; $code = base64_decode($source); eval($code); </code></pre> <p>or even shorter:</p> <pre><code>eval(base64_decode("JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ==")); </code></pre> <p>Do you want to encrypt your code? If so, this is not the right way. Use a accelerator like <a href="http://eaccelerator.net/" rel="nofollow">this one</a> or <a href="http://www.php-accelerator.co.uk/" rel="nofollow">this one</a>. They will crypt your codes and make them even faster!</p> |
36,384,376 | 0 | Passing contents of file to extglob command terminal <p>I have a list of files that I don't want to remove from a location, I have found that by using extglob I am able to keep a pre-defined list of files using:</p> <pre><code>rm -r !(one.txt|Folder) </code></pre> <p>This will remove everything except <code>one.txt</code> and the folder <code>Folder</code>, however the list of files that I want to keep isn't always the same.</p> <p>Is there a way to pass a list of files/folders from a file e.g. <code>whitelist.txt</code> which won't be removed? </p> <p>I have managed to reformat <code>whitelist.txt</code> to have the contents:</p> <pre><code>one.txt|two.txt|Folder </code></pre> <p>However I am unsure of how to pass that into the command</p> <p>Just a note I am running OSX 10.11.</p> <p>Thanks,</p> |
21,357,346 | 0 | I´m using a modal to see my contact info in which there are 4 btn´s which doesn´t always work (Page=UNDEFINED). Can someone help me understand why? <pre><code><!--Kontakt modal--> <li><a data-toggle="modal" href="#myModal">Kontakta mig</a></li> <div id="myModal" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <!--Titeln i modal--> <h2 class="modal-title" id="myModalLabel">Kontakta mig</h2> </div> <div class="modal-body"> <a class="btn btn-default table-responsive glyphicon glyphicon-map-marker" href="https://maps.google.com/maps?q=Moldegatan+1C%2c+Bor%C3%A5s%2c+Sweden&hl=en&ie=UTF8&sll=38.882147%2c-76.99017&sspn=0.014866%2c0.027874&oq=Mo&hnear=Moldegatan+1C%2c+504+32+Bor%C3%A5s%2c+Sweden&t=m&z=16&source=gplus-ogsb" role="button">Moldegatan 1C 50432 BORÅS</a> <hr /> <a class="btn btn-default table-responsive glyphicon glyphicon-earphone" href="tel:+0735451624" role="button">Telefonnummer: 0735451624</a> <hr /> <a class="btn btn-default table-responsive glyphicon glyphicon-envelope" href="mailto:[email protected]" role="button">E-mail: [email protected]</a> <hr /> <div class="intent"> <img src="Content/Bilder/facebook.png" alt="Facebook" /> <a class="btn btn-default" href="http://facebook.com/carlos.clavijo.77" data-scheme="fb://profile/555447256">Facebook</a> </div> </div> <div class="modal-footer"> <div class="btn-group"> <button class="btn btn-danger" data-dismiss="modal">Stäng</button> </div> </div> </div> <!-- /modal-content --> </div> <!-- /modal-dialog --> </div> <!-- /myModal --> </code></pre> <p>// JavaScript. I´m using this so that when using a smartphone or tablet it will open up the aplication istead of the explorer. I´m kind of new to this so please bare with me. </p> <p>When using this function and press one of the buttons in the kontakt modal it works sometimes, but sometimes it shows up as page undefined. What am I missing?</p> <pre><code>(function() { // tries to execute the uri:scheme function goToUri(uri, href) { var start, end, elapsed; // start a timer start = new Date().getTime(); // attempt to redirect to the uri:scheme // it'll stutter for a split second, causing the timer to be off document.location = uri; // end timer end = new Date().getTime(); elapsed = (end - start); // if there's no elapsed time, then the scheme didn't fire, and we head to the url. if (elapsed < 1) { document.location = href; } } $('a.btn-default').on('click', function(event) { goToUri($(this).data('scheme'), $(this).attr('href')); event.preventDefault(); }); })(); </code></pre> |
5,853,378 | 0 | need to help to convert <p>Hi need help to convert this C++ code to C#</p> <pre><code>sprintf((char *)(dataBuffer), "Failed statistics read, device %s", device); </code></pre> <p>The dataBuffer is byte[]</p> <p>I wrote this, but with error converting string to byte[]</p> <pre><code> dataBuffer = string.Format("Failed statistics read, device {0}", device); </code></pre> |
36,172,451 | 0 | <p>1) it has no sense with OR 2) for AND use , instead</p> <pre><code>if let u = custom["u"] as? String, let url = custom["URL"] as? String { // Do something here } </code></pre> |
25,680,571 | 0 | <p>Create a getter method in counter class. Then call that method in register class when you need number of students.</p> |
29,853,477 | 0 | <pre><code>'Create a function Function ASPPostJSON(url) 'declare a variable Dim objXmlHttp Set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP") 'If the API needs userName and Password authentication then pass the values here objXmlHttp.Open "POST", url, False, "User123", "pass123" objXmlHttp.SetRequestHeader "Content-Type", "application/json" objXmlHttp.SetRequestHeader "User-Agent", "ASP/3.0" 'send the json string to the API server objXmlHttp.Send "{""TestId"": 012345,""Test1Id"": 123456,""Test123"": 37,""Type123"": ""Test_String"",""contact"": {""name"": ""FirstName LastName"",""Organization"": ""XYZ"",""phone"":""123456"",""emailAddress"": ""[email protected]""}}" 'If objXmlHttp.Status = 200 Then ASPPostJSON = CStr(objXmlHttp.ResponseText) 'end if 'return the response from the API server Response.write(ASPPostJSON) Set objXmlHttp = Nothing End Function 'call the function and pass the API URL call ASPPostJSON("https://TheAPIUrl.com/") </code></pre> |
6,619,701 | 0 | <pre><code>RewriteEngine on RewriteRule ^(\w+)$ /view.php?somevar=$1 [L] </code></pre> <p>You have to set NAME as the value of some variable.</p> <p>This example allows NAME to be any word.. if you want something specific... just replace \w+ with whatever specific thing you want.</p> |
20,959,727 | 0 | <p>you could create a class that initializes other classes and then calls the real main method, e.g:</p> <pre><code>public static void main(String[] args) throws Exception { Class<?> mainClass = Class.forName(System.getProperty("mainClass")); for (String className : System.getProperty("initClasses").split(";")) { Class.forName(className); } Method main = mainClass.getMethod("main", String[].class); main.invoke(null, new Object[] { args }); } </code></pre> <p>Then you would start the application with that class as the main class and specify the real main class and the classes to be initialized via properties.</p> |
25,710,837 | 0 | How to write an HTML button which can run both onclick and onserverclick? <p>I have a HTML button which is connected to some external JS and on its onclick events my JavaScript functions would run. The functions consist of some alerts. Now I would like to write my main code which is in C# language but as soon as I write onserverclick event in my button, my onclick events don't work anymore. </p> <p>My button code is:</p> <pre><code><input runat="server" type="button" id="btn_submit" class="btn_submit" value ="ثبت" onclick="mail_valid()" onserverclick="BtnRegister_Click"/> </code></pre> <p>How can I make both the "onclick" and "onserverclick" event handlers work?</p> <p>Edit: I want to avoid from postback in the button thats why i used html button . </p> |
12,635,935 | 0 | last code changes not present in application server <p><br> Under Eclipse (with Maven and GWT), i have 4 projects. <br> <br> I made modifications in my Java code source. To put my modifications in the application server (a Jonas server), <br> i made a clean / build automatically of all projects, <br> then a GWT compile of the project who contains the entry point. <br> and finally an export WAR of this project who contains the entry point. <br> When i put this WAR on the application server (Jonas), and stop and restart of the server, <br> <b> my last changes are not present in the server !!! </b> <br> <br> However, when i run my GWT application in local (localhost:8080), my last changes are present. <br> <br> <b> Do you have met such a situation ? What can explain it ? </b> <br> Thanks</p> |
24,252,801 | 0 | <p>To iterate through ENABLE once you have it you should use a simple while loop:</p> <pre><code>while(<ENABLE>){ chomp; //each line read from ENABLE will be stored in $_ per loop } </code></pre> <p>This way you do not need a for loop to iterate. So in essence you would run the "server hostname" command in this while loop:</p> <pre><code>... while(<ENABLE>) { chomp; $ssh->exec("server $_"); } ... </code></pre> <p><a href="http://perl.about.com/od/perltutorials/a/readwritefiles.htm" rel="nofollow" title="Here">Check here</a> for details.</p> |
11,975,159 | 0 | Command Line Tool to Disable PDF Printing <p>Does anyone know of a "FREE" command line tool that can lock a pdf from a user being able to print it. I need to be able to put this in a batch to loop through a folder and disable printing from adobe standard and reader. Is this possible to do it from command line with any tool? </p> |
38,598,518 | 0 | Word extraction multiline text file <blockquote> <p>Here I have created a code to: Extract indivisual words from a text file, Append only the words with no duplicates into a blank list and Sort them by alphabetical order.</p> </blockquote> <pre><code>fname = raw_input("Enter file name: ") fhandle = open(fname) wordlist = list() counter = 0 for line in fhandle: line = line.split() length = len(line) if line not in wordlist: wordlist.append(line[counter]) counter += 1 if counter == length: break print wordlist.sort() </code></pre> <blockquote> <p>Checking this in Pycharm still gives result 'None' although looking at live execution shows the words sorted in alphabetically ordered list but with duplicated words intact (see figures). I would love to decipher difference between append from file <a href="http://imgur.com/a/Zapbp" rel="nofollow">1</a> and from a variable <a href="http://imgur.com/fpB4DTe" rel="nofollow">2</a>.</p> </blockquote> |
33,804,930 | 0 | <p>I am very late for this question, but anyway... My guess is that you <em>want</em> to use the Application Factory pattern and use the Flask-Admin. There is a <a href="https://github.com/flask-admin/flask-admin/issues/910" rel="nofollow">nice discussion</a> about the underlying problems. I used a very ugly solution, instantiating the Flask-Admin in the <strong>init</strong>.py file:</p> <pre><code>from flask_admin.contrib.sqla import ModelView class UserModelView(ModelView): create_modal = True edit_modal = True can_export = True def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) db.init_app(app) # import models here because otherwise it will throw errors from models import User, Sector, Article admin.init_app(app) admin.add_view(UserModelView(User, db.session)) # attach blueprints from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') return app </code></pre> |
32,039,532 | 0 | <p>The correct MySQL syntax is:</p> <pre><code>UPDATE allranks ar INNER JOIN therankings r on ar.`Player Name` = r.`Player Name` SET ar.Ranktwo = r.Rank; </code></pre> <p>Notice how the table aliases make the query easier to write and to read.</p> |
24,304,803 | 0 | Gaussian Process, negative hyper-parameters? <p>I'm doing Gaussian Processes for Regression using GPML toolbox. However, after optimization using 'minimize.m' (without mean functions), I get some negative hyper-parameters! </p> <p>The initial hyper-parameters are: </p> <p><code>hyp.cov = [0; 0]; % two hyper-parameters in covariance kernel (length-scale & amplitute) hyp.lik = log(0.1); %hyper-parameters of noise</code></p> <p>The original training data:</p> <pre><code>x=[819 1119 1419 1599 1719 1839 1899 2019 2079 2139]; %coordinates y=[105.00 114.33 126.33 130.33 116.33 103.00 103.00 124.67 122.67 109.00]; %training data </code></pre> <p>In my codes, y are <strong>NORMALIZED</strong> to have zero mean and unit variance. Then optimize:</p> <pre><code>hyp = minimize(hyp, @gp, -100, @infExact, [], {@covSEiso}, likfunc, x,y); </code></pre> <p>After about 100 iterations, I get some negative hyper-parameters!!! It is quite confusing....</p> <p>However, if I don't normalize y, all hyper-parameters will be positive after optimization.</p> <p>Could anyone tell me what does Negative Hyper-parameters mean? Should I normalize the data?</p> |
19,505,287 | 0 | <pre><code> var jamie = someVarThatCanBeUndefined || 'or maybe not'; </code></pre> <p>You can use the above to do coalescing</p> <p>Here is an answer with more details <a href="http://stackoverflow.com/questions/476436/null-coalescing-operator-for-javascript/476438#476438">Is there a "null coalescing" operator in JavaScript?</a></p> <p>If you wanted short hand notation for <code>if</code></p> <p>Try this instead:</p> <pre><code>boolCondition ? "OneStringForTrue" : "AnotherForFalse" </code></pre> <p>This is often called the </p> <pre><code>Conditional (Ternary) Operator (?:) (JavaScript) </code></pre> |
17,891,153 | 0 | <p><sub>(Edited to correct my initial misreading of the question.)</sub></p> <p>There's no need to override <code>parse</code> method of the model unless you want to change its structure. But it sounds like you don't need to -- to render the author name, just use <code>author.name</code> in the view:</p> <pre><code><%= author.name %> </code></pre> <p>As far as initializing the nested collection, your approach is exactly right. All you have to do is convert the JSON object to Backbone models, and pass them to the <code>PostsCollection</code> (the <code>Backbone.Collection</code> constructor accepts an array of Backbone models, <em>not</em> raw JSON). One way of doing this is to use <code>map</code>:</p> <pre><code>var postModels = json.posts.map(function(post) { return new Posts(post); }); var posts = new PostsCollection(postModels); </code></pre> <p>Note that you'll need to do something similar in the <code>initialize</code> method of the <code>Posts</code> model -- retrieve the comments JSON array, and convert it to an array of <code>Comments</code> models:</p> <pre><code>initialize: function() { if (attributes.comments && attributes.comments.length > 0) { var commentModels = attributes.comments.map(function(comment) { return new Comments(comment); }); this.set("comments", new CommentsCollection(commentModels)); } } </code></pre> <p><a href="http://jsfiddle.net/tQw2n/5/" rel="nofollow">Here is working example.</a></p> |
29,776,864 | 0 | <p>The RegEx is working as written: </p> <pre><code>/^[^t]{2,2}st$/ </code></pre> <ul> <li>^ assert position at start of the string</li> <li>[^t]{2,2} match a single character not present in the list below Quantifier: {2,2} Exactly 2 times</li> <li>t the literal character t (case sensitive)</li> <li>st matches the characters st literally (case sensitive)</li> <li>$ assert position at end of the string</li> </ul> <p>You also don't need to do {2,2} as that is a range, you can do {2} for exactly 2 matches, or {1,2} for 1 upto 2 matches.</p> <p><a href="https://regex101.com/r/zB1sB3/1" rel="nofollow">REGEX101</a></p> <p>This example should serve as a good illustration of what is occurring within that RegEx.</p> <p><strong>If you are looking for a solution to:</strong> Match any word that does not start with tt (case sensitive) you can use the following:</p> <pre><code>/^(?!tt)\w+$/ </code></pre> <p><a href="https://regex101.com/r/zB1sB3/2" rel="nofollow">PROOF</a></p> <p>Hope this helps.</p> |
23,046,486 | 0 | Auto height a div between two other divs <p>I am going to make a sidebar like Google+ or Facebook sidebar.</p> <p>sidebar is <code>position:fixed; left:0; top:0; bottom:0; width: 250px</code> and has:</p> <p>A header with 50px height<br> A footer with 50px height.<br> A content with dynamic height based on browser height.</p> <p><img src="https://i.stack.imgur.com/C7UTc.jpg" alt="enter image description here"></p> <p>any help?</p> |
31,605,285 | 0 | SQL queries in MySQL using phpseclib <p>I am trying to connect to MySQL database on a remote server and I could successfully connect to the server and login to the MySQL database. But now i need to run few SQL queries on the database tables but facing the error : ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).</p> <p>I am not sure if the SQL queries are of correct syntax? Also do i need to connect to the server every time i need to run SQL queries? Please provide me with some inputs. Thanks.</p> <pre><code> /* SUCCESS */ $ssh = new Net_SSH2('XX.XXX.XX.XXX'); if (!$ssh->login('root', 'password')) { exit('Login Failed'); } echo $ssh->exec('pwd'); /* SUCCESS */ if (!$ssh->exec('mysql -h localhost -u root -pDataBaseName \r\n')){ exit('Login to MySQL Failed'); }else{ echo "Login to MySQL Success"; } /* ERROR - facing error in this code*/ echo $ssh->exec('mysql -h localhost -u root -pDataBaseName -e "SELECT * FROM cmu_util_all"'); </code></pre> |
10,987,821 | 0 | Two columns equal height only css (no display: table, table-row, table-cell) <p>In CSS, I can do something like this: <img src="http://s1.ipicture.ru/uploads/20120612/Uk1Z8iZ1.png" alt="http://s1.ipicture.ru/uploads/20120612/Uk1Z8iZ1.png"></p> <p>But I've no idea how to change that to something like: <img src="http://s2.ipicture.ru/uploads/20120612/eI5sNTeu.png" alt="http://s2.ipicture.ru/uploads/20120612/eI5sNTeu.png"></p> <p><em><strong>The height is not fixed</em></strong></p> <p><strong>Please help me do it! Thank you all in advance!</strong></p> |
955,823 | 0 | <p>Using a state pattern is an approach you can take for this, but honestly what your describing is part of what the MVC framework was designed to accomplish.</p> <p>Edit:<br> MVP/MVC</p> <p>Since the MVC Framework isn't an option then I would take a look at Model View Presenter pattern (MVP) with either the passive view approach or superviser approach as described here: <a href="http://www.martinfowler.com/eaaDev/SupervisingPresenter.html" rel="nofollow noreferrer">http://www.martinfowler.com/eaaDev/SupervisingPresenter.html</a></p> <p>We found that the passive view approach worked with a little adaptation for our legacy code to work out good for us.</p> <p>Edit: Patterns:</p> <p>In that case then which pattern you choose really depends upon what the business needs are. </p> <p>State pattern:</p> <p>State pattern is typically used for when you need to change the behavior of an object based upon its current state or the state of a relation to the object. A common usage of this pattern is with games when the behavior of the object depends upon which mouse cursor button is pressed.</p> <p><a href="http://en.wikipedia.org/wiki/State_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/State_pattern</a></p> <p>Strategy pattern:</p> <p>This pattern is good for when you need different implementation based upon a configuration. For example say you are defining an email system and you need to have a different implimentation based upon which email provider is being used to send the email. </p> <p><a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Strategy_pattern</a></p> <p>So State pattern could definetly be the right direction it just comes down to what the objective is and what behavior's your trying to meet.</p> <p>What you'll often find with patterns is that they work well with eachother and you'll use multiple patterns in conjuction with eachother.</p> |
20,766,271 | 0 | <p>The code below shows a simple way of doing it by overloading the <code>paintEvent</code> method of the view. Painting of the text should probably use the style mechanism to obtain the font and pen/brush, but I'll leave that up for grabs by a keen editor.</p> <p>It uses Qt 5 and its C++11 features, doing it the Qt 4 or pre-C++11 way would require a QObject-deriving class with a slot to connect to the spin box's <code>valueChanged</code> signal. The implementation of <code>ListView</code> doesn't need to change between Qt 4 and Qt 5.</p> <p><img src="https://i.stack.imgur.com/OU1iW.png" alt="screenshot"></p> <pre class="lang-cpp prettyprint-override"><code>#include <QtWidgets> class ListView : public QListView { void paintEvent(QPaintEvent *e) { QListView::paintEvent(e); if (model() && model()->rowCount(rootIndex()) > 0) return; // The view is empty. QPainter p(this->viewport()); p.drawText(rect(), Qt::AlignCenter, "No Items"); } public: ListView(QWidget* parent = 0) : QListView(parent) {} }; int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget window; QFormLayout layout(&window); ListView view; QSpinBox spin; QStringListModel model; layout.addRow(&view); layout.addRow("Item Count", &spin); QObject::connect(&spin, (void (QSpinBox::*)(int))&QSpinBox::valueChanged, [&](int value){ QStringList list; for (int i = 0; i < value; ++i) list << QString("Item %1").arg(i); model.setStringList(list); }); view.setModel(&model); window.show(); return a.exec(); } </code></pre> |
14,733,074 | 0 | <pre><code>preg_match(";from"><span class="profile fn>(.?)</span></div>;", $text, $match) </code></pre> <p>... should trigger this:</p> <blockquote> <p>Parse error: syntax error, unexpected '<'</p> </blockquote> <p>Apart from that:</p> <ul> <li><p>You seek for an unclosed attribute that's not in the original text:</p> <p><code>class="profile fn</code> vs <code>class="profile fn"</code></p></li> <li><p>You seek for zero or one characters:</p> <p><code>.?</code></p></li> </ul> <p>Fixed regexp would be:</p> <pre><code>$text = '<div class="from"><span class="profile fn">firstnamed familyname</span></div>'; preg_match(';from"><span class="profile fn">(.*)</span></div>;', $text, $match); var_dump($match); </code></pre> <p>Of course, this will probably break on large HTML documents (as soon as there's another <code></span></div></code> bit later on). Regular expressions are impossible to get right when used for parsing HTML.</p> |
10,889,536 | 0 | <p>In <code>cBase</code> you should use <code>@Override</code> with the <code>onCreate(Bundle savedInstanceState)</code> method and it MUST also call through to <code>super.onCreate(Bundle savedInstanceState)</code></p> |
22,812,808 | 0 | maxima and converting output of variable to float <p>I can get maxima to solve an equation but can't figure out why it won't show it's numerical value without typing the extra command/step of <strong>float(%)</strong>. Is there away to automatically convert a solved variable to a numerical format.</p> <p>Example of equation below:</p> <pre><code>kill(all); alpha:float(.0014931); endfreq:50; dursec:1200; solve(alpha=log(startfreq/endfreq)/dursec,float(startfreq)); </code></pre> <p>what comes back is <strong>startfreq=50%e(44793/25000)</strong></p> <p>I would like it to say <strong>299.988</strong> instead </p> |
12,110,407 | 0 | <p><strong>Solution 1 :</strong> One solution that worked for me when this error "<strong>The declared package does not match the expected package</strong>" occured for a project I checked-out from eclipse CVS :</p> <p>1.Right click the project in the navigation bar and click 'delete'<br> 2.Make sure '<strong>Delete project contents on disk</strong>' option is <strong>NOT</strong> checked, and click OK.<br> 3.Now after the project is deleted, go to <strong>File -> Import -> General -> Existing Projects into Workspace</strong><br> 4.Select your workspace from the directory listing and check the box next to your project name. Click '<strong>Finish</strong>' </p> <p><strong>Solution 2 :</strong> Once again I got this error with the following message </p> <p><em>Eclipse build errors - java.lang.Object cannot be resolved</em> I had to follow another route mention here and the error went away.</p> <p>In the mean time, the work around is to remove the JRE System Library from the project and then add it back again. Here are the steps:</p> <ol> <li>Go to properties of project with the build error (right click > Properties) View the "Libraries" tab in the "Build Path" section Find the "JRE System Library" in the list (if this is missing then this error message is not an eclipse bug but a mis-configured project) </li> <li>Remove the "JRE System Library"</li> <li>Hit "Add Library ...", Select "JRE System Library" and add the appropriate JRE for the project (eg. 'Workspace default JRE')</li> <li>Hit "Finish" in the library selection and "OK" in the project properties and then wait for the re-build of the project</li> </ol> <p>Hopefully the error will be resolved ...</p> |
2,282,264 | 0 | In Google App Engine, how do I use reference properties between two entities that reference each other? <p>If I have two types of models that each reference each other, whichever one I try to define first says it does not recognize the referenced other type (because it is defined further down in the file). For example:</p> <pre><code>class Author(db.Model): most_recent_book = db.ReferenceProperty(Book) class Book(db.Model): author = db.ReferenceProperty(Author) </code></pre> <p>This will claim that the referenced "Book" model is not recognized. If I flip the order, I run into the same issue (except it will say that "Author" is not recognized). How do I get around this? </p> |
7,306,049 | 0 | <p>You don't have to use the <code>operator()()</code> if you provide a method on the object to be executed (in this case <code>updateEpsilons</code>). Obviously this <code>operator()()</code> is not correct because it does not call the appropriate <code>updateEpsilons</code> method with a parameter.</p> <p>Note that in the tutorial, the new thread is created giving just an instance of a class, and no method. In this case, the class has to implement the <code>operator()()</code>, which is what will be called for the code of the thread.</p> |
13,292,336 | 0 | Can i get an automatic email every time someone logs in to password protected directory? <p>I have a VPS server with WHM and cpanel. We have a few password protected directories(defined in cpanel). We wish that whenever a user logs in to one of them, we will get an instant email. Possible? Thanks</p> |
37,553,649 | 0 | git stash pop prints "deleted by us" for file that was never created on master <p>I am relatively new to git (coming from svn).</p> <p>I perform the following steps which are mainly that I edit a file on a branch, perform a stash and then try to apply the stash to the master (which does not have this file).:</p> <pre><code>user1:~/gittest$ ls user1:~/gittest$ git init Initialized empty Git repository in /home/user1/gittest/.git/ user1:~/gittest$ touch file1 user1:~/gittest$ git add file1 user1:~/gittest$ git commit -m "committing file1" [master (root-commit) 7c29335] committing file1 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 file1 user1:~/gittest$ git checkout -b br1 Switched to a new branch 'br1' user1:~/gittest$ touch file2 user1:~/gittest$ git add file2 user1:~/gittest$ git commit -m "committing file2" [br1 b565401] committing file2 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 file2 user1:~/gittest$ echo "updated.." >> file2 user1:~/gittest$ git add file2 user1:~/gittest$ git stash Saved working directory and index state WIP on br1: b565401 committing file2 HEAD is now at b565401 committing file2 user1:~/gittest$ git checkout master Switched to branch 'master' user1:~/gittest$ git stash pop CONFLICT (modify/delete): file2 deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of file2 left in tree. user1:~/gittest$ git status On branch master Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add/rm <file>..." as appropriate to mark resolution) deleted by us: file2 no changes added to commit (use "git add" and/or "git commit -a") </code></pre> <p>My question is why does git print the message "deleted by us" since file2 was never created on master and thus never deleted.</p> <p>Is this a misleading message, or am I missing something about the way git works.</p> |
22,455,309 | 1 | How can I directly open a custom file with python on a double click? <p>I am programming on a windows machine and I have an app that reads file selected by the user. Is it possible to allow them to open the file directly when they double click. This needs to work when the program is "compiled" as an .exe with cxfreeze.</p> <p>What I am really asking is this: Is there a way to allow the user to double click on a custom file (.lpd) and when they do windows starts the program (a compiled cxfreeze .exe) and passes it the file path as an argument.</p> |
7,409,535 | 0 | <p><a href="http://jsoup.org/" rel="nofollow">Jsoup</a> could help to remove all anchor tags with name starting with "OLE".</p> <pre><code>Elements anchors = doc.select("a[name^=OLE]"); for (Iterator it = anchors.iterator(); it.hasNext(); ) { Element anchor = it.next(); String text = anchor.text(); Element header = anchor.parent(); header.text(text); } </code></pre> |
23,957,246 | 0 | Apache derby plugin for eclipse <p>After installing the <a href="http://archive.apache.org/dist/db/derby/db-derby-10.3.1.4/" rel="nofollow noreferrer">JavaDB plugin</a> for eclipse version 4.3.2, I unzipped the core and ui folders and put their contents under eclipse/plugin directroy.</p> <p>unfortunately, clicking on a project, and adding apache derby nature lead for nothing! No packages is added to the project, and no control panel is available for the apache derby! I can repeat the process 10s times and nothing happened.</p> <p>I'm new with the environment, help me out!</p> <p>Ps; you should be able to see packages added to eclipse java ee kepler.</p> <p><img src="https://i.stack.imgur.com/6aAOL.png" alt="enter image description here"></p> |
40,737,930 | 0 | Using PHP inside of HTML to redirect to a random site <p>I need to be able to have the user click a button, and be redirected to a random page.</p> <p>I tried putting the PHP inside of JavaScript, and that inside of HTML, like this:</p> <pre><code><script> <button onclick="var jsVar = "<?php $urls = array("www.site1.com", "www.site2.com", "www.site3.com","www.site4.com"); $url = $urls[array_rand($urls)]; header("Location: http://$url"); ?>"">Click</button> </script> </code></pre> <p>I know this may have many errors, and help is very appreciated. Thank you!</p> |
19,077,661 | 0 | <p>CMake guys are working on it: <a href="http://www.cmake.org/Bug/print_bug_page.php?bug_id=13511" rel="nofollow">Bug report at cmake.org</a></p> |
7,143,488 | 0 | <p>I propose that you generate Image for your need, just by running this code and delete it after you generate the image:</p> <pre><code>- (void)viewDidLoad { ... someButton = [UIButton buttonWithType:101]; UIBarButtonItem *someBarButton = [[UIBarButtonItem alloc] initWithCustomView:someButton]; self.navigationItem.leftBarButtonItem = someBarButton; ... } </code></pre> <p>and </p> <pre><code>- (void)viewWillAppear:(BOOL)animated { .... UIImage *img1 = [someButton backgroundImageForState:UIControlStateNormal]; NSData *newData = UIImagePNGRepresentation(img1); NSFileManager *fileManager =[NSFileManager defaultManager]; BOOL filecreationSuccess = [fileManager createFileAtPath:@"/Users/macbookmac/Desktop/tester.png" contents:newData attributes:nil]; ... } </code></pre> |
2,638,603 | 0 | <p>$(document).ready() fires once the DOM is completely loaded and ready for manipulation. This prevents your code from firing before the objects that it'll act against exist. $(document).ready() is the most verbose version of it, and can be replaced up with any of these statements...</p> <pre><code>$(document).ready(handler) $().ready(handler) (this is not recommended) $(handler) $(document).bind("ready", handler) </code></pre> <p>See <a href="http://api.jquery.com/ready/" rel="nofollow noreferrer">here</a> for the documentation. </p> |
178,005 | 0 | Simulating <%#Bind(...) %> <p>ASP.Net:</p> <p>In code-behind I can simulate <code><%# Eval("Property")%></code> with a call to <code>DataBinder.Eval(myObject,"Property");</code></p> <p>How do I simulate a call to <code><%# Bind("Property")%></code> ?</p> <p>many thanks</p> |
5,519,132 | 0 | Add padding to the contents of a textfield <p>I have a textinput component on my stage with an instance name of "myTxt"</p> <p>I would like to add some left padding to the contents of this textfield. I've tried:</p> <pre><code>myTxt.setStyle("textPadding", 5); </code></pre> <p>But it adds top (and I assume bottom and right) padding in addition to the left padding. What is the best way to simply add left padding to the textfield's contents?</p> <p>Thanks for your help!</p> |
36,192,700 | 0 | <p>I got the solution. The reason why <code>y</code> didn't increase was because the value of <code>x</code> didn't get reset from <code>1000</code>. It just automatically skipped that chunk of code because the value of <code>x</code> was already 1000. This is my improved code which also sorts the array in order. </p> <pre class="lang-py prettyprint-override"><code>def Problem4(): y = 100 a = [] x1 = [] y1 = [] while y < 1000: y = y + 1 x = 100 while x < 1000: z = x*y if str(z) == str(z)[::-1]: a.append(z) x = x + 1 a.sort() print(a) Problem4() </code></pre> |
32,852,767 | 0 | <ol> <li>The m. or t. are aliases for tables within your query (so you are probably using tables that begin with the letter m and t). The alias is specified after the table name in the FROM part of your query.</li> <li>The syntax looks off for your JOIN. The query should probably look more similar to this:</li> </ol> <blockquote> <p>SELECT DISTINCT t1.email, t1.status_type, t2.status_value_text<br> FROM [Table 1] t1 JOIN [Table 2] t2 ON t1.email = t2.email</p> </blockquote> <p>Check out this link to see more examples.<a href="http://www.w3schools.com/sql/sql_join.asp" rel="nofollow">http://www.w3schools.com/sql/sql_join.asp</a></p> |
21,515,056 | 0 | <p>I suggest that you give your bottom colorful panels a <code>preferredDimension</code> based on the screen resolution, the font size, etc. That way, it <em>may</em> stay the way you want it to stay. </p> <p>Also, try setting the <code>Insets</code> for these components, see if that helps.</p> |
10,981,830 | 0 | <p>Inheritance is not the answer to everything, and here is is <em>not</em> the answer at all. Inheritance should model "is-a", and by no stretch of the imagination is an <code>Account</code> a <code>UseAccount</code>.</p> <p>Instead, just change the signature of <code>display()</code> to take a <code>JTextArea</code> as an argument; then in the <code>display()</code> code you'll have a <code>JTextArea</code> to work with. When you call <code>display()</code>, pass the <code>JTextArea</code> in.</p> <p>In other words:</p> <pre><code>void display(JTextArea ta) { ta.append(name); ... </code></pre> <p>and then</p> <pre><code>// "frame" is the UseAccount object that contains the JTextArea variable `output` myAccount.display(frame.output); </code></pre> <p>Most of the time, the right question is not "How can X get access to part of Y", but rather "How can Y give access to part of itself to X?"</p> <p>One final note: small effort put into naming variables well really pays off. </p> |
38,350,549 | 0 | <p>"Error : The uploaded file exceeds the upload_max_filesize directive in php.ini." Solved by uploading my theme manually. I was also facing the same problem while uploading wordpress theme, My theme is of 3.2MB in size. I searched for following line in wp-config.php file,</p> <p>// this will change your max file size upload AND your php memory define( 'WP_MEMORY_LIMIT', '64M' );</p> <p>But it was not found. so I tried another approach, I Log into cpanel went into the directory where wordpress is install then /wp-content/themes, choose upload option and upload my theme and it get installed. :D</p> |
27,024,886 | 0 | <p>As I mentioned in my comment, you only need one loop to solve this problem:</p> <pre><code>public static boolean isStringArraySorted(String[] strs, int n) { for (int i = 0; i < strs.length - 1; i++) { String first = substring(strs[i], n); String second = substring(strs[i + 1], n); if (first.compareToIgnoreCase(second) > 0) { return false; } } return true; } private static String substring(String s, int n) { return s.substring(0, n > s.length() ? s.length() - 1 : n); } </code></pre> |
25,475,181 | 0 | Stop R estimation after given time <p>I would like to constrain the time of estimation to be performed in R. For example, I would like to stop running estimation of a GARCH model (by function <code>ugarchfit</code> from package <code>rugarch</code>) after 10 seconds if it has not finished by that time. This is just one example, and I would be interested in a general way to instruct R to stop whatever function which has been running as long as a chosen time limit. Thank you!</p> |
29,672,489 | 0 | <p>The easiest way to do it directly in the list is</p> <pre><code>HashSet<Object> seen=new HashSet<>(); employee.removeIf(e->!seen.add(e.getID())); </code></pre> <ul> <li><code>removeIf</code> will remove an element if it meets the specified criteria</li> <li><code>Set.add</code> will return <code>false</code> if it did not modify the <code>Set</code>, i.e. already contains the value</li> <li>combining these two, it will remove all elements (employees) whose id has been encountered before</li> </ul> <p>Of course, it only works if the list supports removal of elements.</p> |
29,462,881 | 0 | <p>There are a few things involved here that it's useful to know.</p> <p>First, <code>.select2("val", xyz)</code> <a href="https://github.com/select2/select2/blob/c24293f2ba3d1de3b2dd1421177d3d91b05be887/src/js/select2/core.js#L462-L470" rel="nofollow">is equivalent to</a> <code>.val(xyz).trigger("change")</code>. The reason why a <code>change</code> event is triggered is for two reasons</p> <ul> <li>Older versions of Select2 used to trigger the <code>change</code> event, so we gave an easy-upgrade path.</li> <li>Other components on the page should be listening to the <code>change</code> event to know when the value of the <code><select></code> changes, so it makes sense to trigger it.</li> </ul> <p>Second, Select2 can only know if the underlying value of the <code><select></code> changes if you trigger the <code>change</code> event.</p> <p>So when you combine these two issues together, it starts to explain why Select2 doesn't act as you would expect when you set the new value within a <code>change</code> event.</p> <hr> <p>You can get around the cyclic <code>change</code> events by using the <code>select2:select</code> event to determine when a new selection is made, instead of the <code>change</code> event.</p> <p><a href="https://jsfiddle.net/nmeoosLk/8/" rel="nofollow">https://jsfiddle.net/nmeoosLk/8/</a></p> <p>This is locking you into using Select2-specific events, but it's your best alternative if you don't want to always check if the value changed. I personally would recommend not triggering the <code>change</code> event if the value didn't change, as the small amount of code will better help other components understand what is happening on the page.</p> |
18,727,655 | 0 | Add an object to a java structure only if it isn't already there <p>I have an arrayList that I want to add to, as long as the value isn't already stored in it. For example if my array is like this: </p> <pre><code>H LK KL LS </code></pre> <p>And I have the value LS, it wouldn't be added. But if the value was A, it would be. I don't care about order or sorting. Just whether or not the information is in there.</p> <p>I was thinking that the code should look something like this:</p> <pre><code>value = A; no = 0; for (int o; arraylist.length; o++) if (arraylist.get(o).equals(value)){ continue; }else{ no++; } } if (arraylist.length = no){ arraylist.add(value); } </code></pre> <p>But there has to be an easier way to do it. Does anyone know a more concise way to do this?</p> |
39,704,721 | 0 | <p>Rather than attempting parse every line from the url and put it into specific rows for a csv file, you can just push it all into a text file to clean up the formating, and then read back from it, it may seem like a bit more works but this is generally my approach to comma delimited information from a URL. </p> <pre><code>import requests URL = "http://www.cftc.gov/dea/newcot/FinFutWk.txt" r = requests.get(URL,stream=True) with open('file.txt','w') as W: W.write(r.text) with open('file.txt', 'r') as f: lines = f.readlines() for line in lines: print(line.split(',')) </code></pre> <p>You can take what is in that forloop, and swap it around to actually saving the lists into a array of lists so you can use rather than print them.</p> <pre><code>content = [] for line in lines: content.append(line.split(',')) </code></pre> <p>Also note that upon splitting, you will still notice that there is content that has quite a large amount of white space after it, you could run through the entire list, for each list in the array, and remove all white space but that would ruin the first element in the list, or just convert the numeric values which have the white space into actual integers as they were read in as strings. That would be your preference. If you have any questions feel free to add a comment below.</p> <p>EDIT 1: On a side note, if you do not wish to keep the file that was saved with the content, import the os library and then after you read the lines into the lines array, remove the file.</p> <pre><code>import os os.remove('file.txt') </code></pre> |
19,661,501 | 0 | Regular expression that matches positive double number with/without parentheses <p>I'm trying to find out the regular expression that could match any double number between parentheses or without them. These would two examples of numbers that should match:</p> <pre><code>(0.5) </code></pre> <p>Or, </p> <pre><code>0.5 </code></pre> |
18,080,612 | 0 | Swing application won't display in unity when second monitor is on the left <p>I am developing an application in Swing. When I have two monitors connected, the application will not display. The icon appears in the unity side bar but the window is nowhere to be seen.</p> <p>I went back to basics and ran HelloWorldSwing.java from the Oracle tuorials</p> <p><a href="http://docs.oracle.com/javase/tutorial/uiswing/examples/start/HelloWorldSwingProject/src/start/HelloWorldSwing.java" rel="nofollow">http://docs.oracle.com/javase/tutorial/uiswing/examples/start/HelloWorldSwingProject/src/start/HelloWorldSwing.java</a></p> <p>and the same problem exists. Then I find that if I put Monitor 1 on the left, HelloWorld appears in the top left hand corner.</p> <p>How can I get HelloWorldSwing (and Swing apps in general) to display in Unity when the main monitor is on the right?</p> <p>My display configuration: Monitor 1 (Laptop Screen) 1280x800 Monitor 2 ("unknown") 1440x900</p> <p>Monitor 2 is on the left. I have the following in my ~/.xprofile:</p> <pre><code>xrandr --newmode "1680x1050" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync xrandr --addmode VGA1 1680x1050 xrandr --newmode "1440x900" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync xrandr --addmode VGA1 1440x900 </code></pre> |
22,210,276 | 0 | How to reroute a resource to include a different field besides $id in Laravel 4 <p>I have a resource controlling one of my tables "fans". I have a view that shows the information for each respective. The urls for these right now is "url.com/fans/{$id}", where {$id} is the unique id for the row/object in the table.</p> <p>I would like to maintain this relationship, but I would also like to the url be pointed to another column in the table (another unique identifier). So something like "ulr.com/fans/{$new_column}". </p> <p>How would I reroute this view/url so that it appears like that? This is what I have so far:</p> <p>Routes: </p> <pre><code>Route::resource('fans', 'FansController'); </code></pre> <p>FansController:</p> <pre><code>public function show($id) { $fan = Fan::find($id); return View::make('fans.show', compact('fan')); } </code></pre> <p>So ultimately, I would like "url.com/fans/{$id}" to still work, but then it will be rerouted to "url.com/fans/{$new_column}". And going directly to "url.com/fans/{$new_column} should just stay there. </p> |
20,079,151 | 0 | Trying to use the GitHub GUI and I come across "GitHub for Mac version is too old" <p>I tried to install GitHub GUI because I'm new to github. However, I installed the newest version of the github GUI I could find (straight from the github site itself)</p> <p>But when I try to log in using the GUI, it claims "GitHub for Mac version is too old"</p> <p>Can anyone help me out here?</p> |
38,407,861 | 0 | How do I get 'id' from database to update a particular row? <p>I am trying to update a row which is already in database, and i am using above code for that but it gives me error as 'undefined id', so how can i do this.....please help me!!!</p> <pre><code>if(isset($_POST['sub'])) { $getid="select id from login"; $res=mysql_query($getid); $ids=$_GET[$row['id']]; $about=$_POST['desc']; $pri=$_POST['price']; $ride=$_POST['fly']; $city=$_POST['ct']; $flt=""; foreach($ride as $entry) { $flt .= $entry.","; } $ct=""; foreach($city as $entry) { $ct .= $entry.","; } $query ="UPDATE login SET rides='$flt',price=$pri,about='$about',city='$ct' WHERE id='$ids'"; $result = mysql_query($query); echo $result; if(!$result) { echo '<script language="javascript">'; echo 'alert("something went Wrong...:("); location.href="edit.php"'; echo '</script>'; } else { echo '<script language="javascript">'; echo 'alert("successfully updated!!!"); location.href="edit.php"'; echo '</script>'; } } </code></pre> |
34,807,482 | 0 | <p>In your code change <code>NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 1.0);</code> to </p> <p>NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 0.5);</p> <p>This code 0.5 means 50% of your image will compress.</p> <pre><code> - (void)saveImageToDocumentsDirectory:(UIImage *)mimage withFileName:(NSString *)fileName { NSData *dataForJPEGFile = UIImageJPEGRepresentation(mimage, 0.5); [dataForJPEGFile writeToFile:[self getDirectoryFilePath:fileName] atomically:YES]; } </code></pre> |
7,876,410 | 0 | <p>usually ajax request ha js type,if you can change type to js these changes will works </p> <p>controller </p> <pre><code>def show @article = Article.find(params[:id]) respond_to do |format| format.html format.js format.xml { render :xml => @article } end </code></pre> <p>end</p> <p>then in app/views/articles/show.js.erb write javascript code to update page content like</p> <pre><code>$("#yourDiv1").html("blah blah"); $("#yourDiv2").html("whatever"); </code></pre> <p>and following approach will work for both html and JS</p> <pre><code>$.ajax({ success : null, type : 'GET', url : '/admin/articles/show', dataType : 'html', data: { id: article_id }, }).done(function( html ) { $("#yourDIv").html(html); }); </code></pre> |
24,368,662 | 0 | Query only uses relations without a given property <p>Is there a possibility with cypher to not use certain relations based on property? </p> <p>We have a new requirement that says that relations should never be hard deleted but should get a flag "deleted = true" so we kind of have an audit trail for relations of our nodes. (Something like X was a friend of Y but a little more complex and for all relation types)</p> <p>This is doable in a cypher query by just using <code>WHERE r.deleted = false</code> but in more complex queries that traverse 4-5 relation types this might become harder.</p> <p>Is there an easy way to just say that Neo4J shouldn't use any relation with the property "deleted" set to true?</p> |
28,617,439 | 0 | PERL Fixed Width to CSV based on Input Files <p>EDITED: I'm attempting to create a brief script that calls for an input fixed width file and a file with the start position and length of each attribute and then outputs the file as CSV instead of fixed width. I haven't messed with removing whitespace yet and am currently focusing on building the file reader portion. </p> <p>Fixed: My current issue is that this code returns data from the third row for $StartPosition and from the fourth row for $Length when they should both be first found on the first row of COMMA. I have no idea what is prompting this behavior.</p> <p>Next issue: It only reads the first record in practice_data.txt I'm guessing it's something where I need to tell COMMA to go back to the beginning?</p> <pre><code>while (my $sourceLine = <SOURCE>) { $StartPosition = 0; $Length = 0; $Output = ""; $NextRecord =""; while (my $commaLine = <COMMA>) { my $Comma = index($commaLine, ','); print "Comma location found at $Comma \n"; $StartPosition = substr($commaLine, 0, $Comma); print "Start position is $StartPosition \n"; $Comma = $Comma + 1 $Length = substr($commaLine, $Comma); print "Length is $Length \n"; $NextRecord = substr($sourceLine, $StartPosition, $Length); $Output = "$Output . ',' . $NextRecord"; } print OUTPUT "$Output \n"; } </code></pre> <p><strong>practice_data.txt</strong></p> <pre><code>1234512345John Doe 123 Mulberry Lane Columbus Ohio 43215Johnny Jane 5432154321Jason McKinny 423 Thursday Lane Columbus Ohio 43212Jase Jamie 4321543212Mike Jameson 289 Front Street Cleveland Ohio 43623James Sarah </code></pre> <p>Each record is 100 characters long. <strong>Definitions.txt:</strong></p> <pre><code>0,10 10,10 20,10 30,20 50,10 60,10 70,5 75,15 90,10 </code></pre> |
25,824,500 | 0 | Change web font-face type depending on browser <p>Is there any simple CSS rule for changing the whole body font-face type by detecting the browser type?</p> <p>Open-sans doesn't work in IE so I'm searching for a way to change it depending on the browsers.</p> <p>I tried looking at <a href="http://stackoverflow.com/questions/14633947/alternative-css-font-settings-for-different-browsers">this question</a> but still didn't understand how to accomplish this task.</p> |
39,695,728 | 0 | <blockquote> <p>You can go with the following steps :</p> </blockquote> <p>Step 1: you can use the regex to extract the url <code>.*href=(.*)\\">.*</code></p> <p>Output will be : <code>\"http:\/\/docroot.com.dd:8083\/sites\/docroot.com.dd\/files\/catalogues\/2016-09\/images\/Pty%20Prs.compressedjpg_Page1.jpg</code></p> <p><a href="https://regex101.com/r/rZ9gX4/1" rel="nofollow">Example link</a></p> <p>Stem 2: use <code>unescape</code> function </p> <p>Output will be : <code>""http://docroot.com.dd:8083/sites/docroot.com.dd/files/catalogues/2016-09/images/Pty Prs.compressedjpg_Page1.jpg"</code></p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.