pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
22,427,418 | 0 | <p>I solved the problem by removing the line</p> <pre><code>storyboard.purgeScene("onevsone") </code></pre> <p>from the exitscene event of the scene and arranging the code like below</p> <pre><code>local function btnTap(event) local function onAlertComplete(event) if "clicked" == event.action then local i = event.index if i == 1 then storyboard.gotoScene("luduMenu") end end end native.showAlert( "End Game?", "Are you sure you want to exit this game?", { "Yes", "No" }, onAlertComplete ) return true end </code></pre> |
38,938,074 | 0 | Mysql count with condition <p>I have a table like this:</p> <pre><code>+---------------+--------+-----------------+ | ReservationID | UserID | ReservationDate | +---------------+--------+-----------------+ | 1 | 10002 | 04_04_2016 | | 2 | 10003 | 04_04_2016 | | 3 | 10003 | 07_04_2016 | | 4 | 10002 | 04_04_2016 | | 5 | 10002 | 04_04_2016 | | 6 | 10002 | 06_04_2016 | +---------------+--------+-----------------+ </code></pre> <p>I use this query to count how many reservation each of my user have:</p> <pre><code>SELECT UserID, COUNT(UserID) as Times FROM mytable GROUP BY UserID ORDER BY Times DESC </code></pre> <p>And It gives me this result:</p> <pre><code>+--------+-------+ | UserID | Times | +--------+-------+ | 10002 | 4 | | 10003 | 2 | +--------+-------+ </code></pre> <p>However I want to count one if my user has more than one reservation in specific date. For example User 10002 has 3 reservation at 04-04-2016, It should be count 1. And I want to get this result:</p> <pre><code>+--------+-------+ | UserID | Times | +--------+-------+ | 10002 | 2 | | 10003 | 2 | +--------+-------+ </code></pre> <p>How can I can get it?</p> <p>Thanks</p> |
574,667 | 0 | <p>If you want to maintain your own version of LibraryB you have a few options:</p> <ul> <li><p>You can make LibraryB inherent part of your project: just remove or comment out <code>[remote "LibraryB"]</code> section in the config file, and make changes to LibraryB inside your project.</p> <p>The disadvantage is that it would be harder to send patches for canonical (third-party) version of LibraryB</p></li> <li><p>You can continue using 'subtree' merge, but not from the canonical version of LibraryB, but from your own clone (fork) of this library. You would change remote.LibraryB.url to point to your local version, and your local version would be clone of original LibraryB. Note that you should merge your own branch, and not remote-tracking branch of canonical LibraryB.</p> <p>The disadvantage is that you have to maintain separate clone, and to remember that your own changes (well, at least those generic) to LibraryB have to be made in the fork of LibraryB, and not directly inside ProjectA.</p></li> <li><p>You might want to move from 'subtree' merge which interweaves history of ProjectA and LibraryB, to having more separation that can be achieved using <a href="http://git-scm.com/docs/git-submodule" rel="nofollow noreferrer" title="git-submodule(1)">submodule</a> (<a href="http://git.or.cz/gitwiki/GitSubmoduleTutorial" rel="nofollow noreferrer" title="Git Submodule Tutorial at Git wiki">tutorial</a>). In this case you would have separate repository (fork) of LibraryB, but it would be inside working area of ProjectA; the commit in ProjectA would have instead of having tree of LibraryB as subtree, pointer to commit in LibraryB repository. Then if you do not want to follow LibraryB development, it would be enough to simply not use 'git submodule update' (and perhaps just in case comment out or remove link to canonical version of LibraryB).</p> <p>This has the advantage of making it easy to send your improvements to canonical LibraryB, and the advantage that you make changes inside working area of ProjectA. It has disadvantage of having to learn slightly different workflow.</p> <p>Additionally there is also an issue of how to go from 'subtree' merge to submodules. You can either:</p> <ul> <li>Move from subtree merge to submodule by creating git repository in the subproject subtree in superproject working repository (i.e. "git init" inside appropriate subdirectory + appropriate "git submodule init" etc.). This means that you would have 'subtree' up to some point of history, and submodule later.</li> <li>Rewrite history using <a href="http://git-scm.com/docs/git-filter-branch" rel="nofollow noreferrer" title="git-filter-branch(1)">git filter-branch</a> to replace subtree merge by submodule. This has the disadvantage of rewriting history (big no if somebody based his/her work on current history), and advantage of 'clean start'. Or you can wait a bit for "git submodule split" (<a href="http://thread.gmane.org/gmane.comp.version-control.git/109667" rel="nofollow noreferrer" title="[RFC] What's the best UI for 'git submodule split'?">thread on git mailing list</a>) to make it into git...<br> <em>Unfortunately <a href="http://www.ishlif.org/blog/linux/splitting-a-git-repository/" rel="nofollow noreferrer">Splitting a git repository</a> blog posts returns "host not found"</em></li> </ul></li> </ul> <p>I hope that this version solve your problem.</p> <p><strong><em>Disclaimer:</em></strong> <em>I have used neither subtree merge, nor submodules, nor git-filter-branch personally.</em></p> |
25,312,549 | 0 | <p>By the looks of a comment you left in another answer given (to the effect of getting the same error message), it sounds like you need to escape the entered data, including <code>if(!mysqli_query($con,$sql))</code> which is a contributing factor. - <em>See further down below.</em></p> <p>Using the following may very well fix the problem.</p> <pre><code>$con=mysqli_connect('localhost','root','root','secure_login'); // place this first if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $username = stripslashes($_POST['username']); $password = stripslashes($_POST['password']); $repassword = stripslashes($_POST['repassword']); $username = mysqli_real_escape_string($con,$_POST['username']); $password = mysqli_real_escape_string($con,$_POST['password']); $repassword = mysqli_real_escape_string($con,$_POST['repassword']); ... $sql = mysqli_query($con,"INSERT INTO users (username, password) VALUES ('".$username."','".$password."')"); ... </code></pre> <p>You also need to change:</p> <pre><code>if (!mysqli_query($con,$sql)){...} </code></pre> <p>to </p> <pre><code>if (!$sql){...} </code></pre> <p>you're querying twice with <code>mysqli_query</code> and connecting twice, which is a <strong>contributing</strong> factor, <em>then again</em>, it may very well be <strong>"thee"</strong> reason which I suspect it is.</p> <ul> <li>Consult <a href="http://stackoverflow.com/a/25268487/"><strong>this answer</strong></a> given by Marc B who states what is happening with a similar problem. His explanation will shed some light on the subject.</li> </ul> <hr> <p><strong>About password storage</strong></p> <p>I must also note that storing passwords in plain text is unsafe.</p> <p>You'd be better off using <a href="http://security.stackexchange.com/q/36471"><strong>CRYPT_BLOWFISH</strong></a> or PHP 5.5's <a href="http://www.php.net/manual/en/function.password-hash.php" rel="nofollow"><code>password_hash()</code></a> function. For PHP < 5.5 use the <a href="https://github.com/ircmaxell/password_compat" rel="nofollow"><code>password_hash() compatibility pack</code></a> and use <a href="http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php" rel="nofollow"><strong>prepared statements</strong></a>.</p> <p>Plus as I stated in my comment;</p> <p>You don't need this <code>mysql_select_db("secure_login", $con);</code> for two reasons.</p> <p>1) <strong>You're already selecting a DB.</strong> <code>mysqli_connect('localhost','root','root','secure_login')</code> </p> <p>2) <strong>You're mixing MySQL APIs</strong> - Those are two different APIs, and they do not mix together.</p> <p>...and the fact about the missing quote for <code>$password</code> in <code>('$username',$password')</code></p> |
31,300,608 | 0 | <p>First line -- a table scan (see NULLs and ALL)</p> <p>2nd and 4th line -- an index scan ("Using index"), but rather costly since 10K rows needed.</p> <p>What it does not tell you is whether some other index(es) would be more efficient. Nor does it tell you whether reformulating the query would help. Please provide us with the SELECT so we can help you there, plus tie more things to the EXPLAIN.</p> <p>More links:<br> <a href="http://myxplain.net/" rel="nofollow">http://myxplain.net/</a><br> <a href="http://www.sitepoint.com/using-explain-to-write-better-mysql-queries/" rel="nofollow">http://www.sitepoint.com/using-explain-to-write-better-mysql-queries/</a></p> |
41,047,079 | 0 | google home actions catch all query with Actions SDK <p>Our company already has as a conversational service for intent matching and entity parsing. Let's call this service "Charlie". </p> <p>If we were to integrate Google Home with our service, would we have to repeat all of our existing queries in the action package or is there way to have a catch-all query so when we say to "talk to Charlie", Google Home forwards future utterances to our Charlie service?</p> |
28,823,526 | 0 | How to debug android studio gradle files and tasks? <p>I've leveraged TWiStErRob's solution <a href="http://stackoverflow.com/questions/21414399/android-gradle-dynamically-change-versionname-at-build-time">to auto-increment android versionNumber</a> and I have expanded on this to add more capability, however lately when I add the "apply from" statement in my build.gradle to include the auto-version.gradle file and let Gradle sync, my build.gradle gets inexplicably corrupted and loses all formatting using Android Studio 1.1.</p> <p>Is there any way to debug or step through gradle scripts in Android studio?</p> |
40,963,998 | 0 | <p>The header file (<code>.h</code>) is the programmer's interface to your module. Anything a user (programmer) of your module needs to know to use your module should be in there, but put the actual implementations in the associated <code>.c</code> file. Generally, you put the function prototypes (e.g. <code>int f(void);</code>) in the <code>.h</code> file and the definitions (the implementations, e.g. <code>int f(void) { return 1; }</code>) in the <code>.c</code> file. The linker matches the prototype to the definition because the function signatures match (the name, argument types, and return type). One way to think about it is the <code>.h</code> file as what you share with everyone, and the <code>.c</code> file as what you keep to yourself.</p> <p>If you want a user of your module to have access to <code>STUDENT_SIZE</code>, then put</p> <pre><code>#define STUDENT_SIZE 20 </code></pre> <p>in your <code>.h</code> file instead of your <code>.c</code> file. Then, any file with</p> <pre><code>#include "stud.h" </code></pre> <p>would have your macro for <code>STUDENT_SIZE</code>. (Notice the file name is <code>"stud.h"</code> not <code>"stud"</code>.)</p> <blockquote> <p>Lets say i want to use STUDENT_SIZE in another file whats the syntax? Do i need to use stud.STUDENT_SIZE?</p> </blockquote> <p>No. You might be confusing this with namespaces, which <a href="http://stackoverflow.com/questions/4396140/why-doesnt-ansi-c-have-namespaces">C does not have</a> in the same sense as other languages like C++, Java, etc. Just use <code>STUDENT_SIZE</code>. (This is why it is important to not use existing identifiers, and also why many people frown upon macros.)</p> <blockquote> <p>... i want from another file to access some of the functions inside stud.c.</p> </blockquote> <p>If you want another file to have access to some function in <code>stud.c</code>, then put that function's prototype in <code>stud.h</code>. This is precisely what the header file is for.</p> <blockquote> <p>... if i want to lets say make an array of students:</p> <p><code>struct stud students[STUDENT_SIZE];</code></p> <p>Can i access that normally like <code>students[5].stud_id</code> ?</p> </blockquote> <p>As you have written your header file, no. You might know some <code>struct stud</code> exists, but you don't know what the members are called (i.e. you wouldn't know <code>stud_id</code> exists). The reason is that the user of your module sees only what is in the header file, and you defined no members of the struct in your header file. (I'm surprised what you have written even compiles, because you define <code>struct stud</code> twice, once empty <code>{}</code>, and once with members.) Again, if you want the programmer user to have access to the members of <code>struct stud</code>, its definition</p> <pre><code>struct stud { char stud_id[MAX_STR_LEN]; char stud_name[MAX_STR_LEN]; struct grade Grade[MAX_STRUCT]; struct income Income[MAX_STRUCT]; }; </code></pre> <p>belongs in your header file (along with whatever those other macros are). Without knowing this, the programmer (and the compiler) has no idea what the members of <code>struct stud</code> are.</p> <p>(You didn't ask about this, but if you want to share access to a <em>global variable</em> in your <code>.c</code> file, then <em>declare</em> it with the keyword <code>extern</code> in your <code>.h</code> file, and without <code>extern</code> in your <code>.c</code> file. See <a href="http://stackoverflow.com/questions/496448/how-to-correctly-use-the-extern-keyword-in-c">How to correctly use the extern keyword in C</a> for more.)</p> |
40,064,792 | 0 | <p>This worked for me:</p> <ol> <li>Generate a <a href="https://help.github.com/articles/creating-an-access-token-for-command-line-use/" rel="nofollow">Github Access Token</a></li> <li><p>In requirements.txt list private module as follows:</p> <pre><code>git+https://your_user_name:your_git_token@github.com/your_company/your_module.git </code></pre></li> </ol> |
5,664,767 | 0 | How do I print out java debugging information to the screen like gdb's print command in eclipse? <p>When I use the gdb debugger in c++ eclipse I can open up the console tab and type <code>p someVar</code> and it will print out the value of that variable. Now I'm in java eclipse and I would like to do the same type of thing but I can't find out how. I know there is a variables tab but I would like to use print because of its ability to print out function calls and such. Does anyone know if java has this debugging ability or am I stuck constantly using the Variables tab?</p> |
21,054,543 | 0 | <p>This may be due to a recent change to the router component. We are currently evaluating the best way to alleviate this issue. The engineering team is engaged in solving this.</p> |
11,608,641 | 0 | Scala Form, Type mismatch error <p>I am trying to do CRUD on a Category class:</p> <p><strong>categoryEdit.scala.html</strong>:</p> <pre><code>@(cat: Category, myForm: Form[Category]) @admin(title = "Category") { @helper.form(action = controllers.Application.categorySave) { @inputText(myForm("name")) <input type="submit" value="Save"> } } </code></pre> <p>The <strong>controller</strong> code:</p> <pre><code>public static Result categorySave() { // save form data here ... return redirect( routes.Application.index() ); } </code></pre> <p>Entry in Routes file is as below.</p> <pre><code>GET /saveCategory controllers.Application.categorySave() </code></pre> <p>I am getting this error: </p> <pre><code>type mismatch; found : play.mvc.Result required: play.api.mvc.Call </code></pre> <p>on this line: <code>@helper.form(action = controllers.Application.categorySave) {</code></p> <p>What's wrong in my form? I am missing something?</p> |
31,194,788 | 0 | Validating Input Fields with JavaScript or jQuery <p>I need to check to make sure that four fields have some kind of value in them. I have tried these ideas: <a href="http://stackoverflow.com/questions/11039658/how-to-check-whether-a-select-box-is-empty-using-jquery-javascript">Check whether a select box is empty</a> <a href="http://stackoverflow.com/questions/4855250/how-to-tell-if-a-drop-down-has-options-to-select">How to tell if a DDL has options to select</a></p> <p>My code is currently this:</p> <pre><code> function goToConfirmStep() { var isAllowed = false; var type = $(".#tShowingType option:selected").val(); //DDL var startDate = $("#startDate").text(); //date picker var startTime = $("#startTime option:selected").val(); //DDL var endTime = $("showingLength option:selected").val(); //DDL if (type.val() ) { //&& //(type != null || type != "") //(startDate.text() == "" || startDate.text() == null)) {//&& //($('#startTime').has('option').length > 0) && //($('#endTime').has('option').length > 0)) { alert("here"); </code></pre> <p>I left the comments in so you can tell what I have tried.</p> <p>If they have values selected (which the 'type' and 'startTime' will have one selected on load), I want to move to the next page. I have an alert on the else to prevent them from moving forward if the fields aren't filled out.</p> |
20,441,633 | 0 | Restrict scope of variable within include file in php <p>I am facing variable conflicting issues in application i am designing.</p> <p>e.g in one of my web application page, there are two modules</p> <p>i: tag clouds module ii: photo listing module</p> <p>both have variable <strong>$listOrder</strong> , e.g when script processing module "<strong>tag cloudes</strong>" it set <strong>$listOrder = "tagid desc"</strong> as its not set initially.</p> <pre><code>if(!isset($listOrder)) $listOrder = "tagid desc"; </code></pre> <p>When script reach to photo listing module again it try to process the following line as shown above. as variable is already set in tag cloud list. it keeps "tagid desc" as value. which causes sql error as "tagid" is not a field of photo listing.</p> <p>This is simple example there are more than 4 or 5 modules with lots of similar variables in every page, which cause conflicts.</p> <p>Can we do something to restrict scope of variable to module level in php to avoid such conflicts.</p> |
14,717,367 | 0 | How to convert the java String to different languages <p>Currently I am writing some text to pdf. based on the user locale, the language must be changed(ex: spanish, chineese, german).</p> <p>Is there any API for this conversion? and Better approach?</p> |
28,895,039 | 0 | Jquery for chosen not working properly on rails 4 app <p>I am using the Mailboxer and Chosen gems. A user can select multiple users from a dropdown menu. The problem is, on the initial load the dropdown appears already opened and allows you to only select one other user. If I reload the page the dropdown appears as it should.</p> <p>When I check it in the chrome inspector I get <a href="http://cl.ly/image/290g3B2o380f" rel="nofollow">TypeError: undefined is not a function</a> error. I've checked S.O, and google and a lot of the advice is to change the order of my application.js file. I have tried this but cannot get this to fire properly on the initial start-up. Looking at my terminal window, every request seems to go through successfully.</p> <p><a href="http://cl.ly/image/2n3r3r2t1S3j" rel="nofollow">Dropdown on initial load, broken</a></p> <p><a href="http://cl.ly/image/2x1X3D0v1w0R" rel="nofollow">Dropdown w/ refresh working properly</a></p> <p>So it DOES work, but why do I have to refresh the page to make it work properly?</p> <p>Application.js:</p> <pre><code> ... // //= require jquery //= require jquery.turbolinks //= require jquery_ujs //= require chosen-jquery //= require bootstrap //= require jquery.image-select //= require messages //= require turbolinks </code></pre> <p>application.css.scss:</p> <pre><code>... * *= require_tree . *= require_self */ @import 'bootstrap'; @import 'bootstrap/theme'; @import 'chosen'; ... </code></pre> <p>messages.coffee:</p> <pre><code># Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ jQuery -> $('.chosen-it').chosen() </code></pre> <p>gemfile:</p> <pre><code>source 'https://rubygems.org' ruby '2.1.5' gem 'rails', '4.2.0' gem 'devise' gem 'thin' gem "simple_calendar" gem 'bootstrap-sass' gem 'bootstrap-will_paginate' gem "mailboxer" gem 'will_paginate' gem 'gravatar_image_tag' group :development do gem 'sqlite3' gem 'better_errors' gem 'binding_of_caller' gem 'annotate' end group :production do gem 'pg' gem 'rails_12factor' end gem 'chosen-rails' gem 'sass-rails', '~> 4.0.5' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.1.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' gem 'jquery-turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc #gem 'sass-rails', '4.0.4' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Use debugger # gem 'debugger', group: [:development, :test] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin] </code></pre> <p>Offending file, home.html.erb:</p> <pre><code><div class="box"> <div class="col-lg-12 text-center"> <div id="carousel-example-generic" class="carousel slide"> <!-- Indicators --> <ol class="carousel-indicators hidden-xs"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner"> <div class="item active"> <%= image_tag "slide-1.jpg", :class => "img-responsive img-full" %> </div> <div class="item"> <%= image_tag "slide-2.jpg", :class => "img-responsive img-full" %> </div> <div class="item"> <%= image_tag "slide-5.jpg", :class => "img-responsive img-full" %> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"> <span class="icon-prev"></span> </a> <a class="right carousel-control" href="#carousel-example-generic" data-slide="next"> <span class="icon-next"></span> </a> </div> <h2 class="brand-before"> <small>Welcome to</small> </h2> <h1 class="brand-name">Balern Education</h1> <hr class="tagline-divider"> </div> </div> </div> <div class="box"> <hr> <hr> <%= image_tag "intro1.jpg", :class => "img-responsive img-border img-left" %> <hr class="visible-xs"> </div> <div class="box"> <hr> <h2 class="intro-text text-center">Balern really <strong>Cares</strong> </h2> <hr> </div> <!-- /.container --> <!-- jQuery --> <script src="assets/jquery.js"></script> <!-- Bootstrap Core JavaScript --> <script src="assets/bootstrap.min.js"></script> <!-- Script to Activate the Carousel --> <script> $('.carousel').carousel({ interval: 5000 //changes the speed }) </script> </code></pre> |
35,211,170 | 0 | carrierwave backgrounder s3 recreate_versions <p>I'm trying to follow <a href="https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Recreate-and-reprocess-your-files-stored-on-fog" rel="nofollow">https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Recreate-and-reprocess-your-files-stored-on-fog</a> instructions, but I was getting errors. my file is called <code>hat.jpg</code></p> <p>I'm using carrierwave_backgrounder so i needed these instructions to process immediately.</p> <pre><code>with_avatar.each do |instance| begin instance.process_avatar_upload = true instance.avatar.cache_stored_file! instance.avatar.retrieve_from_cache!(instance.avatar.cache_name) instance.avatar.recreate_versions! instance.save! rescue => e Rails.logger.info("ERROR: UserAvatar: #{instance.id} -> #{e}") end end </code></pre> <p>So, i tried it in my console one line at a time. If I set process_avatar_upload = true, the next line fails</p> <pre><code>undefined method `cached?' for nil:NilClass </code></pre> <p>If i run the same command again i get</p> <pre><code>undefined method `content_length' for nil:NilClass </code></pre> <p>Finally, if I run a third time, it seems to work. However, when i get to the recreate_versions! I get this:</p> <pre><code>No such file or directory [my file path]/uploads/tmp/1454615129-9112-7053/square_hat.jpg </code></pre> <p>Its correct, there is no square, because that's what I'm trying to create.</p> <p>How can I recreate my versions on s3? I have a lot of them to do. Thanks.</p> |
18,151,185 | 0 | <p>The <em>technical</em> difference is the presence of <code>get</code> and <code>set</code> accessors. You can customize either or both to do more that just get or set the value.</p> <p>The <em>practical</em> difference is that many data-binding methods (including most if not all of the .NET controls) use reflection to bind to <em>properties</em> only - they do not support binding to <em>fields</em> directly.</p> <p>If you plan to bind the properties of your class to a UI control (<code>DataGrid</code>, <code>TextBox</code>, etc.), or if there's the <em>slightest</em> chance that you might customize the get/set accessors in the future, then make the properties. It is a breaking change to change a field to a property.</p> <p>Many coding standards (<a href="http://msdn.microsoft.com/en-us/library/ms182141.aspx" rel="nofollow">including FxCop</a>) hold that you should use properties instead of fields for public data.</p> <p>If lines of code are a concern you can use auto-implemented properties:</p> <pre><code>class Class2 { public static int A {get; set; } } </code></pre> <p>You can later add logic to the get/set accessors without breaking users of your class.</p> |
29,919,674 | 0 | How to use dependent bundles in different container in Fabri8? <p>I am trying to understand the capabilities of Fabric8's container management. I just want to clarify weather the following scenario can be achieved by using Fabric8 in JBossFuse.</p> <p>I have created simple 2 bundles (tick, tock bundles inspired by the : <a href="http://kevinboone.net/osgitest.html" rel="nofollow noreferrer">http://kevinboone.net/osgitest.html</a>). Simply Tick bundle is exporting a package and Tock bundle is importing it. In another words, Tock Bundle depends on the Tick Bundle.</p> <p>These 2 bundles are working perfectly when deployed in a single container (say in a one child container in JBoossFuse).</p> <p>Then I have created a cluster by using the fabric8 and added its containers to the Fabric Ensemble as well.</p> <p>And I have created 2 profiles. TickProfile contains the Tick bundle and Tock profile contains the Tock bundle.</p> <p>I have deployed above 2 profiles in 2 different containers as follows, </p> <p><img src="https://i.stack.imgur.com/yiZjK.png" alt="enter image description here"></p> <p>Then it is not working properly because Tock bundle cannot resolve its dependency of Tick Bundle which is exposed by Tick Bundle (because those bundles are in two different containers).</p> <p>I thought this is possible with fabric8 but it seems it cannot.</p> <p>It would be really appreciated if someone can tell me whether there is any way of achieving this.</p> <p>Thanks.</p> |
5,232,342 | 0 | <p>The rate at which the capacity of a vector grows is implementation dependent. Implementations almost invariable choose exponential growth, in order to meet the <em>amortized constant time</em> requirement for the <code>push_back</code> operation. What <em>amortized constant time</em> means and how exponential growth achieves this is interesting.</p> <p>Every time a vector's capacity is grown the elements need to be copied. If you 'amortize' this cost out over the lifetime of the vector, it turns out that if you increase the capacity by an exponential factor you end up with an amortized constant cost.</p> <p>This probably seems a bit odd, so let me explain to you how this works...</p> <ul> <li>size: 1 capacity 1 - No elements have been copied, the cost per element for copies is 0.</li> <li>size: 2 capacity 2 - When the vector's capacity was increased to 2, the first element had to be copied. Average copies per element is 0.5</li> <li>size: 3 capacity 4 - When the vector's capacity was increased to 4, the first two elements had to be copied. Average copies per element is (2 + 1 + 0) / 3 = 1.</li> <li>size: 4 capacity 4 - Average copies per element is (2 + 1 + 0 + 0) / 4 = 3 / 4 = 0.75.</li> <li>size: 5 capacity 8 - Average copies per element is (3 + 2 + 1 + 1 + 0) / 5 = 7 / 5 = 1.4</li> <li>...</li> <li>size: 8 capacity 8 - Average copies per element is (3 + 2 + 1 + 1 + 0 + 0 + 0 + 0) / 8 = 7 / 8 = 0.875</li> <li>size: 9 capacity 16 - Average copies per element is (4 + 3 + 2 + 2 + 1 + 1 + 1 + 1 + 0) / 9 = 15 / 9 = 1.67</li> <li>...</li> <li>size 16 capacity 16 - Average copies per element is 15 / 16 = 0.938</li> <li>size 17 capacity 32 - Average copies per element is 31 / 17 = 1.82</li> </ul> <p>As you can see, every time the capacity jumps, the number of copies goes up by the previous size of the array. But because the array has to double in size before the capacity jumps again, the number of copies per element always stays less than 2.</p> <p>If you increased the capacity by 1.5 * N instead of by 2 * N, you would end up with a very similar effect, except the upper bound on the copies per element would be higher (I think it would be 3).</p> <p>I suspect an implementation would choose 1.5 over 2 both to save a bit of space, but also because 1.5 is closer to the <a href="http://en.wikipedia.org/wiki/Golden_ratio">golden ratio</a>. I have an intuition (that is currently not backed up by any hard data) that a growth rate in line with the golden ratio (because of its relationship to the fibonacci sequence) will prove to be the most efficient growth rate for real-world loads in terms of minimizing both extra space used and time.</p> |
14,634,166 | 0 | <p>I agree, htaccess can't help you. I guess you'll have to change them manually. I wish I could be of more help</p> |
38,402,138 | 0 | How to restrict users from creating new organization on Grafana <p>On a Grafana deployment if i create a user with the Editor role it can't perform administrative tasks but it can create a new organization and gain Administrative privileges on that organization. Is there a way to prevent roles from creating new Organizations?</p> <p>Bellow you can see a snapshot of a user with the Editor role viewing the "New organization" action on the main menu on Grafana 3.1.0 <a href="https://i.stack.imgur.com/ngnF2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ngnF2.png" alt="enter image description here"></a></p> |
27,686,169 | 0 | PHP: calculate array values by array <p>This may be simple to some of you guys but I'm really dummy in php. All what I need is just to transform a multidimensional array and calculate some of it's sub array values.</p> <pre><code> Array ( [0] => Array ( [date] => 2014-10-30 [mission] => one [point] => 10 ) [1] => Array ( [date] => 2014-10-31 [mission] => five [point] => 10 ) [2] => Array ( [date] => 2014-11-19 [mission] => one [point] => 8 ) </code></pre> <p>And the output would be like:</p> <pre><code> Array ( [one] => Array ( [mission] => one [point] => 18 // sum all points where [mission] => one [count] => 2 [everage] => 9 // 18/2 ) [five] => Array ( [mission] => five [point] => 10 [count] => 1 [everage] => 10 ) </code></pre> <p>It is simple to get the sum of <code>[point]</code> values using <code>foreach</code> but troubles begin when I try to get <code>count</code> of arrays with same <code>[mission]</code> value. Thats my code:</p> <pre><code>foreach($missionsarray as $row) { if(!isset($newarray[ $row['mission'] ])) { $newarray[ $row['mission'] ] = $row; $newarray[ $row['mission'] ]['count'] = count($row['point']); continue ; } $newarray[ $row['mission'] ]['point'] += $row['point']; } print_r($newarray); </code></pre> |
21,055,710 | 0 | What is the difference between JavaFX scripting and Using Regular java Syntax while programming JavaFX Applications <p>I am looking for a detail explanation to the following question.</p> <p>Can I use regular java syntax to develop JavaFX application? And if so why is the JavaFX scripting so important?</p> |
28,198,875 | 0 | <p>As far as I know, there is no such .net class as <code>EmailService</code> Typically you use the <code>SmtpClient</code> class to send emails:</p> <pre><code>SmtpClient client = new SmtpClient("server.address.com"); MailAddress from = new MailAddress(fromAddress, fromName); MailMessage msg = new MailMessage(); msg.From = from; foreach(string addr in to) msg.To.Add(addr); msg.Body = content; msg.Subject = subject; client.Send(msg); </code></pre> |
2,955,707 | 0 | <p>The shell can't do that directly, since there will only be a single stream coming from the source program (the cat, in this case).</p> <p>You need a helper program, such as <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?tee" rel="nofollow noreferrer">tee</a>. Try this:</p> <pre><code>$ cat mysig | tee -a F* </code></pre> |
3,154,510 | 0 | <p>You probably don't need the .dialog('open') call; use the option <a href="http://docs.jquery.com/UI/Dialog#option-autoOpen" rel="nofollow noreferrer">autoOpen</a> : true instead.</p> |
9,643,069 | 0 | <p>I did this using the following snippet.</p> <pre><code>#!/usr/bin/env python import numpy as np import matplotlib.cm as cm import matplotlib.mlab as mlab import matplotlib.pyplot as plt from pylab import * delta = 0.025 x = y = np.arange(-3.0, 3.0, delta) X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = Z2-Z1 # difference of Gaussians ax = Axes(plt.gcf(),[0,0,1,1],yticks=[],xticks=[],frame_on=False) plt.gcf().delaxes(plt.gca()) plt.gcf().add_axes(ax) im = plt.imshow(Z, cmap=cm.gray) plt.show() </code></pre> <p>Note the grey border on the sides is related to the aspect rario of the Axes which is altered by setting <code>aspect='equal'</code>, or <code>aspect='auto'</code> or your ratio.</p> <p>Also as mentioned by Zhenya in the comments <a href="http://stackoverflow.com/questions/4042192/reduce-left-and-right-margins-in-matplotlib-plot">Similar StackOverflow Question</a> mentions the parameters to <code>savefig</code> of <code>bbox_inches='tight'</code> and <code>pad_inches=-1</code> or p<code>ad_inches=0</code></p> |
5,856,704 | 0 | <p>Assuming you're on a linux/unix machine with the GNU toolchain you could check this easily by:</p> <p>Copying the above code into test.c:</p> <pre><code>$ echo "int temp = temp +1; int main() { return temp; }" > test.c </code></pre> <p>Testing to see if it's valid C (it's not):</p> <pre><code>$ gcc test.c test.c:2: error: initializer element is not constant </code></pre> <p>Testing to see if it's valid in C++ (it is!):</p> <pre><code>$ g++ test.c </code></pre> <p>Checking the return code:</p> <pre><code>$ ./a.out && echo "success: return code $?" || echo "failure: return code $?" failure: return code 1 </code></pre> |
4,208,775 | 0 | <p>Your substitution will look like this:</p> <pre><code>s#^.*\s(remote\.host\.tld)\s*$#$ip_to_update\t$1# </code></pre> <p>Replacement can be done in one line:</p> <pre><code>perl -i -wpe "BEGIN{$ip=`awk {'print \$5'} /web_root/ip_update/ip_update.txt`} s#^.*\s(remote\.host\.tld)\s*$#$ip\t$1#"' </code></pre> |
24,002,066 | 0 | Progress Bar during the loading of a ListView <p>So, I want to display a spinning loading indicator while my ListView is being populated. I successfully have implemented the progress bar, BUT for some reason it disappears BEFORE all of the listings are displayed. What I want is the progressbar to be present during the TOTAL load time of the listings. Basically, what it seems like, each listing is being displayed one at a time, not all at once when they are all loaded. What I'm doing is 1. Creating a new custom adapter class 2. Populating the ListView in an AsyncTask using this adapter class 3. Setting the ListView to this adapter</p> <p>This works properly, the progress bar just disappears before all of the listings are displayed. Does anyone have any ideas?</p> <p>Activity class:</p> <pre><code>public class MainActivity extends ActionBarActivity { ArrayList<Location> arrayOfLocations; LocationAdapter adapter; // public static Bitmap bitmap; Button refresh; ProgressBar progress; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progress=(ProgressBar)findViewById(R.id.progressbar_loading); // Construct the data source arrayOfLocations = new ArrayList<Location>(); // Create the adapter to convert the array to views adapter = new LocationAdapter(this, arrayOfLocations); FillLocations myFill = new FillLocations(); myFill.execute(); refresh = (Button) findViewById(R.id.refresh); refresh.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); startActivity(getIntent()); } }); } private class FillLocations extends AsyncTask<Integer, Void, String> { String msg = "Done"; protected void onPreExecute() { progress.setVisibility(View.VISIBLE); } // Decode image in background. @Override protected String doInBackground(Integer... params) { String result = ""; InputStream isr = null; try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://afs.spotcontent.com/"); // YOUR // PHP // SCRIPT // ADDRESS HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); isr = entity.getContent(); // resultView.setText("connected"); } catch (Exception e) { Log.e("log_tag", "Error in http connection " + e.toString()); } // convert response to string try { BufferedReader reader = new BufferedReader( new InputStreamReader(isr, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } isr.close(); result = sb.toString(); } catch (Exception e) { Log.e("log_tag", "Error converting result " + e.toString()); } // parse json data try { JSONArray jArray = new JSONArray(result); for (int i = 0; i < jArray.length(); i++) { final JSONObject json = jArray.getJSONObject(i); try { BitmapWorkerTask myTask = new BitmapWorkerTask( json.getInt("ID"), json); myTask.execute(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (Exception e) { // TODO: handle exception Log.e("log_tag", "Error Parsing Data " + e.toString()); } return msg; } protected void onPostExecute(String msg) { // Attach the adapter to a ListView ListView listView = (ListView) findViewById(R.id.listView1); // View header = (View) getLayoutInflater().inflate( // R.layout.listview_header, null); // listView.addHeaderView(header); listView.setAdapter(adapter); progress.setVisibility(View.GONE); } } } </code></pre> <p>Adapter class:</p> <pre><code>public class LocationAdapter extends ArrayAdapter<Location> { public LocationAdapter(Context context, ArrayList<Location> locations) { super(context, R.layout.item_location, locations); } @Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position Location location = getItem(position); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_location, parent, false); } // Lookup view for data population TextView tvName = (TextView) convertView.findViewById(R.id.tvName); TextView tvDetails = (TextView) convertView.findViewById(R.id.tvDetails); TextView tvDistance = (TextView) convertView.findViewById(R.id.tvDistance); TextView tvHours = (TextView) convertView.findViewById(R.id.tvHours); ImageView ivIcon = (ImageView) convertView.findViewById(R.id.imgIcon); // Populate the data into the template view using the data object tvName.setText(location.name); tvDetails.setText(location.details); tvDistance.setText(location.distance); tvHours.setText(location.hours); ivIcon.setImageBitmap(location.icon); // Return the completed view to render on screen return convertView; } } </code></pre> |
7,592,838 | 0 | Correct way to get beans from applicationContext Spring <p>I have a factory that creates instances:</p> <pre><code>public class myFactory { public static getInstace() { switch(someInt) { case 1: return new MySpringBean(); case 2: return new MyOtherSpringBean(); } } } </code></pre> <p>I need to return a new instance of the beans that are "managed" by Spring bc they have Transactional business logic methods. I have read in many posts here that I should not use getBean method to get a singleton or a new instance from the applicationContext. But I cannot find the proper way to do it for my case. I have used @Resource and it seems to work but it doesn't support static fields. Thanx </p> |
34,931,060 | 0 | Can't read array of structure in C <p>I am trying to read members of an object like in the code below. The issue is that the code can't read the second member (car[i].model) in the array and the third one (car[i].price), only the first one (car[i].manufacturer).</p> <pre><code>#include <stdio.h> #include <conio.h> struct machine { int price; char manufacturer[30]; char model[30]; }; int main() { int i = 0, n; printf("Introduce number of cars: "); scanf_s("%d", &n); struct machine car[100]; for (i = 0; i < n; i++) { printf("Data of the car nr. %d:\n", i+1); printf("Manufacturer: "); scanf_s("%s", car[i].manufacturer); printf("Model: "); scanf_s("%s", car[i].model); printf("\n"); printf("Price: "); scanf_s("%d", &car[i].price); printf("\n"); } for (i = 0; i < n; i++) { printf("Data of the car nr. %d:\n", i + 1); printf("Manufacturer: %s\n", car[i].manufacturer); printf("Manufacturer: %s\n", car[i].manufacturer); printf("Model: %s\n", car[i].model); printf("Price %d\n", car[i].price); } _getch(); } </code></pre> |
30,629,810 | 0 | Plotting multiple columns with a for loop in gnuplot, key doesn't work <p>I have file with many columns that I'd like to plot as follows:</p> <pre><code>plot for [i=1:30] 'test' using 1:i w lp </code></pre> <p>This gives the plot I want, but when I do <code>set key</code>, then the key I see has all lines labeled as <code>1:i</code>:</p> <p><img src="https://i.stack.imgur.com/O0Znl.png" alt="enter image description here"></p> <p>How can I make this output more meaningful, by actually displayin the value of <code>i</code>?</p> |
18,869,902 | 0 | <p>Basically:</p> <ul> <li><code>#info</code> is used to discover <a href="http://xmpp.org/extensions/xep-0030.html#info" rel="nofollow">information about a XMPP entity.</a></li> <li><code>#item</code> is used to discover <a href="http://xmpp.org/extensions/xep-0030.html#items" rel="nofollow">items associated with a XMPP entity.</a></li> </ul> <p><code>#info</code> query results will show you amongst others the supported features of a XMPP entity (e.g. <a href="http://xmpp.org/extensions/xep-0071.html#discovery-explicit" rel="nofollow">XHTML-IM support</a>).</p> <p><code>#item</code> query results will show the available items of a XMPP entity. For example the <a href="http://xmpp.org/extensions/xep-0045.html#disco-service" rel="nofollow">XEP-0045 MUC component</a> of a XMPP service. But any other available service/component could show up here.</p> <p>One could also say that <code>#info</code> is used to query the features of this particular entity, while <code>#items</code> is used to query for "sub-components" of that entity, which itself are usually be queried with <code>#info</code> for their features.</p> |
31,510,255 | 0 | <p>The problem with the date format is because you are converting it to a string and then back to a DateTime value. Depending on the culture settings on the specific server this may or may not work. It may also misinterpret the data, e.g. transforming a date from 2013-10-12 to 2013-12-10.</p> <pre><code>DateTime datet = new DateTime(year,month,day); startDateParam.Value = datet; endDateParam.Value = datet; </code></pre> <p>"note that the server stored datetime with format '1900-01-01 00:00:00.000'"</p> |
2,868,707 | 0 | <p>Check out <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="nofollow noreferrer">Scott Gu's Blog</a>.</p> <p>It will explain exactly how to do it.</p> |
3,727,398 | 0 | sql server stock quote every second <p>I have a table with stock quotes</p> <p>Symbol<br/> Ask<br/> Bid<br/> QuoteDateTime</p> <p>Using SQL Server 2008, lets say for any given 60 second time period I want to select quotes on all symbols so that there is a record for every second in that time period. </p> <p>Problem is not every symbol has the same number of quotes - so there are some seconds that have no quote record for any given symbol. So I want to fill in the missing holes of data. So if ORCL has quotes at second 1, 2, 3, 5, 7, I want the result set that has 1,2,3,4,5,6,7...up to 60 sec (covering the whole minute). The values in row 4 come from row 3</p> <p>In this scenario I would want to select the previous quote and use that for that particular second. So there is continuous records for each symbol and the same number of records are selected for each symbol.</p> <p>I am not sure what this is called in sql server but any help building a query to do this would be great</p> <p>For output I am expecting that for any given 60 sec time period. For those symbols that have a record in the 60 seconds, there will be 60 records for each symbol, one for each second</p> <p>Symbol Ask Bid QuoteDateTime</p> <p>MSFT 26.00 27.00 2010-05-20 06:28:00<br/> MSFT 26.01 27.02 2010-05-20 06:28:01<br/> ...<br/> ORCL 26.00 27.00 2010-05-20 06:28:00<br/> ORCL 26.01 27.02 2010-05-20 06:28:01<br/></p> <p>etc</p> |
29,674,087 | 0 | <p>One of the ways to do this could be create "anchor" table from all possible data from all three tables and then use <code>left outer join</code>:</p> <pre><code>select A.column2, B.column2, C.column2 from ( select distinct month from table1 union select distinct month from table2 union select distinct month from table3 ) as X left outer join table1 as A on A.month = X.month left outer join table2 as B on B.month = X.month left outer join table3 as C on C.month = X.month </code></pre> |
28,957,173 | 0 | <p>No need to add custom packet listener to connection object.</p> <p>get all rosters from server</p> <pre><code>Roster roster = mConnection.getRoster(); // collection of RosterEntry from roster object Collection<RosterEntry> entries= roster.getEntries(); for(RosterEntry entry : entries) { Log.i("RosterName", "Name : "+ entry.getName()); Log.i("RosterName", "Name : "+ entry.getUser()); } </code></pre> |
29,044,041 | 0 | Is there a way to use UITextField's on a dynamic UITableView, AND 'tab' between them? <p>This may be a tad lengthy, but bear with me. It's mostly simple code and log output. Normally, if I wanted to have a UITextField as a part of a UITableViewCell, I would likely use either a) static rows or b) I would create the cell in the storyboard, outlet the cell and outlet the field to my ViewController, and then drag the cell outside of the "Table View", but keeping it in the scene. </p> <p>However, I need to create a View where I accept input from 28 various things. I don't want to outlet up 28 different UITextField's. </p> <p>I want to do this dynamically, to make it easier. So I've created a custom UITableViewCell with a Label and UITextField.</p> <p>My ViewController has two arrays. </p> <pre><code>@property (nonatomic, strong) NSArray *items; @property (nonatomic, strong) NSArray *itemValues; </code></pre> <p>My <code>cellForRowAtIndexPath</code> looks something like this...</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cellIdentifier = @"ItemCell"; MyItemTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; if (!cell) { cell = [[MyItemTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; cell.categoryValue.tag = indexPath.row; cell.categoryValue.delegate = self; } cell.item.text = [self.items objectAtIndex:indexPath.row]; cell.itemValue.text = [self.itemValues objectAtIndex:indexPath.row]; return cell; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { NSInteger tag = [textField tag]; NSLog(@"TFSR tag: %zd/%zd", tag, self.categories.count-1); if (tag < (self.categories.count - 1)) { NSIndexPath *nextIndex = [NSIndexPath indexPathForRow:tag+1 inSection:0]; NSLog(@"TFSR nextRow: %zd/%zd\n", nextIndex.row); FFFCategoryTableViewCell *cell = (MyItemTableViewCell *)[self.tableView cellForRowAtIndexPath:nextIndex]; [self.tableView scrollToRowAtIndexPath:nextIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; [cell.categoryValue becomeFirstResponder]; } else { NSLog(@"DONE!"); } return YES; } </code></pre> <p>This is proving to be problematic. The goal is, the user should be able to select the UITextField on the first row, enter a value, and when they hit the 'Next' key on the keyboard, they will be sent to the UITextField on the second row. Then 3rd, 4th,... 27th, 28th.</p> <p>However, let's say I first highlight the UITextField on the Cell with IndexPath.row = 11. If I tap 'Next', this is what my output looks like...</p> <pre><code>======== OUTPUT ======== TFSR tag: 11/27 TFSR nextRow: 12/27 TFSR tag: 12/27 TFSR nextRow: 13/27 TFSR tag: 13/27 TFSR nextRow: 14/27 TFSR tag: 0/27 TFSR nextRow: 1/27 </code></pre> <p>Now I fully understand why this is happening. With UITableView trying to save memory in loading various cells, and with the use of dequeueReusableCellWithIdentifier... I only have 14 cells (0-13). Then it loops back to the beginning.</p> <p>My problem is... I don't know a solution to this problem. I want the user to be able to his Next until the 28th UITextField row. </p> <p>Any ideas/solutions on how I could achieve this?</p> |
13,799,027 | 0 | <p>Are you sure the font is loaded correctly?</p> <p>You can try:</p> <pre><code>for (NSString *familyName in [UIFont familyNames]) { NSLog(@"%@", familyName); for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { NSLog(@"\t%@",fontName); } } </code></pre> <p>This will show you all the fonts that are loaded. Make sure the same name "Cabin-Regular" is showing up exactly the same. A lot of times the font itself isn't loaded and then the font-size won't be used at all.</p> |
2,733,441 | 0 | <p>Use the <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.selectmany(v=VS.90).aspx" rel="nofollow noreferrer"><code>SelectMany</code></a> extension method:</p> <pre><code>List<List<int>> lists = new List<List<int>>() { new List<int>(){1, 2}, new List<int>(){3, 4} }; var result = lists.SelectMany(x => x); // results in 1, 2, 3, 4 </code></pre> <p>Or, for your specific case:</p> <pre><code>var performancePanels = new { Panels = (from panel in doc.Elements("PerformancePanel") select new { LegalTextIds = (from legalText in panel.Elements("LegalText").Elements("Line") select new List<int>() { (int)legalText.Attribute("id") }).SelectMany(x => x) }).ToList() }; </code></pre> |
18,988,095 | 0 | <p>Consider using <code>NSUserDefaults</code> for storing single values</p> <p><em>For Storing:</em></p> <pre><code>[[NSUserDefaults standardUserDefaults] setInteger:100 forKey:@"storageKey"]; </code></pre> <p><em>For Retrieving:</em></p> <pre><code>NSInteger myValue = [[NSUserDefaults standardUserDefaults] integerForKey:storageKey]; </code></pre> |
2,340,952 | 0 | <tbody> glitch in PHP Simple HTML DOM parser <p>I'm using PHP Simple HTML DOM Parser to scrape some data of a webshop (also running XAMPP 1.7.2 with PHP5.3.0), and I'm running into problems with <code><tbody></code> tag. The structure of the table is, essentialy (details aren't really that important):</p> <pre><code><table> <thead> <!--text here--> </thead> <tbody> <!--text here--> </tbody> </table> </code></pre> <p>Now, I'm trying to get to the <code><tbody></code> section by using code:</p> <pre><code>$element = $html->find('tbody',0)->innertext; </code></pre> <p>It doesn't throw any errors, it just prints nothing out when I try to echo it. I've tested the code on other elements, <code><thead></code>, <code><table></code>, even something like <code><span class="price"></code> and they all work fine (ofcourse, removing ",0" fails the code). They all give their correct sections. Outertext ditto. But it all fails on <code><tbody></code>.</p> <p>Now, I've skimmed through the Parser, but I'm not sure I can figure it out. I've noticed that <code><thead></code> isn't even mentioned, but it works fine. <em>shrug</em></p> <p>I guess I could try and do child navigation, but that seems to glitch as well. I've just tried running:</p> <pre><code>$el = $html->find('table',0); $el2 = $el->children(2); echo $el2->outertext; </code></pre> <p>and no dice. Tried replacing <code>children</code> with <code>first_child</code> and 2 with 1, and still no dice. Funny, though, if I try <code>->find</code> instead of <code>children</code>, it works perfectly.</p> <p>I'm pretty confident I could find a work-around the whole thing, but this behaviour seems odd enough to post here. My curious mind is happy for all the help it can get.</p> |
40,341,145 | 0 | Can run_loop use a different identifier for resigning DeviceAgent-Runner.app <p>Setup:</p> <ul> <li>Xcode 8</li> <li>OSX El Capitan (10.11.6)</li> <li>Physical iPhone6 (iOS 9.1)</li> <li>calabash-cucumber 0.20.3</li> <li>Run_loop 2.2.2</li> </ul> <p>First I tried to start the calabash console on the physical phone, but because it didn't have the <strong>DeviceAgent-Runner.app</strong> app it tried to install it.</p> <pre><code>calabash-ios 0.20.3> start_test_server_in_background EXEC: xcrun simctl list devices --json EXEC: xcrun instruments -s devices DEBUG: HTTP: get http://10.57.39.140:27753/1.0/health {:retries=>1, :timeout=>0.5} DEBUG: Waiting for DeviceAgent to launch... EXEC: cd /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent EXEC: ditto -xk Frameworks.zip . EXEC: ditto -xk DeviceAgent-Runner.app.zip . EXEC: /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager install --device-id e544a153544294d3a9bcce89cecb17161d528baa --app-bundle /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app --codesign-identity iPhone Developer: name@gmail.com (P536D9MXXX) with a timeout of 60 from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/shell.rb:104:in `run_shell_command' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/ios_device_manager.rb:124:in `launch' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:1233:in `launch_cbx_runner' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:264:in `launch' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/client.rb:140:in `run' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop.rb:113:in `run' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:408:in `block in new_run_loop' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:406:in `times' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:406:in `new_run_loop' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/launcher.rb:365:in `relaunch' from /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/calabash-cucumber-0.20.3/lib/calabash-cucumber/core.rb:1567:in `start_test_server_in_background' from (irb):1 from /Users/stefan/.rbenv/versions/2.2.3/bin/irb:11:in `<main>' </code></pre> <p>As you can see it fails to install the <strong>DeviceAgent-Runner.app</strong> app with a timeout.</p> <p>Then I tried to install the DeviceAgent-Runner.app manualy</p> <pre><code>MACC02MK1XBFD59:CalabashVerification stefan$ /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager install --device-id e544a153544294d3a9bcce89cecb17161d528baa --app-bundle /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/ipa/DeviceAgent-Runner.app --codesign-identity "iPhone Developer: name@gmail.com (P536D9MXXX)" objc[47805]: Class DDLog is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDLoggerNode is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDLogMessage is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDAbstractLogger is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDAbstractDatabaseLogger is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDTTYLogger is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDTTYLoggerColorProfile is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDLogFileManagerDefault is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDLogFileFormatterDefault is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDFileLogger is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDLogFileInfo is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. objc[47805]: Class DDASLLogger is implemented in both /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/Frameworks/FBControlCore.framework/Versions/A/Frameworks/CocoaLumberjack.framework/Versions/A/CocoaLumberjack and /Users/stefan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/run_loop-2.2.2/lib/run_loop/device_agent/bin/iOSDeviceManager. One of the two will be used. Which one is undefined. 2016-10-31 12:09:12.495 iOSDeviceManager[47805:7626359] [MT] DVTPlugInManager: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for KSImageNamed.ideplugin (com.ksuther.KSImageNamed) not present 2016-10-31 12:09:12.638 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/xcfui.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.639 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/RTImageAssets.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.639 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/PrettyPrintJSON.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.640 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/OMColorSense.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.640 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/KSImageNamed.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.641 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/DebugSearch.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.641 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPods.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:12.642 iOSDeviceManager[47805:7626359] [MT] PluginLoading: Required plug-in compatibility UUID DA4FDFD8-C509-4D8B-8B55-84A7B66AE701 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2016-10-31 12:09:20.201 iOSDeviceManager[47805:7626359] EXEC: /usr/bin/xcrun security find-identity -v -p codesigning 2016-10-31 12:09:50.203 iOSDeviceManager[47805:7626359] Could not find valid codesign identities with: /usr/bin/xcrun security find-identity -v -p codesigning 2016-10-31 12:09:50.203 iOSDeviceManager[47805:7626359] Command timed out after 30.0009800195694 seconds 2016-10-31 12:09:50.203 iOSDeviceManager[47805:7626359] ERROR: The signing identity you provided is not valid: iPhone Developer: name@gmail.com (P536D9MXXX) 2016-10-31 12:09:50.203 iOSDeviceManager[47805:7626359] ERROR: 2016-10-31 12:09:50.203 iOSDeviceManager[47805:7626359] ERROR: These are the valid signing identities that are available: 2016-10-31 12:09:50.203 iOSDeviceManager[47805:7626359] EXEC: /usr/bin/xcrun security find-identity -v -p codesigning 2016-10-31 12:10:20.204 iOSDeviceManager[47805:7626359] Could not find valid codesign identities with: /usr/bin/xcrun security find-identity -v -p codesigning 2016-10-31 12:10:20.204 iOSDeviceManager[47805:7626359] Command timed out after 30.00082302093506 seconds 2016-10-31 12:10:20.206 iOSDeviceManager[47805:7626359] Error creating product bundle for /var/folders/yy/vvrqrp2n6qv9b_tbssf_74n80000gn/T/59E25CB1-38F5-4269-B950-0040BACB2E00-47805-000048155108503C/DeviceAgent-Runner.app: Error Domain=com.facebook.XCTestBootstrap Code=0 "Failed to codesign /var/folders/yy/vvrqrp2n6qv9b_tbssf_74n80000gn/T/59E25CB1-38F5-4269-B950-0040BACB2E00-47805-000048155108503C/DeviceAgent-Runner.app" UserInfo={NSLocalizedDescription=Failed to codesign /var/folders/yy/vvrqrp2n6qv9b_tbssf_74n80000gn/T/59E25CB1-38F5-4269-B950-0040BACB2E00-47805-000048155108503C/DeviceAgent-Runner.app, NSUnderlyingError=0x7fbfef6127f0 {Error Domain=sh.calaba.iOSDeviceManger Code=5 "Could not resign with the given arguments" UserInfo={NSLocalizedDescription=Could not resign with the given arguments, NSLocalizedFailureReason=The device UDID and code signing identity were invalid forsome reason. Please check the logs.}}} install -u,--update-app <true-or-false> [OPTIONAL] When true, will reinstall the app if the device contains an older version than the bundle specified DEFAULT=1 -c,--codesign-identity <codesign-identity> [OPTIONAL] Identity used to codesign app bundle [device only] DEFAULT= -a,--app-bundle <path/to/app-bundle.app> Path .app bundle (for .ipas, unzip and look inside of 'Payload') -d,--device-id <device-identifier> iOS Simulator GUID or 40-digit physical device ID </code></pre> <p>Which gave me at least some more info, as it said it is related to code singing. I am sure that my certificats are valid. So my open questions:</p> <ul> <li>Can I tell run_loop to use a different identifier for resigning DeviceAgent-Runner.app, because I can't use a wildcard certificate (company policy).</li> <li><p>Or any other ideas how to continue from this point</p> <p>Thanks!</p></li> </ul> |
4,134,721 | 0 | <p>The php code you show (which really just sends the work to convert in a shell) does not check to see if the images have alpha channels, it just takes whatever file is given and turns it on. If it already had one there would be no file change, but convert is not being asked to make any decision based on the status, just go ahead and add the channel.</p> |
24,952,969 | 0 | RadEditor is not working in IE11 <p>I am working on <code>Telerik RadEditor</code> control but it is not working in <code>IE11</code> although it is working fine in <code>IE8</code>. Below tag, I am using to work with <code>IE9</code> and <code>IE10</code> and It works </p> <pre><code>meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> </code></pre> <p>But, When I use <code>IE11</code> then RadEditor is not showing in proper format. </p> <pre><code>Namespace="Telerik.WebControls" Assembly="RadEditor.Net2" </code></pre> <p>Can someone tell me, what is the problem with <code>IE11</code></p> |
17,459,810 | 0 | <p>Your question is not clear enough, However lets say that the code above is working. </p> <p>You want to add the result every time you preforms this operation (I assume).<br> again assuming you're using windows forms.<br> put a comboBox on your form. </p> <p>then when preforming the operation you need to keep a list of what you got before then use it as dataSource for the comboBox. The code below demonstrate this:</p> <pre><code> List<string> dataList = new List<string>(); // this line is global not inside a closed scoop var myDataTable = new System.Data.DataTable(); using (var conection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;" + "data source="+foldername+"\\Program\\Ramdata.mdb;Jet OLEDB:Database Password=****")) { conection.Open(); var query = "Select u_company From t_user"; var command = new System.Data.OleDb.OleDbCommand(query, conection); var reader = command.ExecuteReader(); while (reader.Read()) { profselect.Text = reader[0].ToString(); dataList.Add(profselect.Text); } } myComboBox.DataSource = dataList; myComboBox.SelectedText = dataList.Last(); </code></pre> <p>that as far as I can help with this much information you gave. </p> |
36,683,726 | 0 | Failed to find Build Tools revision 23.0.1 <p>Hello i am trying to build my first app with react-native. I am following this 2 tutorial: <a href="https://facebook.github.io/react-native/docs/getting-started.html#content" rel="nofollow noreferrer">https://facebook.github.io/react-native/docs/getting-started.html#content</a> <a href="https://facebook.github.io/react-native/docs/android-setup.html" rel="nofollow noreferrer">https://facebook.github.io/react-native/docs/android-setup.html</a> I am sure that i installed all the required things in the second link and when i try running my app with "react-native run-android" I get the following error: <a href="https://i.stack.imgur.com/RBAfL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RBAfL.jpg" alt="Error"></a></p> <p>I executed this command while I am running genymotion. This is all that i have installed in android sdk.</p> <p><a href="https://i.stack.imgur.com/TsXGk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TsXGk.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/MPQEj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MPQEj.jpg" alt="enter image description here"></a></p> <p>I tried to install Android build tools 23.0.1 but i get this: <a href="https://i.stack.imgur.com/07SY9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/07SY9.jpg" alt="enter image description here"></a></p> <p>Any help or advice I would be very grateful Thanks!</p> |
35,669,173 | 0 | Clojure destructure map using :keys with qualified keywords not working <p>I've tried this with both 1.7.0 and 1.8.0 and it appears that Clojure does not destructure maps using <code>:keys</code> whose keys are fully qualified. I don't think it has to do with being in the tail on the arguments as it doesn't work when I switch around the function argument positions as well.</p> <pre><code>(ns foo.sandbox) (def foo ::foo) (def bar ::bar) (defn normalize-vals [mmap & [{:keys [foo bar] :as ops}]] (println "normalize-vals " ops " and foo " foo " bar" bar)) (normalize-vals {} {foo 1 bar 2}) => normalize-vals {:foo.sandbox/foo 1, :foo.sandbox/bar 2} and foo nil bar nil </code></pre> <p>However; this works:</p> <pre><code> (defn normalize-vals [mmap & [{a foo b bar :as ops}]] (println "normalize-vals " ops " and foo " a " bar" b)) (normalize-vals {} {foo 1 bar 2}) => normalize-vals {:cmt.sandbox/foo 1, :cmt.sandbox/bar 2} and foo 1 bar 2 </code></pre> <p>Is this a defect?</p> |
9,728,419 | 0 | <p>It depends if you are using any MVVM model or not.</p> <p>My suggestion, if you are not using a MVVM, is to use Blend Sample data, is fast and quick.</p> <p>If you are MVVM Light I've found very usefull to create two files: DataService.cs - contains the real connection and data DesignDataService.cs - contains the sample data</p> <p>The two libraries are identical, from an call perspective so that in the ViewModelLocator you can swap them:</p> <pre class="lang-csh prettyprint-override"><code> if (ViewModelBase.IsInDesignModeStatic) { SimpleIoc.Default.Register<IDataService, Design.DesignDataService>(); } else { //SimpleIoc.Default.Register<IDataService, Design.DesignDataService>(); SimpleIoc.Default.Register<IDataService, DataService>(); } </code></pre> <p>In the Design class I've decided to create an XML file for each Model so that it's easy to change the sample data and test all possible scenarios.</p> <p>I then use the Deserialize function to read it:</p> <pre class="lang-csh prettyprint-override"><code> csNodeList _Copyrights = new csNodeList(); resource = System.Windows.Application.GetResourceStream(new Uri(@"Design/sampledata.xml", UriKind.Relative)); streamReader = new StreamReader(resource.Stream); serializer = new XmlSerializer(typeof(csNodeList)); _Copyrights = (csNodeList)serializer.Deserialize(streamReader); </code></pre> <p>Please note that the file sampledata.xml has to be stored in folder Design and must be defined as Content not as Resource. It is suggested to improve performance and load time.</p> <p>M</p> |
13,269,086 | 0 | <pre><code>LabelField RateDeal = new LabelField("Rating: "); HorizontalFieldManager StarManager=new HorizontalFieldManager(USE_ALL_WIDTH); final Bitmap StarNotClicked = Bitmap.getBitmapResource("rating_star.png"); final Bitmap StarClicked = Bitmap.getBitmapResource("rating_star_focus.png"); Star1 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){ protected boolean navigationClick(int status, int time){ fieldChangeNotify(1); Star1.setBitmap(StarClicked); Star2.setBitmap(StarNotClicked); Star3.setBitmap(StarNotClicked); Star4.setBitmap(StarNotClicked); Star5.setBitmap(StarNotClicked); AmountOfStarsSelected(1); return true; } }; Star2 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){ protected boolean navigationClick(int status, int time){ fieldChangeNotify(1); Star1.setBitmap(StarClicked); Star2.setBitmap(StarClicked); Star3.setBitmap(StarNotClicked); Star4.setBitmap(StarNotClicked); Star5.setBitmap(StarNotClicked); AmountOfStarsSelected(2); return true; } }; Star3 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){ protected boolean navigationClick(int status, int time){ fieldChangeNotify(1); Star1.setBitmap(StarClicked); Star2.setBitmap(StarClicked); Star3.setBitmap(StarClicked); Star4.setBitmap(StarNotClicked); Star5.setBitmap(StarNotClicked); AmountOfStarsSelected(3); return true; } }; Star4 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){ protected boolean navigationClick(int status, int time){ fieldChangeNotify(1); Star1.setBitmap(StarClicked); Star2.setBitmap(StarClicked); Star3.setBitmap(StarClicked); Star4.setBitmap(StarClicked); Star5.setBitmap(StarNotClicked); AmountOfStarsSelected(4); return true; } }; Star5 = new BitmapField(StarNotClicked,BitmapField.FOCUSABLE){ protected boolean navigationClick(int status, int time){ fieldChangeNotify(1); Star1.setBitmap(StarClicked); Star2.setBitmap(StarClicked); Star3.setBitmap(StarClicked); Star4.setBitmap(StarClicked); Star5.setBitmap(StarClicked); AmountOfStarsSelected(5); return true; } }; StarManager.add(Star1); StarManager.add(Star2); StarManager.add(Star3); StarManager.add(Star4); StarManager.add(Star5); add(StarManager); </code></pre> |
31,307,335 | 0 | <p>If you're using AngularJS and already have a build step, <a href="https://www.npmjs.com/package/gulp-ng-html2js" rel="nofollow">html2js</a> could help you with turning HTML templates into JS, which can then be concat'd and minified.</p> |
17,487,809 | 0 | Sort table by reputation and select rank + LIMIT to print above and below rows <p>I am trying to sort the table by the reputation and then select the position of the row [rank], it works fine, but I would like to print out 3 tables above and 3 tables below this rank row, but LIMIT rank,6 does not work :/ (Im sorry for that wrong formatted SQL :/) Would be thankful for every help :)</p> <p>Here is what is working:</p> <pre><code>$query = mysqli_query($con, "SET @rank=0"); $query = mysqli_query($con, " SELECT rank, user_email, reputation FROM ( SELECT @rank:=@rank+1 AS rank, user_email, reputation FROM accounts, (SELECT @rank := 0) r ORDER BY reputation DESC LIMIT 0,7 ) t WHERE reputation >= '5' OR reputation < '5'"); </code></pre> <p>prints </p> <pre><code>[rank] [user_email] [reputation] 1 mail1@gmail.com 20 2 test@test.com 15 3 mail2@gmail.com 10 4 othermail@gmail.com 5 5 hmmmmm@gmail.com 0 6 ouch@gmail.com 0 7 somemail@gmail.com 0 </code></pre> |
18,802,773 | 0 | Android doesn't deliver correct PHOTO_URI <p>I am using a <code>QuickContactBadge</code>. Now I get this messages on a Sony Xperia P. I developed the app on CyanogenMod and eveything was fine.</p> <pre><code>Unable to open content: content://com.android.contacts/contacts/939/photo java.io.FileNotFoundException: content://com.android.contacts/contacts/939/photo </code></pre> <p>This is my code:</p> <pre><code>projection = new String[] { ContactsContract.CommonDataKinds.Phone._ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone.PHOTO_URI }; contactCursor = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, null, null, null); ... thumbnail = contactCursor.getString(contactCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI)); ... quickContactBadge.setImageURI(Uri.parse(ThumbnailString)); </code></pre> <p>My suggestion was that the Sony ROM doesn't deliver an valid PHOTO_URI but it looks legit.</p> |
21,879,242 | 0 | <p>The unique event count for an action is the number of visits in which that action took place.</p> <p>The total unique events in this report should equal the sum of unique events on all rows, not the number of rows. This is because a unique event is based on unique action-visit combinations, and each row has a different action.</p> <p>In other words, if an action is repeated within a visit, the unique event count is not incremented, but otherwise it is.</p> <p>So if one of the rows has 2 unique events that would mean that the event action was triggered in 2 separate visits, and both these visits would be included in the overall unique events.</p> <p>In your example, the first 10 actions in your report only occurred for 1 visit each (they may even have all been the same visit - you can't tell from this report).</p> <p>So I'm guessing that on the second page of your example there are two rows with 0 unique events, and the rest have 1 unique event - so that they add up to 21 unique events.</p> |
29,399,590 | 0 | <p>Yes, you can do this, but it needs to be done through a separate mechanism than the <code>c</code> argument. In a nutshell, use <code>facecolors=rgb_array</code>.</p> <hr> <p>First off, let me explain what's going on. The <code>Collection</code> that <code>scatter</code> returns has two "systems" (for lack of a better term) for setting colors.</p> <p>If you use the <code>c</code> argument, you're setting the colors through the <code>ScalarMappable</code> "system". This specifies that the colors should be controlled by applying a colormap to a single variable. (This is the <code>set_array</code> method of anything that inherits from <code>ScalarMappable</code>.)</p> <p>In addition to the <code>ScalarMappable</code> system, the colors of a collection can be set independently. In that case, you'd use the <code>facecolors</code> kwarg.</p> <hr> <p>As a quick example, these points will have randomly specified rgb colors:</p> <pre><code>import matplotlib.pyplot as plt import numpy as np x, y = np.random.random((2, 10)) rgb = np.random.random((10, 3)) fig, ax = plt.subplots() ax.scatter(x, y, s=200, facecolors=rgb) plt.show() </code></pre> <p><img src="https://i.stack.imgur.com/PTY2v.png" alt="enter image description here"></p> |
14,615,048 | 0 | <p>Can you give a rating with a number keystroke?</p> <pre><code>tell application "System Events" to keystroke "5" </code></pre> |
18,888,969 | 0 | <p>Yeh I got it, thanks @jeff for the clue, here is the answer.</p> <p>remove the "echo" error from the string</p> <pre><code> { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } </code></pre> <p>its look like this;;</p> <pre><code> { . mysqli_connect_error(); } </code></pre> |
26,389,463 | 0 | Customize table with jquery <p>I want to design a customize table layout. For example after adding data my table is created. Now I am showing column name in one column and column data in another column, I want to add functionality if I drag one row to third column, Then column structure will be modified and that row will be added to new column.</p> <p>For example: This is my table: <a href="http://jsfiddle.net/x8L57md2/" rel="nofollow">jsfiddle.net/x8L57md2/</a></p> <p>code:- </p> <pre><code> <tr> <td>Name</td> <td> Ankur </td> </tr> <tr> <td>Address</td> <td>jaipur</td> </tr> <tr> <td>State</td> <td> Rajasthan</td> </tr> <tr> <td>Country</td> <td>India</td> </tr> <table> </code></pre> <p>If I move state column to right side of ankur(name) then another table column will be created and append it to table with data.</p> <p>Like this: <a href="http://jsfiddle.net/ttzr2ezh/" rel="nofollow">jsfiddle.net/ttzr2ezh/</a></p> <p>code:-</p> <pre><code> <table border="1"> <tr> <td>Name</td> <td> Ankur </td> <td>State</td> <td> Rajasthan</td> </tr> <tr> <td>Address</td> <td>jaipur</td> </tr> <tr> <td>Country</td> <td>India</td> </tr> <table> </code></pre> |
8,892,831 | 1 | How to emulate os.path.samefile behaviour on Windows and Python 2.7? <p>Given two paths I have to compare if they're pointing to the same file or not. In Unix this can be done with <code>os.path.samefile</code>, but as documentation states it's not available in Windows. What's the best way to emulate this function? It doesn't need to emulate common case. In my case there are the following simplifications:</p> <ul> <li>Paths don't contain symbolic links.</li> <li>Files are in the same local disk.</li> </ul> <p>Now I use the following:</p> <pre><code>def samefile(path1, path2) return os.path.normcase(os.path.normpath(path1)) == \ os.path.normcase(os.path.normpath(path2)) </code></pre> <p>Is this OK?</p> |
38,269,664 | 0 | How to improve resized image quality in gtk+3 c? <p>I use this code for resize an image in gtk+3 c:</p> <pre><code>void set_img_zoom() { GdkPixbuf *img1buffer_resized; img1buffer_resized = gdk_pixbuf_scale_simple(img1buffer, width, height, GDK_INTERP_NEAREST); gtk_image_set_from_pixbuf(GTK_IMAGE(img1), img1buffer_resized); //set crop area to zero dest_width = 0; dest_height = 0; } </code></pre> <p>This is my oroginal image:</p> <p><a href="https://i.stack.imgur.com/1tmeA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1tmeA.png" alt="enter image description here"></a></p> <p>but when size of image is big, the image quality is disturbed when I resize it:</p> <p><a href="https://i.stack.imgur.com/8qqkV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8qqkV.png" alt="enter image description here"></a></p> <p>I change <code>GDK_INTERP_NEAREST</code> to another but it doesn't well done. how to improve it?</p> |
38,586,206 | 0 | <p>Got the answer:</p> <p>When trying to upload file using IE, its taking my filename as <code>C:\Users\user_name\Downloads\myfile.csv</code> instead of <code>myfile.csv</code></p> <p>so replaced <code>this.GetCmp<FileUploadField>("FileUpload").PostedFile.FileName</code> with <code>Path.GetFileName(this.GetCmp<FileUploadField>("FileUpload").PostedFile.FileName)</code> in <code>client.UploadFile(..)</code> above.</p> |
23,780,917 | 0 | <pre><code>awk '{print $1,$2,$10,$8}' file </code></pre> |
241,765 | 0 | <p>My company is using Amazon EC2 now and I am down at the PDC watching the details on Azure unfold. I have not seen anything yet that would convince us to move away from Amazon. Azure definitely looks compelling, but the fact is I can now utilize Windows and SQL server on Amazon with SLAs in place. Ray Ozzie made it clear that Azure will be changing A LOT based on feedback from the developer community. However, Azure has a lot of potential and we'll be watching it closely.</p> <p>Also, Amazon will be adding load balancing, autoscaling and dashboard features in upcoming updates to the service (see this link: <a href="http://aws.amazon.com/contact-us/new-features-for-amazon-ec2/" rel="nofollow noreferrer">http://aws.amazon.com/contact-us/new-features-for-amazon-ec2/</a>). Never underestimate Amazon as they have a good headstart on Cloud Computing and a big user base helping refine their offerings already. Never underestimate Microsoft either as they have a massive developer community and global reach.</p> <p>Overall I do not think the cloud services of one company are mutually exclusive from one another. The great thing is that we can leverage all of them if we want to.</p> <p>Microsoft should offer up the ability to host Linux based servers in their cloud. That would really turn the world upside down!</p> |
16,821,194 | 0 | <p>This could happen when the Selenium Server version that you have does not support the Firefox browser version. Try using a stable compatible combination of Firefox Browser and Selenium Server.</p> |
17,191,465 | 0 | <p>Use <code>Base64.NO_WRAP</code> flag to strip line breaks</p> <p>Use 90 quality when compressing will greatly reduce the output size. the length of the output will be 4/3 times of the length of the byte array</p> |
1,687,326 | 0 | Unable to create snapshot of Canvas <p>In my application a canvas object has height = 90 px & width = 86400 px (indicating number of seconds in a day [60 * 60 * 24] ). The canvas is scrollable and the user can add or delete components in that.</p> <p>Now, I want to have snapshot of the whole canvas & shrink it to size 910x30 to draw taken snapshot in another canvas.</p> <p>Can anybody tell me how to take snapshot of such large Component?</p> <p>I have tried to take snapshot in BitmapData object but as it max width is 2880 can not give whole canvas snapshot.</p> <p>Is there any other Idea possible, if yes please let me know.</p> <p>Suggestions are welcome. </p> |
22,946,850 | 0 | Evolutionary Artificial Intelligence in Video Games <p>I had an idea pertaining to the use of Artificial Intelligence on a larger scale then most games. The idea is to train and score agents in a game against players, then the data is sent back to a server where it can be scored for fitness and then added to the pool for evolutionary selection. At that point the new agents would be redistributed to the players to be trained and scored by the players again.</p> <p>I am thinking this would be a good use for possibly a neural network or finite state machine that is evolved in a co-evolutionary manner (AI = predator, Players = prey). What I want to know is: </p> <p>1) Are there any papers or examples of this happening already in games? I haven't been able to find any examples.</p> <p>2) Does it seem like this approach would be any better then the traditional approach to AI in games?</p> <p>I am working on a Tactical Turn-based Strategy and thought that this could add a new dimension to gameplay if I can pull it off.</p> |
27,245,096 | 0 | <p>For a working doodle/proof of concept of an approach to utilize pure JavaScript along with the familiar and declarative pattern behind XSLT's matching expressions and recursive templates, see <a href="https://gist.github.com/brettz9/0e661b3093764f496e36" rel="nofollow">https://gist.github.com/brettz9/0e661b3093764f496e36</a></p> <p>(A similar approach might be taken for JSON.)</p> <p>Note that the demo also relies on JavaScript 1.8 expression closures for convenience in expressing templates in Firefox (at least until the ES6 short form for methods may be implemented).</p> <p>Disclaimer: This is my own code.</p> |
2,055,364 | 0 | <p><code>getText()</code> is returning null, so you're writing "null" down to the server. At least, that's what I found after changing your just enough to get it to compile and run.</p> <p>After changing <code>getText()</code> to return "hello" I got:</p> <p>Server:</p> <pre><code>Server is starting... Server is listening... Client Connected... </code></pre> <p>Client:</p> <pre><code>java.io.BufferedReader@7d2152e6 Text received: hello </code></pre> <p>(The "BufferedReader@7d..." line is due to <code>System.out.println(is);</code>)</p> <p>Note that after the client has disconnected, your server is going to keep trying to send "null" back to it, because you don't test for <code>line</code> being null in the server code.</p> |
11,923,689 | 0 | <p>You can implement an interface (say <code>Printable</code>) and use that interface as parameter type in your static method.</p> |
1,329,167 | 0 | <p>When you <code>require 'something'</code> Ruby searches for a file called either <code>something.rb</code> or <code>something.dll/so/bundle</code> depending on your platform.</p> <p>In case it finds a library <code>dll/so/bundle</code> it dynamically loads it and search for a symbol called <code>Init_something</code>. The convention when creating a native extension is to include such a function which gets used by the ruby interpreter to hook things up.</p> <p>Where (in which directories) the intrepeter looks for rb files and libs is determined by the load path, which you can append using the -I options of the interpreter. At runtime, the current load path is in <code>$:</code> (you can append further directories to this at runtime as well), for example:</p> <pre><code>$ irb irb(main):001:0> puts $: /opt/local/lib/ruby/site_ruby/1.8 /opt/local/lib/ruby/site_ruby/1.8/i686-darwin9 /opt/local/lib/ruby/site_ruby /opt/local/lib/ruby/vendor_ruby/1.8 /opt/local/lib/ruby/vendor_ruby/1.8/i686-darwin9 /opt/local/lib/ruby/vendor_ruby /opt/local/lib/ruby/1.8 /opt/local/lib/ruby/1.8/i686-darwin9 . </code></pre> <p>have a look at the documentation of require (<a href="http://ruby-doc.org/core-1.8.7/classes/Kernel.html#M001077" rel="nofollow noreferrer">http://ruby-doc.org/core-1.8.7/classes/Kernel.html#M001077</a>)</p> <p>I'm not sure what you mean by:</p> <blockquote> <p>P.S. The only exposed part of Ruby I have to work with right now is 'msvcrt-ruby18.dll'</p> </blockquote> <p>Also you mentioned something about sandboxing. This may interfere with your ability to require modules. Search for $SAFE, if $SAFE is set to >2 you won't be able to use <code>require</code> at all.</p> |
9,616,077 | 0 | <p>If your interests are machine learning, data mining and computer vision then I'd say a Lego mindstorms is not the best option for you. Not unless you are also interested in robotics/electronics.</p> <ul> <li>Do do interesting machine learning you only need a computer and a problem to solve. Think <a href="http://aichallenge.org/">ai-contest</a> or <a href="http://mlcomp.org/">mlcomp</a> or similar.</li> <li>Do do interesting data mining you need a computer, a lot of data and a question to answer. If you have an internet connection the amount of data you can get at is only limited by your bandwidth. Think <a href="http://www.netflixprize.com/">netflix prize</a>, try your hand at collecting and interpreting data from wherever. If you are learning, <a href="http://www.autonlab.org/tutorials/">this is a nice place to start</a>.</li> <li>As for computer vision: All you need is a computer and images. Depending on the type of problem you find interesting you could do some processing of <a href="http://www.opentopia.com/hiddencam.php">random webcam images</a>, take all you holiday photo's and try to detect <a href="https://en.wikipedia.org/wiki/Face_detection">where all your travel companions are</a> in them. If you have a webcam your options are endless.</li> </ul> <p>Lego mindstorms allows you to combine machine learning and computer vision. I'm not sure where the datamining would come in, and you will spend (waste?) time on the robotics/electronics side of things, which you don't list as one of your passions. </p> |
27,932,129 | 0 | <pre><code>{ "C:\\workspace\\folder\\test\\added.txt": "synced", "C:\\workspace\\folder\\test\\pending.test": "pending" } </code></pre> <p>Your JSON needs those backslashes escaped. Notice the \\</p> <p><a href="http://json.org/" rel="nofollow">http://json.org/</a></p> |
3,288,143 | 0 | <p>From the cocos2d <a href="http://github.com/cocos2d/cocos2d-iphone/blob/454d1753ea73b37dbde4d686a876a542a65e4677/tests/drawPrimitivesTest.m" rel="nofollow noreferrer">drawPrimitivesTest.m</a>:</p> <pre><code>- (void)draw { // ... // draw a simple line // The default state is: // Line Width: 1 // color: 255,255,255,255 (white, non-transparent) // Anti-Aliased glEnable(GL_LINE_SMOOTH); ccDrawLine( ccp(0, 0), ccp(s.width, s.height) ); // ... } </code></pre> |
13,993,694 | 0 | Jquery push all li's ID's into array <p>I need to push all my ID's into an array, both ways I've tried this only pushes the first ID into the array:</p> <pre><code> var some = []; $('ul#jdLists li').each(function () { some.push([$('ul#jdLists li').attr("id")]); }); </code></pre> <p>This returns the correct number of items in the array but with the ID of the first li</p> <p>or</p> <pre><code> var some = []; some.push([$('ul#jdLists li').attr("id")]); </code></pre> <p>this returns a single item with the first li ID</p> <p>thanks</p> |
26,851,521 | 0 | <p>You can replace enter keys with space in select statement, and then export to Excel</p> |
26,492,272 | 0 | <p>Sitecore has a special edition that was design for Azure. </p> <p><a href="http://www.sitecore.net/azure" rel="nofollow">Sitecore Azure Edition</a></p> |
18,845,404 | 0 | <p>template.Write(new FileStream("c:/path", FileMode.Create, FileAccess.ReadWrite));</p> |
19,743,559 | 0 | <p>EDIT: apparently this doesn't work, despite Google's documentation.</p> <p>According to <a href="http://developer.android.com/distribute/googleplay/promote/linking.html#android-app" rel="nofollow">developer.android's guide to Linking to Your Products</a>, if the HTML link to the app is <a href="http://play.google.com/store/apps/details?id=package_name" rel="nofollow">http://play.google.com/store/apps/details?id=package_name</a>, the corresponding Android link would be market://details?id=package_name. This should link users directly to a specific app's product details page on Google Play.</p> |
22,157,411 | 0 | Javascript drop list with images <p>I found this on one of the subjects: <a href="http://jsfiddle.net/GHzfD/357/" rel="nofollow">http://jsfiddle.net/GHzfD/357/</a> I would like to ask how to alert(path) after choose the image from drop list.</p> <pre><code><script> $("body select").msDropDown(); alert(???) </script> </code></pre> |
20,897,900 | 0 | <p><code>pip search</code> command does not show installed packages, but search packages in pypi.</p> <p>Use <code>pip freeze</code> command and <code>grep</code> to see installed packages:</p> <pre><code>pip freeze | grep Django </code></pre> |
28,529,215 | 0 | <p>in onCreateDialog, I forgot to set the listener: dialogObj.setOnShowListener(this).</p> |
28,608,911 | 0 | <p>This is a great use case for either <code>by</code> or <code>lapply</code> rather than a <code>for</code>-loop. Basically, the result is the same, but without the overhead of writing a loop, iterating over it, and storing the results appropriate. Here's a simple example like yours that uses the built-in <code>mtcars</code> dataset:</p> <pre><code>b <- by(mtcars, mtcars$gear, FUN = function(d) xtabs(~cyl + vs + am, data = d)) l <- lapply(split(mtcars, mtcars$gear), FUN = function(d) xtabs(~cyl + vs + am, data = d)) </code></pre> <p>We can use <code>str</code> to take a look at what we created:</p> <pre><code>> str(b, 1) List of 3 $ 3: xtabs [1:3, 1:2, 1] 0 0 12 1 2 0 ..- attr(*, "dimnames")=List of 3 ..- attr(*, "class")= chr [1:2] "xtabs" "table" ..- attr(*, "call")= language xtabs(formula = ~cyl + vs + am, data = d) $ 4: xtabs [1:2, 1:2, 1:2] 0 0 2 2 0 2 6 0 ..- attr(*, "dimnames")=List of 3 ..- attr(*, "class")= chr [1:2] "xtabs" "table" ..- attr(*, "call")= language xtabs(formula = ~cyl + vs + am, data = d) $ 5: xtabs [1:3, 1:2, 1] 1 1 2 1 0 0 ..- attr(*, "dimnames")=List of 3 ..- attr(*, "class")= chr [1:2] "xtabs" "table" ..- attr(*, "call")= language xtabs(formula = ~cyl + vs + am, data = d) - attr(*, "dim")= int 3 - attr(*, "dimnames")=List of 1 - attr(*, "call")= language by.data.frame(data = mtcars, INDICES = mtcars$gear, FUN = function(d) xtabs(~cyl + vs + am, data = d)) - attr(*, "class")= chr "by" > str(l, 1) List of 3 $ 3: xtabs [1:3, 1:2, 1] 0 0 12 1 2 0 ..- attr(*, "dimnames")=List of 3 ..- attr(*, "class")= chr [1:2] "xtabs" "table" ..- attr(*, "call")= language xtabs(formula = ~cyl + vs + am, data = d) $ 4: xtabs [1:2, 1:2, 1:2] 0 0 2 2 0 2 6 0 ..- attr(*, "dimnames")=List of 3 ..- attr(*, "class")= chr [1:2] "xtabs" "table" ..- attr(*, "call")= language xtabs(formula = ~cyl + vs + am, data = d) $ 5: xtabs [1:3, 1:2, 1] 1 1 2 1 0 0 ..- attr(*, "dimnames")=List of 3 ..- attr(*, "class")= chr [1:2] "xtabs" "table" ..- attr(*, "call")= language xtabs(formula = ~cyl + vs + am, data = d) </code></pre> <p>In this case, I think the result from <code>lapply</code> is probably closer to what you're going for, but (as you can hopefully see) the structures are very similar - both are lists of <code>xtabs</code> objects.</p> |
16,369,706 | 0 | <p>If it still crashes then try out</p> <p>move dword[stak],esp ;at the very start</p> <p>and end with</p> <p>mov esp,[stak]</p> <p>ret</p> <p>kinda thing</p> <p>gl</p> |
38,072,975 | 0 | <p><strong>NCover</strong> is a .Net tool for code coverage checking for .Net programs. You can use its latest version for both 32-bit and 64-bit operating systems. This tool can perform manual as well as automated code coverage tests for .Net programs. Using NCover may speed up your tests, providing you with nice and attractive multiple testing environments. Key Features: supports statement coverage and branch coverage, very fast tool, simple to use, provides better code quality, supports 32 & 64-bit OS, auto upgrade and update notifications for new service License: Floating License Latest Version: NCover 4.5.2745.646 Tool for: .Net programs Download NCover</p> <p><strong>Emma</strong> is a free and open source code coverage tool. Emma checks and reports for code coverage in a source code of a Java program. Emma can check code coverage for: class, method, line, package, etc. This code coverage tool is purely for Java programs. Among popular code coverage tools, it is a preferred choice of many users. Key Features: fast tool, good for large scale software development projects, ability to detect partially created source code line for code coverage, provide reports in plain text, HTML, and XML formats Developer(s): Vlad Roubtsov License: Common Public License Latest Version: Emma 2.1 Tool for: Java programs Platform Supported: Cross Platform Download Emma</p> <p><strong>OpenCover</strong> is a free and open source tool for code coverage checking for .Net programs. It checks for code coverage of tests in minimum time. OpenCover acquires less memory and can generate nice HTML, XML coverage reports. It is one of the best code coverage tools for generating nice output reports. Key Features: supports Silverlight, supports 32 & 64-bit OS, supports statement coverage and branch coverage, excellent coverage reports generation License: MIT Licence Latest Version: OpenCover 4.5.3207 Tool for: .Net programs Download NCover</p> <p>And some tools like</p> <ol> <li>Jester</li> <li>JVMDI Code Coverage Analyser</li> <li>PIT</li> </ol> |
19,483,833 | 0 | jQuery won't fade in span <p>I have some trouble fading in a span after hiding it and replacing it's contents.</p> <p>Here is my html before replacing it</p> <pre><code><span id="replace_with_editor"> <a id="edit_button" class="btn btn-success" href="thread.php">Post ny tråd</a> </span> </code></pre> <p>Here is my jQuery code</p> <pre><code>replace_with_editor = $('#replace_with_editor'); $('#edit_button').click(function(e) { e.preventDefault(); replace_with_editor.hide(); replace_with_editor.html('<form role="form" method="post" action="process/submit_thread.php"><div class="form-group"><label for="Title">Tittel</label><input id="thread_title" name="thread_title" type="text" class="form-control" placeholder="Skriv en tittel for tråden."></div><div class="form-group"><label for="Svar">Tråd</label><textarea id="thread_editor" name="thread_content" rows="10" class="form-control"></textarea></div><input type="hidden" value="category_id" name="category_id"><input type="hidden" value="forum_id" name="forum_id"><button type="submit" class="btn btn-success">Post tråd</button></form>'); replace_with_editor.fadeIn(2000); }); </code></pre> <p>For some reason when i try this script, the new content shows up but the fadeIn() doesnt work, it shows up instant.</p> <p>Any guess what i am doing wrong? Oh and the jQuery is not nested because of debugging. Any help is much appreciated.</p> |
16,350,841 | 0 | <p>Your code is somewhat confusing. Is MyTabBarController the class? It looks like mainTabVC is your instance. You should use that rather than the class, and you should change the type when you instantiate mainTabVC to MyTabBarController, instead of UITabBarController. You also don't need to get the storyboard the way you do, you can just use self.storyboard.</p> <pre><code> MyTabBarController *mainTabVC = [self.storyboard instantiateViewControllerWithIdentifier:@"mainTabVC"]; mainTabVC.managedObjectContext = self.managedObjectContext; [mainTabVC setModalPresentationStyle:UIModalPresentationFullScreen]; [self presentViewController:mainTabVC animated:NO completion:nil]; </code></pre> |
16,651,721 | 0 | <p>Since this post was made, there has been a third party tokenization service made available. Take a look at <a href="https://spreedly.com/" rel="nofollow">https://spreedly.com/</a>. I'm in the market for a similar solution currently.</p> |
17,935,377 | 0 | unexpected result from regular expression of url <p>I am trying to match one part in a url. This url has already been processed and consists of domain name only.</p> <p>For example:</p> <p>The url I have now is business.time.com Now I want to get rid of the top level domain(.com). The result I want is business.time</p> <p>I am using the following code:</p> <pre><code>gawk'{ match($1, /[a-zA-Z0-9\-\.]+[^(.com|.org|.edu|.gov|.mil)]/, where) print where[0] print where[1] }' test </code></pre> <p>In test, there are four lines:</p> <pre><code>business.time.com mybest.try.com this.is.a.example.org this.is.another.example.edu </code></pre> <p>I was expecting this :</p> <pre><code>business.time mybest.try this.is.a.example this.is.another.example </code></pre> <p>However, the output is</p> <pre><code>business.t mybest.try this.is.a.examp this.is.another.examp </code></pre> <p>Can anyone tell me what's wrong and what should I do?</p> <p>Thanks</p> |
34,074,507 | 0 | <p>I tried using the options above but didn't work. Try this: </p> <p><code>from statistics import mean</code></p> <pre><code>n = [11, 13, 15, 17, 19] print(n) print(mean(n)) </code></pre> <p>worked on python 3.5</p> |
31,688,717 | 0 | Cocoa launch application window <p>I need to implement in Cocoa a initial windows with information and logo of the company such like this:</p> <p><a href="https://i.stack.imgur.com/dkim1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dkim1.png" alt="enter image description here"></a></p> <p>My question for you guys is how can avoid showing the window bar:</p> <p><a href="https://i.stack.imgur.com/jc1Px.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jc1Px.png" alt="enter image description here"></a></p> <p>I'll really appreciate your help.</p> |
5,714,701 | 0 | How to open forms ussing keyboard keys <p>I would like to be able to press shift+D+A+L to open another form (form2) ussing VB.net how do i do this?</p> |
22,159,190 | 0 | <p>We solved this 10 minute timeout problem by implementing a small amount of Javascript which every 9 minutes sends an ajax request to a URL which sends back a new blob upload URL and swaps out the form.</p> <p>The <code>/ajax/blob</code> URL takes a success url, and then calls <code>create_upload_url()</code> and returns it as an ajax data object.</p> <p>Here's the Javascript we wrote:</p> <pre><code>if ($('#blobUploadForm').length > 0) { setTimeout(_getNewBlobstoreUrl, 9 * 1000 * 60 * 60); // 9 minutes } //do nothing if there is no uploadUrl id function _getNewBlobstoreUrl() { var successUrl = $('#uploadUrl').attr('value'); if (typeof successUrl == 'undefined') { return; } var url = "/ajax/blob?url=" + successUrl; $.ajax({ url: url, dataType: "json", cache: false, async: true, success: _getNewBlobstoreUrlSuccess, error: _getNewBlobstoreUrlError }) function _getNewBlobstoreUrlSuccess(data) { if (data.url) { //change the action to a new action $('#blobUploadForm').attr('action', data.url) } } function _getNewBlobstoreUrlError(err) { // do something } </code></pre> <p>Don't forget at the end to setup the timeout again too (or use setInterval?), in case the user takes a really long time to fill in the form.</p> |
32,208,030 | 0 | <p>I'm not sure what your code is doing but you can adapt it to this. Here is the general code that a recorded macro will show you.</p> <pre><code>'Selects everything on the current sheet and copies it Cells.Select Selection.Copy 'Add a new workbook. 'Adding a new workbook makes it the active workbook so you can paste to it. Workbooks.Add 'Paste the date using Paste:=xlPasteValues Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("C8").Select </code></pre> |
23,620,796 | 0 | <p>You probably want to create two functions in R:</p> <ul> <li><code>getdata</code>: a function that retrieves the data from your database, and returns the data frame.</li> <li><code>makeplot</code> : a function with a dataframe argument that creates your plot and returns nothing.</li> </ul> <p>Then your client you can call them separately. First the client calls <code>getdata</code> to retrieve the data from the db, and the server will respond with a temporary <code>{key}</code> that represents the returned dataframe object on the server, for example <code>x01234567</code>.</p> <p>Then you can use this key to either download the dataset or use it as an argument to create the plot. To download the data, simply create a hyperlink to for example:</p> <ul> <li><code>http://your.server.com/ocpu/tmp/x01234567/R/.val/csv</code></li> <li><code>http://your.server.com/ocpu/tmp/x01234567/R/.val/tab</code></li> <li><code>http://your.server.com/ocpu/tmp/x01234567/R/.val/json</code></li> </ul> <p>To create the plot, the client calls <code>makeplot</code> and passes <code>x01234567</code> as the argument value for the data frame. The <code>OpenCPU</code> server will automatically lookup the object for this key to the dataframe object that was returned before by <code>getdata</code>.</p> |
7,255,652 | 0 | <p>The easiest way to do this, is to get the StyledDocument from the JTextPane, and to use the setCharacterAttributes() method.</p> <p>The setCharacterAttributes method on the StyledDocument object allows you to set for a specific character range, a set of attributes, which can include BOLD.</p> <p>See the <a href="http://download.oracle.com/javase/1,5.0/docs/api/javax/swing/text/StyledDocument.html#setCharacterAttributes%28int,%20int,%20javax.swing.text.AttributeSet,%20boolean%29">Javadoc for more info</a></p> <p>Some sample code could be</p> <pre><code>// set chars 4 to 10 to Bold SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setBold(sas, true); textPane.getStyledDocument().setCharacterAttributes(4, 6, sas, false); </code></pre> |
33,618,760 | 0 | <p>You can't access data asset files in the same way you access a random file using <code>NSBundle.pathForResource</code>. Since they can only be defined within <code>Assets.xcassets</code>, you need to initialize a <code>NSDataAsset</code> instance in order to access the contents of it: </p> <pre><code>let asset = NSDataAsset(name: "Colors", bundle: NSBundle.mainBundle()) let json = try? NSJSONSerialization.JSONObjectWithData(asset!.data, options: NSJSONReadingOptions.AllowFragments) print(json) </code></pre> <p>Please note that <code>NSDataAsset</code> class was introduced as of iOS 9.0 & macOS 10.11.</p> <p><strong>Swift3 version:</strong></p> <pre><code>let asset = NSDataAsset(name: "Colors", bundle: Bundle.main) let json = try? JSONSerialization.jsonObject(with: asset!.data, options: JSONSerialization.ReadingOptions.allowFragments) print(json) </code></pre> <p>Also, NSDataAsset is surprisingly located in UIKit/AppKit so don't forget to import the relevant framework in your code:</p> <pre><code>#if os(iOS) import UIKit #elseif os(OSX) import AppKit #endif </code></pre> |