input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
R boolean statement <p>So, I'm doing an R code project for school, and there are 36 columns (9 related to column supercategory Exams, 8 related to Writing, 4 related to Collaboration, and 15 related to Other) of categorical variables each with the levels "1 time", "2-4 times", and ">4 times". I want to write a Boolean ... | <p>first I created some dummy data and add "0 times" in the possible levels:</p>
<pre><code>nam <- " factor(ifelse(((SurveyDataSP16$Exams_A==1 time|SurveyDataSP16$Exams_A==2-4 times|SurveyDataSP16$Exams_A==>4 times)|(SurveyDataSP16$Exams_B==1 time|SurveyDataSP16$Exams_B==2-4 times|SurveyDataSP16$Exams_B==>4 ... |
$http.post not woking in AngularJS <p>I'm trying to make a $http.post request but I have the following error:</p>
<blockquote>
<p>XMLHttpRequest cannot load <a href="https://mipage.com/examplephp" rel="nofollow">https://mipage.com/examplephp</a>. Request header field Content-Type is not allowed by Access-Control-All... | <p>The server to which the POST request is sent needs to include the <strong>Access-Control-Allow-Headers in its response</strong>.Putting them into you client has no effect.</p>
<p>It is up to the server to specify if it accepts the cross origin requests so the client cannot decide for itself if it permits the CORS.<... |
Invalid procedure call or argument in excel vba <p>I am using a filter on column1 of sheet1 with a unique no, get filtered values from column Z into an array (arr) object and paste those values as a string in one cell in "Dashboard" sheet. Repeat this process for all unique values on column 1 of sheet1. I am getting mu... | <p>Possible cause of this is the range length that you specified exceeds to the length of data you are calling on your code. </p>
|
Training loss and validation loss in convolutional auto encoder is not decreasing much <p>Why the training loss and validation loss in convolutional auto encoder is not decreasing. The training data is of dimension <code>10496x1024</code> and <code>CAE</code> is trained with <code>32x32</code> size image patches in <co... | <p>Your network is still learning, and is not slowing down so much at epoch 20. You can try a higher learning rate, and more epochs with an early stopping method if you have enough data.
This approach can be applied also with regularization methods and k-fold cross validation.</p>
|
Wordpress PHP variables in get_results() <p>I have a function that works fine when I say</p>
<pre><code>$results = $wpdb->get_results(
"SELECT meta_value
FROM wp_woocommerce_order_itemmeta
WHERE order_item_id = '21'
AND meta_key = '_qty"
... | <p>In this specific case I think it is a simple issue of missing white-space in your string concatenation. However there may be a more suitable way to prepare your statement that would have prevented this by making it easier to spot, and follows other good query building practices</p>
<p><strong>Wordpress Prepared Sta... |
storing a game score <p>I have this code in my playGame() which I call from <code>main</code>. The code below increments when either player, X / O, either wins or ties, but when I play my full game a second time, I loose my previous score.</p>
<p>Can someone suggest a more efficient way to store the scores? </p>
<p>D... | <p>Probably you should store the score value to temporary variable. Then after a new score, you should sum it up on the last score on your temporary variable.</p>
|
How to solve for the mean in an array without the max and min? <pre><code>public class FunWithArrays {
public static void main(String[] args) {
int[] myFunArray = {7, 10, 3, 0, 615, -1000};
int i;
//minimum
int min;
min = myFunArray[0];
for (i=0; i < myFunArray. length; i++) {
i... | <p>the answer to your second question is don't print using </p>
<pre><code>println
</code></pre>
<p>, just use <code>print</code></p>
<p>The code should be:</p>
<pre><code>System.our.print("Reversed: [")
for(int i1 = reversed.length - 1; i1 >= 0 ; i1--) {
System.out.print(reversed[i1]);
if(i1>0){
... |
Get HTML tag name from React element? <p>Is it possible to get an HTML tag name from a React element (return from a component)? For example:</p>
<pre><code>function Foo() {
return <span>Hello</span>;
}
</code></pre>
<p>The HTML tag name would be <code>span</code>. I know you can look into the <code>ty... | <p>No.</p>
<p>React Elements are a virtual construct, and they don't directly represent DOM elements. There are two types of React Elements - "regular" HTML DOM elements, and instantiations of a React Class. The first one has a "type" because it is extremely simple, stateless, and immutable, and is created only to ren... |
I added an area called home, moved my controller and view to it and now I can't connect to the index view <p>I already have controllers and views in folders under the project name. I added an Area folder and then an area inside it and called it Home and then moved my controller and index view into it. But when I connec... | <p>The 404 error shows the main problem itself: default routing and view engine search cannot found default <code>Index.cshtml</code> view file in <code>Views</code> directory on your project (i.e. <code>ProjectName/Views/Index.cshtml</code> pointed by route <code>~/Views/Home/Index</code>).</p>
<p>First, create a cla... |
Unit Testing Java Script - Fake XRM with QUnit <p>I have a <code>js</code> function which I want to unit test using <code>QUnit</code>. It is a simple function where I pass the field name that I want to hide from the form. I am also using a Mocking framework from here: [link] <a href="https://github.com/ambek/XrmPage-M... | <p>It was just a typo in the following statement: </p>
<p><code>assert.equal(XRM.page.getControl('NewField').getVisible(),false, 'Passsed');</code></p>
<p>The new statement is (Correction on the word "page")</p>
<p><code>assert.equal(XRM.Page.getControl('NewField').getVisible(),false, 'Passsed');</code></p>
|
The app crashes due to this reason <blockquote>
<p>Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array</p>
</blockquote>
| <p>You are accessing Empty array about to access object at index.</p>
<p>replace all places like in your code below:</p>
<pre><code>[arrMydata objectAtIndex:indexPath.row];
</code></pre>
<p>with</p>
<pre><code>//1. Positive index ([anArray objectAtIndex:-NUMBERS]) will crash
//2. within the array boundary
if([arr... |
How can I get the line-number of an error in a dynamically added <script> tag? <p>When dynamically creating a script element and adding it to the page, my errors are not giving me line numbers of the script, but instead the line number where I append the script. </p>
<p>The code below when in a .js file will give you... | <p>Got it. Adding a try catch around the code works great </p>
<pre><code>catchableScript = function(scriptText) {
var scriptText = "try {\n"+scriptText+"\n} \n catch(ex){console.log(ex.lineNumber-1)}";
var script = document.createElement("script");
script.innerHTML = scriptText;
document.head.appen... |
Error reading table into R <p>I am trying to read this <a href="https://d396qusza40orc.cloudfront.net/eureconometrics-assets/Dataset%20Files%20for%20On-Demand%20Course/Exercises%20and%20datasets/Module%203/TrainExer%203-1-corrected.txt" rel="nofollow">file</a> into an R dataframe but keep getting errors.</p>
<p>This i... | <p>You probably should be using <code>read.table</code> instead, since you're not loading in a csv. This might work: <code>data <- read.table("TrainExer 3-1-corrected.txt", header = TRUE)</code></p>
|
Python SQLite TypeError <pre><code>from sqlite3 import *
def insert_record(Who, Invented):
connection = connect(database = "activity.db")
internet = connection.cursor()
list = "INSERT INTO Information VALUES((Alexander_Graham, Phone))"
internet.execute(list)
rows_inserted = internet.rowcount
... | <p>insert record is a function that takes two required arguments, which you didn't pass values in for.</p>
<pre><code>command = insert_record
</code></pre>
<p>A good example of this in action is the following test sequence:</p>
<pre><code>In [1]: def func(one,two):
...: return one+two
...:
In [2]: func()... |
mysqli_select_db() expects parameter 1 to be mysqli, string given & mysqli_error() expects exactly 1 parameter, 0 given in DATABASE_CONNECT_ERROR <p>Ive searched on here and various other places and I just cannot find the answer to solve this problem. I just bought new hosting and am trying to move my sites. I am getti... | <p>First you no need to have "" for your DB connection as you pass it as variable and second is In MYSQLI always Pass <code>$connection</code> First.</p>
<p>And for a mysqli_error pass $connection to let server know you are looking for error in Database Connection.</p>
<p>Try this.</p>
<pre><code>$connect = mysqli_c... |
How to find the running time of these two functions? <p>I'm familiar with the big O notation and the running time and most of the time I can recognize the running time of an algorithm but I'm not sure with this one.
I'm dealing with a tree here.</p>
<p><strong>First method:</strong></p>
<pre><code>static boolean con... | <p>Both methods have a worst case running time of O(n) if the tree is not balanced.</p>
<p>The first would run in O(log n) if the tree is balanced.</p>
<p>The second method would still need O(n) even for balanced tree since it traverses both subtrees if the record is found in the right half. It actually does a full s... |
Saving/Serializing OkHttp/Retrofit Requests <p>I want to be able to recover from crash/closing the app or just device being disconnected.</p>
<p>Currently when I detect that the network is out for my Android device I save the Call created with RetroFit2 in a stack (to process later). If the user were to close the app ... | <p>Use <a href="https://github.com/yigit/android-priority-jobqueue" rel="nofollow">android priority jobqueue</a> by Yigit Boyar (one of the google android guys). It'll serailize your jobs, detect network changes (and respond accordingly) and persist even through device reboots (let alone app crashes). Plus a ton of oth... |
Ruby trying to store array elements when reiterating through functions <p>I am attempting to make a tic tac toe game. I have a good idea of where to go, and I know what the problem is, but I am not sure how to fix it. When I create a function, I establish variables for that function. i = 0, row1 = [], but when I am ... | <p>Global variables are prefixed by <code>$</code> and are generally a bad idea in Ruby.</p>
<p>Instance variables, prefixed by <code>@</code>, can also do what you want; on top-level, they behave pretty much the same as globals, but in classes or modules they are nicely isolated.</p>
<p>So the best way would be to m... |
printout sequence in python2.7 <pre><code>def foo(num,base):
if(num>= base):
foo(num/base,base)
print num%base,num
numA =126
numB = 2
foo(numA,numB)
</code></pre>
<p>In my mind,<a href="https://i.stack.imgur.com/RFIXw.jpg" rel="nofollow">enter image description here</a>results should be same as pi... | <p>i think what you intended was something like below, 1st iteration will taking input 126, subsequence will be num/base</p>
<pre><code>def foo(num,base):
print num%base,num
if(num>= base):
foo(num/base,base)
</code></pre>
|
Getting error while Convert string to json object <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var result = "";
result += "[";
for(i=0;i<=10;i++)
{
result += "{ '... | <p>In this snippet <code>( result += "]}, ";) , ","</code> (comma) is getting appended at the last, so the json will be like <code>"},]"</code> where you will be expecting like <code>"}]"</code></p>
|
CSS slide in from left animation <p>I'm working on a slideshow and it works, except for the animations. The animation for sliding out works fine but the animation for sliding in from the left does not. The left margin gets set to 0% but there is no animation, even though it is set to -100% at first.</p>
<p>Javascript:... | <p>To create a nice slideshow I suggest to use css <code>transform</code> property rather than the <code>margin</code>. The idea is to create the placeholder element <code>currentImage</code> with <code>relative</code> position, and then create all images inside it with position set to <code>absolute</code>. Then by de... |
View from a Join of two tables in SQL Server <p><a href="https://i.stack.imgur.com/0QsgA.jpg" rel="nofollow">Tables to Join</a></p>
<p>I attached an image explaining issues that I currently face at the moment. I was looking for a way to join two tables. Where first table has a relationship to the previous table that i... | <p>If you are using SQL Server, try creating a view function. You can easily add tables and view the sql results after you connect all of them. It also has a built in function that will automatically creates the sql queries corresponding to your created view function.</p>
|
nixOS: how to recover from collision between two instances of same package, same version <p>Here is my <code>nixos</code> version:</p>
<pre><code>$ nixos-version
16.09pre85931.125ffff (Flounder)
</code></pre>
<p>Here is my shell script:</p>
<pre><code>$ cat test.nix
{ nixpkgs ? import <nixpkgs> {
}, compiler... | <p><code>ghcWithPackages</code> effectively creates a brand new distribution of GHC, customised to include the packages you've listed. That is a different thing from <code>pkgs.ghc</code>, not just a thing that depends on it; it doesn't make sense to install both into the same environment. I think you've accidentally r... |
AutoValue not finding generated constructor in Android project <p>I am struggling to get <a href="https://github.com/google/auto/tree/master/value" rel="nofollow">AutoValue</a> working in an Android project. It seems to be working for others, so I must just be missing something. I've tried enabling the jack compiler, t... | <p>Because we are generating a class here access to the method needs to be public so autovalue can work.</p>
<pre><code> public static Repo create(int id, String name, String fullName, String description,
int numStars, String language, String htmlUrl) {
// See "How do I...?" below for nested ... |
Video gallery in GridView <p>I want to make Video Gallery in Grid View in Xamarin Android.
When I click on any video, it should play on same page.</p>
<p>I have googled a lot but I could not find any example there.</p>
| <p>You can use a <code>RecyclerView</code> to display videos and use a custom video player to play videos.</p>
<p>Please refer this post <a href="http://stackoverflow.com/a/31902683/85606">http://stackoverflow.com/a/31902683/85606</a>, the code is in Java but you can port it to C#</p>
|
SQL Server : find Instance of values that deviate <p>Scenario: I have bills on various accounts, stored in a SQL Server database, over a series of months.</p>
<p>i.e.</p>
<pre><code>AccountNum BillNum BillMonth BillTotal
---------------------------------------------------
123456 123456-1 ... | <p>You can try using the following query:</p>
<pre><code>SELECT AccountNum, BillNum, BillMonth, BillTotal,
CASE
WHEN ABS(BillTotal - AVG(BillTotal) OVER (PARTITION BY AccountNum)) >
STDEV(BillTotal) OVER (PARTITION BY AccountNum)
THEN 1
ELSE 0
END AS devi... |
Yii2 make an input field appear only in create <p>I would like to make an input field appear only in the 'create' form and not in the 'update' form. How can I achieve this?</p>
| <p>You can do that by following way</p>
<pre><code>if ($model->isNewRecord){
echo $form->field($model, 'password')->passwordInput(['maxlength' => true, 'placeholder' => "Enter password"]);
}
</code></pre>
|
Make horizontal line spanning to width of container using pseudo css elment <p>I want to make a a horizontal line spanning to the width of the container in which it is placed. The lined element should look like this:</p>
<pre><code>//////////////////////////////////////////////////////////////////
</code></pre>
<p>Ve... | <p>I think you should try linear-gradient. Please find the below code.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.horizontal-line:before
{
content: '';
margin: ... |
Microsoft Graph .NET SDK: Getting items from mycompany.sharepoint.com/Shared%20Documents <p>Debugging the code, I see the request is like:
<a href="https://graph.microsoft.com:443/v1.0/drives/the-shared-docs-id/items/the-root-id/children" rel="nofollow">https://graph.microsoft.com:443/v1.0/drives/the-shared-docs-id/ite... | <p>I was testing with two different apps, one with <strong>Files.ReadWrite</strong> scope only, and other with <strong>Files.ReadWrite.All</strong>.</p>
<p>I thought <strong>Files.ReadWrite.All</strong> was needed to access other user's files. It turns out, it is also needed to access the shared folder, even being th... |
When value in dropdownlist have ever been selected will not display <p>I have two tables that relate to each other one to one that is Husband and Wife. I've made my value dropdownlist and to get the data from the table Husband. I want when its value had been chosen will not appear on his dropdownlist. Perhaps there are... | <p>mungkin kau harus memakai javascript
ini adalah contoh view saya dan controller</p>
<p>view</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?php
use yii\helpe... |
Push files to gitlab-ci via CI runner <p>I am using gitlab CI runner to test my code and generating some files. I just want to push the generated files to gitlab repository via CI runner. Is there any way to do that ?</p>
| <p>The Feature you are looking for is called Artifacts. Artifacts are files which are attached to a build when they are successful.</p>
<p>To enable an Artifact put this in your .gitlab-ci.yml:</p>
<pre><code>artifacts:
paths:
- dir/
- singlefile
</code></pre>
<p>This will upload the <code>dir</code> direc... |
Angular 2 how to define lazy loaded child routes of a parent route that's also lazy loaded <p>I'm trying to get lazy loading to work for my app but it's one issue after another. I've gotten the main route to lazy load which is <code>/admin</code>, now I want to add another route which is <code>/admin/login</code>. </p>... | <p>You need to define an empty route within your LoginModule.</p>
<p><strong>login.module.ts</strong></p>
<pre><code>@NgModule({
imports: [
RouterModule.forChild({ path: '', component: LoginComponent })
ComponentsModule,
SharedModule
],
exports: [
ComponentsModule,
SharedModule
],
declar... |
What is the limit of holding the data in viewstate? <p>What is the limit of data we hold in ViewState? And are the limitations of Viewstate?</p>
<pre><code>ViewState["allDataOfCandidates"]=dt;
</code></pre>
| <p>Viewstate does not have any size limitations. But nothing comes for free, and view state is no exception. It certainly imposes performance hits whenever an Asp.net webpage is requested.</p>
<ol>
<li><p>On all page visits, during the save view state stage the Page class gathers the collective view state for all of t... |
Better approach for login implementation without internet connection and matching password from local db <p>I am integrating log in in my app. There is a requirement for log in without internet connection. Means first time when user gets login there will be a web service call for log in authentication but next time the... | <p>Never ever store passwords in plain text anywhere. Event when it's local and nobody has access to it.<br>
The better approach is storing it using a hashing algorithm along with salt so the if password is leaked somewhere, no harm should come of it.
You can then hash the input password with the same algorithm and ver... |
Microsoft.Office.Interop.Excel missing in the Component Name list <p>Microsoft.Office.Interop.Excel in the Component Name list is missing on the Assemblies page.</p>
<p>I need to include that:</p>
<pre><code>using Microsoft.Office.Interop.Excel;
</code></pre>
<p>But it throws error: <em>The type or namespace name 'O... | <p>Try installing interop package from microsoft depending on your version of excel. </p>
<p>Then check if the microsoft excel 12.0 library will be on your reference.</p>
<p>See if it helps.</p>
|
Thread safe of operation in one entry <p>I want to do operations like </p>
<pre><code>class A {
}
ConcurrentHashMap<A, Integer> map = new ConcurrentHashMap<>();
public void fun() {
Integer count = map.get(Object);
if (count != null) {
map.put(Object, count+1);
}
}
public void ad... | <p>Use <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicInteger.html" rel="nofollow">AtomicInteger</a> and <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#putIfAbsent-K-V-" rel="nofollow">ConcurrentHashMap.putIfAbsent()</a></p>
<p>Also ... |
Identify duplicate customer id's in a list of customers <p>A complete newbie here so I apologize if my question is stupid. I honestly tried before posting.
I have a list of some customers, with their customer Id's as one column and customer name as the other, and age as the third column. </p>
<p>I want to go through t... | <blockquote>
<p>I tried adding the customers to a set (because set would not add duplicates), but how do I state that it is the customerId, not the customer, that cannot be duplicated in this list?</p>
</blockquote>
<p>This is possible if you override the <code>equals()</code> method based on the ID field, thereby t... |
jQuery autocomplete keeps giving TypeError <p>been trying to figure out this one for hours, no luck.
The exact error according to firebug is: TypeError: items[0] is null
<a href="http://localhost:81/tab/resources/jquery-ui.js" rel="nofollow">http://localhost:81/tab/resources/jquery-ui.js</a>
Line 8488</p>
<p>and the c... | <p>Turns out, the problem was that I had special characters in my array wich came from the query. Simply adding mysqli_set_charset($connection, "utf8"); to the search.php solved the problem.</p>
|
Enable DataGrid sorting for first column in xaml <p>I have a DataGrid in WPF with autogenerated columns.</p>
<p>How can I disable sorting functionality of all the rows except the first one which corresponds time in my Source.</p>
<p>I am following MVVM pattern and I know that CanUserSortColumns is disabling sorting f... | <p>I found this code <a href="http://stackoverflow.com/questions/1296532/making-a-datagrid-column-header-sortable-in-wpf-using-c-sharp">snippet</a> for you:</p>
<pre><code><my:DataGridTemplateColumn SortMemberPath="CompleteDate" Header="Complete Date" CanUserSort="true">
<my:DataGridTemplateColum... |
Date Difference between consecutive rows <p>I have a table with following structure</p>
<pre><code>RetailerCode Orderdate
1001 01-JUL-16
1001 04-JUL-16
1001 06-JUL-16
</code></pre>
<p>I want this output</p>
<pre><code>1001 10/9/2011 - 12/9/2011 2 days
1001 12/9/2011 - 20... | <p>It s look like simple analitic functions </p>
<pre><code>select RetailerCode, tO_char(Orderdate,'DD/mm/YYYY')||nvl2(next_Orderdate,' - '||tO_char(next_Orderdate,'DD/mm/YYYY'),'') Orderdate_diff, nvl(to_char(next_Orderdate - Orderdate),'NA') count_days from
(select RetailerCode, Orderdate,
l... |
Keras - input shape of large 2-dimensional Array <p>I want to build an array which contains a very large number of elements
number of sequences (batch size) * size of dictionary (unique words in file)
474683 * 22995</p>
<p>each sequence will have some number X of bits turned on which represents a word in the dictionar... | <p>Okay, I decided to split the array and train on each of the split instead of pushing everything to memory:</p>
<pre><code>data_cut = 3
X = np.zeros((len(inputs)/data_cut, max_len, len(words)), dtype=np.bool)
y = np.zeros((len(inputs)/data_cut, len(words)), dtype=np.bool)
# set the appropriate indices to 1 in eac... |
How can I determine the register bit widths correctly? <p>This is the simple code I wrote.From 'outt' I get 122116. But if I change 'outt' width to be 33 bits ([32:0]) then code seems to work and give the correct answer -140028. What is the reason for this behaviour?? </p>
<pre><code>`timescale 1ns / 1ps
module valu... | <p>You are performing an operation that needs at least 33 bits (the temporary result before the right shift uses 33 bits) and theoretically it could need 32+"the size of the multiplicand constant" assuming that r_1 and r_2 are not constants.</p>
<p>If you think of the hardware your code will generate, these bits needs... |
Multiple booleans if condition in C# <p>In plain language - if this portion of the script detects that the direction is "right" and the two booleans "Wallright" and "WallsLeftOrRight" are false then play the standard walking animation and move the sprite...</p>
<p>This portion works okay, it is the next portion I am h... | <p>First of all, simplify your code.</p>
<p><code>if(WallRight == false)</code> is the-same as <code>if(!WallRight)</code></p>
<p><code>if(WallRight == true)</code> is the-same as <code>if(WallRight)</code></p>
<p>To answer your question:</p>
<blockquote>
<p>If this portion of the script detects that the directio... |
How to connect Aws S3 to Wowza Streaming Engine? <p>We have finished our project.we have using many Web Server in our project and also we have used AWS S3 server to save the media files.we have run app in web & Android & IOS deceives. That time videos are taking long time to play in our application. we are p... | <p>After you've created your S3 bucket, you mount it as a local file system.
If you are using the pre-built AMI provided by Wowza, then you can use the built-in application named <strong>vods3</strong>. This application is already configured to use Media Cache so that after the first playback, the files are cached on t... |
How to add foreign key in Laravel 5.1 Integrity constraint violation: 1452? <p>I am adding a foreign key to <strong>Tickets</strong> Table. The other table is <strong>ticket_statuses</strong>.</p>
<p>In artisan, i executed this command: <strong>php artisan make:migration add_ticket_status_to_tickets_table</strong></p>... | <p>Check your migration table name and reference table name. You have mistake here.</p>
<p>UPD:</p>
<p>It looks like you already have data in tickets table. If so, you can try now</p>
<pre><code>$table->integer('ticket_status_id')->unsigned()->nullable();
</code></pre>
|
Sublime text 3 plugin development for custom autocomplete like emmet? <p>I would like to create my custom plugin like emmet for auto completion and tag expansion for html tags like <code>h2>span</code> .myclass should result in <code><div class="myclass"></div></code>.</p>
<p>I started with but didn't ... | <p>Typically, one doesn't program a plugin to track what the user types in Sublime Text, but instead binds a command to a keybinding. Then, when the user presses that certain key, under certain conditions, defined in the context of the keybinding, the command executes and looks at the text near the selection caret.</p>... |
How to create a database with collation value from other database <p>I am taking a backup of database and restoring it on other system which have other collation. Want to know how can I get the collation from database of target system and use it to create new database with this collation instead of collation set in bac... | <p>You can't specify collation while restoring..Only options are</p>
<p>1.Alter collation once restore is done<br>
2.IF you have scripted out the database,then you can alter the scripts</p>
<p>to get collation : </p>
<pre><code>select name, collation_name from sys.databases
</code></pre>
<p>To alter collation: </... |
What kind of type have the range in for loop? <p>When we write the following:</p>
<pre><code>for i in 1...10 {
//do stuff
}
</code></pre>
<p>I want know what type have the range <code>1...10</code> to use it in function call for example:</p>
<pre><code>myFunc(1...10)
</code></pre>
| <p>If you put a breakpoint after defining <code>let range = 1..<10</code>, you will see that it's actually not a <code>Range</code> structure, but rater a <code>CountableRange</code> (or <code>CountableClosedRange</code> for 0...10)</p>
<p>Docs: <a href="https://developer.apple.com/reference/swift/countablerange" r... |
Is it possible to move files or file changes between branches? <p><strong>Summary</strong>: I forgot to switch branches when developing and would like to move the files/changes to the appropriate branch.</p>
<p><strong>Details</strong>: I have two files <code>A</code> and <code>B</code> which are initially in <code>ma... | <p>A simple solution is, from where you are on <code>branch1</code>:</p>
<ul>
<li>create branch2 (<code>git checkout -b branch2</code>), and remove <code>C</code>. Add, commit, and push</li>
<li>get back to master (git checkout master), and <a href="http://stackoverflow.com/a/7099164/6309">copy <code>C</code> from <co... |
Android converting color string to resource int <p>I am trying to set color from a json color array to my custom menu background.</p>
<p><code>addMenuItem(int bgColor);</code></p>
<p>json color array =></p>
<pre><code>[
[
"B71C1C",
"C62828"],[
"B71C1C",
"C62828"]
]
</code></pre>
<p>Color String is... | <p>That's because you are throwing in a number and the Android framework tries to find a resource for that (R.color) which doesn't exist. You should convert that number to a <code>Color</code> object, using <code>Color.argb(int,int,int,int)</code> for example</p>
|
Closure confusion with keyword 'this' <p>Below is my module. I want to namespace 'Module' with self.
So inside the module I assign this to self. With this, inside closures I can call Module as 'self' instead of this, that's my idea. But it gives error;</p>
<p>How can I use self or any other variable name instead of th... | <p>In your code, <code>self</code> has the value <code>this</code> had when you created your object; it doesn't refer to your object. When you call <code>Module.init</code>, the usual mechanism of setting <code>this</code> to the object that the <code>init</code> property came from during the call sets in.</p>
<p>If y... |
adding storyboard element run time issue <p>I have this situation :</p>
<p><a href="https://i.stack.imgur.com/Wv5IA.png" rel="nofollow"><img src="https://i.stack.imgur.com/Wv5IA.png" alt="enter image description here"></a></p>
<p>This pink view in the scrollview and I want is:</p>
<p>when I tap on 'add' button, I wa... | <p>I am not sure where you have problem adding view to scrollview. Here is example for adding button into scrollview at runtime. You can use same code for adding your pink view.</p>
<pre><code>import UIKit
class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate
{
var pickerviewObj : ... |
Getting HTTP POST Error : {"reason":null,"error":"Request JSON object for insert cannot be null."} <p>I am getting HTTP POST error when I am trying to connect to a Service Now Instance for Change Request Automation using Python. Here is the script I am using with Python 3.4.4</p>
<pre><code># SNOW CR AUTOMATION SCRIPT... | <p>This is a working example I tested on my instance. I am using REST Table API to insert a change request. It's not true that it can not be http. It's whatever protocol your instance allows to connect, say from browser. </p>
<pre><code>#Need to install requests package for python
#easy_install requests
import request... |
Error in inserting python variable in mysql table <p>I am working on a raspberry pi project, in which I'm fetching data from plc and storing it into mysql database.</p>
<p>Here is my code:</p>
<pre><code>import minimalmodbus
import serial
import mysql.connector
instrument = minimalmodbus.Instrument('/dev/ttyAMA0',3... | <p>i think should be.</p>
<pre><code>cursor.execute("insert into Register_Values values(%s)",(reg_value))
con.commit()
</code></pre>
|
The table customer is successfully created with a primary key cust_id,Why is this still showing errors? <pre><code>mysql> create table order(order_no int primary key,cust_no int,foreign key(cust_no) references customer(cust_no),order_date date,ship_date date,tocity varchar(20),tostate varchar(20),zip int);
</code></... | <p>NOTE: since <code>order</code> is a keyword, you can only access it as:</p>
<pre><code> select * from `order`
create table `order`(order_no int,cust_no int,foreign key(cust_no) references customer(cust_no),order_date date,ship_date date,tocity varchar(20),tostate varchar(20),zip int, primary key (order_no));... |
Call another service function from a service function <p>Is there anyway to call another service form current service ?</p>
<p>/<em>FACTORIES</em>/</p>
<pre><code>app.service('p3call',function($http,$rootScope){
return {
getRepairCategory:function(url){
$http.post(url)
.success(function (response)... | <p>yes it's totally possible:</p>
<pre><code>app.service('p3call',function($http,$rootScope, myOtherService){
return {
getRepairCategory:function(url){
...
},
deleteRepairCategory:function(request,url){
...
},
generatePaginationData:function(response)... |
Disabled audio on Visual Studio <p>I want to play .wav sound in my application. I know how to do it. For example with a SoundPlayer class:</p>
<pre><code>SoundPlayer player = new SoundPlayer();
player.SoundLocation = @"C:\path\sample.wav";
player.Load();
player.Play();
</code></pre>
<p>At home I have multiple Applica... | <p>In the end it was faulty wav file. I converted it to mp3 and then back to wav and now it works.</p>
|
understanding marshmallow nested schema with list data <p>Am new to python and am usign <a href="https://marshmallow.readthedocs.io/en/latest/" rel="nofollow">marshmallow</a> serialization. unable to use the nested scehma.
, my code </p>
<pre><code>from sqlalchemy import Column, Float, Integer, String, Text, text,F... | <p>Self contained example using in-memory SQLite:</p>
<pre><code>from flask import Flask, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
from marshmallow import Schema, fields, pprint
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'super-secret'
app.config['SQLALCHEMY_DATABASE_URI'] ... |
Upload new iOS 10 application built by older Xcode 7 <p>I've a simple question.<br> What are requirements for new app upload to latest AppStore?<br>I mean is it required to use latest Xcode 8 and also latest swift or is it possible to upload the new application running on swift 2.2 version using Xcode 8 or maybe with X... | <p>Apple recommends you to build and submit to App store with latest SDK. However, it doesn't mean that it forces you to do that. In other words, you can use older SDK to compile you source code. For example, you can compile you app with XCode8 with Swift 3, but if you do with XCode7 and Swift 2.2, it's also fine.
Hav... |
Add two values to AutocompleteTextview Adapter <p>I am trying to display contact list in autoCompleteTextView so far I have successfully achieved that but I need to use the <code>contact_id</code> related to name how Should I bind <code>id</code> with name?</p>
<p>I have used hashmap to store the contact list.</p>
<p... | <p>Check this example <a href="http://www.tutorialsbuzz.com/2015/03/Android-Custom-AutoCompleteTextView-Filter.html" rel="nofollow">AutocompleteTextView</a></p>
|
AngularJS - how to get the parameter from URL <p>I'm trying to pass the parameters to the AngularJS controller.</p>
<p><strong>AngularJs Routes</strong> </p>
<pre><code>$routeProvider.when('/post-ads/', {
templateUrl: "ui/view/post-ads.php",
controller: "adPostController",
controll... | <p>Please inject <code>$routeParams</code></p>
<p><code>adPostController.$inject = ['ApiService', '$scope', '$routeParams'];</code></p>
<p>See: <a href="https://docs.angularjs.org/api/ngRoute/service/" rel="nofollow">https://docs.angularjs.org/api/ngRoute/service/</a>$routeParams</p>
|
Why does Gerrit compares a newly added file with a renamed file? <p>I renamed a file <code>ivim_uc5.xml</code> to <code>ivim_uc5_z1.xml</code>. Then I created 9 new files with the name <code>ivim_uc5_z2.xml ivim_uc5_z3.xml</code> and so on. After pushing the <code>Gerrit</code> shows like this:</p>
<p><a href="https:/... | <p>The "C" character on Gerrit UI indicates that you have copied the ivim_uc5_Z*.xml files from the ivim_uc5.xml one.</p>
<p>See here:</p>
<p><a href="https://gerrit-review.googlesource.com/Documentation/user-review-ui.html#files" rel="nofollow">https://gerrit-review.googlesource.com/Documentation/user-review-ui.html... |
Mocha chai unexpected assertion testing error from object equaling object <p>I'm using Mocha and Chai to do some front end testing and put in the below assertion.</p>
<pre><code> it('AddContact returns contact with type = ADD_CONTACT', function () {
function hi() {return {
type: 'ADD_CONTACT',
data: {... | <p>You have to use <code>to.deep.equal</code> else you are testing that's the <strong>same</strong> object in memory, not the value.</p>
|
Pivot SQL by Year <p>Well, there's a lot of references for pivot SQL. But still, I couldn't solve my problem.<br></p>
<p>I have the following table:<br></p>
<pre><code>-----------------------------------------------------------------------
InspectYear PartNo PartDesc A B C D
-----------------... | <p>Try below dynamic PIVOT:</p>
<pre><code>DECLARE @InspectYear AS NVARCHAR(MAX),@Query AS NVARCHAR(MAX);
SET @InspectYear = STUFF((SELECT distinct ',' + QUOTENAME(InspectYear)
FROM table4 c
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
SET @Query =
';W... |
Canvas Android, how can i do an OnTouchEvent when a bitmap is touched instead of the full screen? <p>I have this function:</p>
<pre><code>@Override
public boolean onTouchEvent(MotionEvent event1)
{
if(event1.getAction()==MotionEvent.ACTION_DOWN){
if(!player.getPlaying() && newGameCreated &&... | <p>You could implement the parent layout touch and pass it to your view (where you binded your canvas) as child layout. You could follow as per below :</p>
<p>1) Implement parent layout touch event </p>
<pre><code>yourparentlayout.setOnTouchListener(new View.OnTouchListener() {
@Override
publi... |
await thousands of Tasks <p>I have an application which converts some data often there are 1.000 - 30.000 files.</p>
<p>I need to do 3 steps:</p>
<ol>
<li>copy a File (replace some text in there)</li>
<li>Make a Webrequest with WebClient to download a file (I send the copied file to a WebServer, which converts the fi... | <p>As commenters have correctly noted, you're overthinking it. The .NET runtime has absolutely no problem tracking thousands of tasks.</p>
<p>However, you might want to consider using a TPL Dataflow pipeline, which would enable you to easily have different concurrency levels for different operations ("blocks") in your... |
Display data with the same title but different content <p>Let's say if I have a database which contain:</p>
<blockquote>
<p>ID: 1 | Name: hello | Content1: sample1 | Content2: sample2</p>
</blockquote>
<p>And I have developed a WSDL webservice which have the result like this:</p>
<pre><code><name> hello <... | <p>all you need to do is make listview_item_row as
name
content1
name
content2</p>
<p>and while adding data to listview just check name and content,
ex: </p>
<blockquote>
<p>if(content2 == null)</p>
</blockquote>
<p>do not add name for content 2 </p>
<blockquote>
<p>if(content2 != null)</p>
</blockquote>
<p>... |
cursor loop in PostgreSQL <p>This below code is a cursor in PostgreSQL 9.0. I want to fetch my records by joining more than one table and i am getting JSON data from that join.</p>
<p>So I want to loop those records and parse that json using query something like </p>
<pre><code>SELECT "Dump"->'activities-steps'-&g... | <p>Since you cannot loop in SQL, you'll have to use PL/pgSQL, for example with a <code>DO</code> statement.</p>
<p>In your case, that could look like this:</p>
<pre><code>DO
$$DECLARE
asn_id ...;
asn_userid ...;
...
c refcursor;
BEGIN
/* assign the SQL cursor to the refcursor variable */
c := 'sessi... |
MongoDB query array and summarize keywords <p>I would like to query the sub-key of an array, extract keywords, and count them. </p>
<p>The words that I'd like to extract from are in "Title." When I applied the query filter, it shows that the field I need to query is <code>Reviews.0.Title</code>. But I have at least 20... | <p>I managed to find a <code>mapReduce</code> solution that provides a functionality similar to what you are looking for <a href="http://stackoverflow.com/questions/16174591/mongo-count-the-number-of-word-occurences-in-a-set-of-documents">here</a></p>
<p>I adjusted that solution and generated the following <code>mapRe... |
What does '...' in React-Native mean? <p><strong>A piece of react-native code</strong>:</p>
<pre><code>enderScene(route, navigator) {
let Component = route.component;
return (
<Component {...route.params} navigator={navigator}></Component>
);
}
</code></pre>
<p>this code returns a Component... | <p>The '...' is called Spread syntax.</p>
<blockquote>
<p>The spread syntax allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) or multiple variables (for destructuring assignment) are expected.</p>
</blockquote>
<p>Example :</p>
<p... |
Excel VBA RemoveDuplicates function with case sensitivity <p>I'm trying to remove some duplicates from selected column, but the function removes all duplicates irrespective of the case. <code>RemoveDuplicates</code> considers lower case, upper case, etc as duplicate. E.g. the function removed <code>CENTRAL</code>, <cod... | <p>Try the following code using a <code>Dictionary</code> to remove duplicates with case sensitivity:</p>
<pre><code>Option Explicit
Sub Test()
RemoveDuplicates Sheet1.Range("A1:A12")
End Sub
Sub RemoveDuplicates(rngDataColumn As Range)
'assumes rngDataColumn is a column of data
Dim dic As Object
Dim rn... |
Knockoutjs: Split a string into an array of string <p>I'm a newbie in knockout so please forgive my ignorance.</p>
<p>This is my knockout.js file:</p>
<pre><code>self.names = ko.observable(); // john, mary, jimmy
var arrNames= new Array();
arrNames = self.names().toString().split(",");
</code></pre>
<p>But I'm getti... | <p>You can use computed in order to get recalculable result:</p>
<pre><code>self.names = ko.observable(); // john, mary, jimmy
self.arrNames = ko.computed(function() { return self.names() && self.names().split(",") || []; });
</code></pre>
<p>Sample usage:</p>
<pre><code>var a = self.arrNames() // a = []
sel... |
Cannot convert BinaryReader.PeekChar or ReadChar to String C# <p>Whenever I try to convert <code>BinaryReader</code> <code>PeekChar</code> or <code>ReadChar</code> to string it gives me an error </p>
<blockquote>
<p>Error 1 'System.IO.BinaryReader.PeekChar()' is a 'method', which is
not valid in the given contex... | <p>You are missing the <code>()</code> for the method calls</p>
<pre><code>richTextBox1.Text = richTextBox1.Text + objBinReader.ReadChar().ToString();
</code></pre>
<p>and</p>
<pre><code>objBinReader.PeekChar().ToString()
</code></pre>
|
Best practices for passing data from one angular module to another, in different HTML pages <p>I have an API that manages Lab, now I'm trying to develop a Form Manager, form quotations, orders, etc.
Since I will add Metalwork in the future, and for OO principles, I would like to have the Forms separated from the 'Work... | <p>I suggest to store the data inside a "model" like <code>.factory()</code> and consume it.</p>
<p>Example:</p>
<pre><code>/* models.js */
import angular from 'angular';
import User from 'models/User';
const models = angular.module('app.models', []);
models
.factory('UserModel', User);
export default models;
... |
Why is `as Date` required for `timeIntervalSince()` with two `NSDate` objects? <p>I have an <code>NSManagedObject</code> object with:</p>
<pre><code>@NSManaged public var timestamp: NSDate
</code></pre>
<p>I needed the time interval between two of these, so I implemented:</p>
<pre><code>let interval = next.timestamp... | <p>Referring to <a href="https://developer.apple.com/reference/foundation/nsdate" rel="nofollow">NSDate Apple Documentation</a>: </p>
<blockquote>
<p>The Swift overlay to the Foundation framework provides the Date
structure, which bridges to the NSDate class. The Date value type
offers the same functionality as ... |
Using multiple columns as ForeignKey to return in another table <p>I'm new to Django so I make 3 simple tables to return a WishList. The thing is that I want whenever user asks for WishList, his/her <code>user_id</code> is used to make a <code>SELECT</code> query to return his/her own WishList. And I want to get produc... | <p>Django documentation is your friend, <a href="https://docs.djangoproject.com/en/1.10/topics/db/queries/" rel="nofollow">read it</a>.</p>
<p>Im serious, read the entire <a href="https://docs.djangoproject.com/en/1.10/" rel="nofollow">documentation</a>.</p>
<p>Moreover its not a good practice to override to_field to... |
Using o-auth to authentify users on my API <p>I've got a project made of two websites:</p>
<ul>
<li>The front : A Laravel website without database and logic (just showing static pages and my javascript)</li>
<li>The API : A project using Lumen/Dingo API with my endpoints, my database, my logic and my models</li>
</ul>... | <p>Identification per user is always a better solution as the claims can be decided per user, also in future when it is required to provide permissions to access API based on claims or roles, it becomes easy to give information using the claims and amount of access you can give to a specific user. </p>
<p>So the way i... |
cURL error on whitespace within data field <p>I'm writing a bash script using cURL to call an API. I'm generating some part of the contents transforming strings coming out from other sources.
From the db the spaces are replaced with "_SPACE_" string for application reasons.
I'm replacing it using</p>
<pre><code>ITEM=$... | <p>The exception</p>
<pre><code>org.codehaus.jackson.JsonParseException: Unexpected end-of-input in VALUE_STRING ...
</code></pre>
<p>says that your lib from codehouse is not able to parse the data object which is send via curl. i could imagin that your --data '{"field": "'$ITEM'"}' object fails because of the single... |
Why does my result data returned as void* gets broken? <p>I am working in a project with a huge legacy code base and have been trying to re-design parts of it to get away from old c-style code.</p>
<p>I've run into a problem and have prepared a short program to explain. </p>
<p>The legacy interface I am using needs m... | <p><code>targetData</code> is a <em>local</em> variable to <code>doSomething</code>. After you assign an address to it, it goes out of scope.</p>
<p>You never actually assign to <code>myResult</code>.</p>
|
How to make selected alert pop up when selected index was choosen <p>I want to make if selected index in option was choosen then the selected alert is pop up, but I don't know how to do it, here is my JavaScript code:</p>
<pre><code><script>
function check1(){
var e= document.getElementById("maske");
... | <p>Function should be like below</p>
<pre><code>function check1(){
var e = document.getElementById("maske");
var selec = e.options[e.selectedIndex].value;
if(selec==1){
alert(e.options[e.selectedIndex].text);
}
}
</code></pre>
|
php shell_exec() command pop out error and permission denied ffmpeg <p>This is the main index.php file where I run my code to generate a video thumbnail with ffmpeg but it has no lucks at all I have been searching online for a lot of solution but nothing comes out i will be very appreciate if you guys can help me out. ... | <p>The user which is attempting to run this file does not have the correct permissions (usually <code>www-data</code>). To test this theory, try running with <code>sudo</code>:</p>
<pre><code>shell_exec('sudo -u user -p pass -s $ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile 2>&1');
</code></pr... |
Response status code:: 404 retrofit 2.0 <p>as far as i understand i get this issue because smth wrong with my code, but i can find exectly reason</p>
<p>There is my code</p>
<pre><code>public class MainActivity extends AppCompatActivity {
private MyServerConnection connection;
@Override
protected void onCreate(Bu... | <p>Eventually i found the reason in my case due to <code>/</code></p>
<p>i put this sing <code>/</code> in <code>.baseUrl(URL)</code> in the end of URL and also i put it in method <code>@POST("/appreg")</code>...</p>
<p>When I delete it from method like this <code>@POST("appreg")</code> it begin to work</p>
|
sed - replace second octet on an IP address <p>I would like to replace the second octet on an IP address using sed:</p>
<p>Example:</p>
<blockquote>
<p>10.<strong>110</strong>.30.11</p>
<p>10.<strong>133</strong>.30.11</p>
</blockquote>
<p>What is the easiest way to perform this task?</p>
<p>Thank you</p>
| <p>An attempt in pure <code>bash</code>, apart from wonderful <code>awk</code> and <code>sed</code> answers from above.</p>
<pre><code> $ IFS="." read -r octet1 _ octet3 octet4 <<<"10.110.30.11"
$ octet2=133
$ printf "%s.%s.%s.%s\n" "$octet1" "$octet2" "$octet3" "$octet4"
10.133.30.11
</code></pre>
|
Edit markers's lat-lng in Google Maps V3 <p>I'm using Google Map DrawingManager to add Markers to map. After a marker is added, it also adds a column into the table below the map. This column has some information about the marker (title, description, lat, lng) and 2 links (Edit and Delete). You can see that on this pho... | <p>I have found out a solution to do this.</p>
<p>Instead of using <code>markers[obj.lat + ':' + obj.lng] = marker;</code> to store markers, I use <code>markers[index] = marker;</code> (index is integer number).</p>
<p>Here is my change:</p>
<pre><code>var index = 0;
google.maps.event.addDomListener( drawingManager... |
Bad practise? Take row by username, then do validations if passwords match and then add to session? <pre><code>$user = \App\User::where("name", $req->us)->firstOrFail();
</code></pre>
<p>then:</p>
<pre><code>if(Hash::check($plain_text_password, $user->password)){
//add user to session
}
else{
//bad cred... | <p>There are two approaches.</p>
<p><strong>Approach 1.</strong> You can add both username password in the where condition.</p>
<p>If the username and password not matching, The error message will be like "Invalid Username and password"</p>
<p><strong>Approach 2.</strong> (Your approach). Get the user record from th... |
facebook og meta tag duplicated title <p>I have a problem sharing in facebook. I think i have correctly og:meta title but facebook duplicate title.</p>
<p>This is the link:</p>
<p><a href="https://developers.facebook.com/tools/debug/sharing/?q=http%3A%2F%2Fwww.pisos.afys.cat%2Fvivienda%2Fesgl%25C3%25A8sia%2Fplanta-ba... | <p>After a re-scrape, debug tool shows the following message:</p>
<blockquote>
<p>Object at URL <code>http://www.pisos.afys.cat/vivienda/esgl%C3%A8sia/planta-baja_en_sant-joan-de-vilatorrada_4290167.3377.html#f</code> of type <code>website</code> is invalid because the given value <code>494641230470</code> for prope... |
UITabBarController's viewControllers, the second one is loaded before the first one <p>I'm working with an App and its rootViewController is <code>UITabBarController</code>. I assigned <code>UITabBarController's</code> <code>viewController</code> with NewsViewController(index = 0), MusicViewController(index = 1) and We... | <p>when you are using <code>UITabBarViewController</code> keep in mind that:</p>
<p>first thing will be load is the <code>UITabBarViewController</code>, then it will load the first 3 view controllers from where you are standing.</p>
<p>for example if you are in index 0 it will load view controllers in index 0,1,2.</p... |
How to use java object as a key In JSON? <p>Hi I have a Java Class like,</p>
<pre><code>// code
class A{
private int i;
private String j;
// getters/setters
}
</code></pre>
<p>I want to use this object as a map key in my json, how i can do this?
e.g : i want something like - {javaObject:value}</p>
| <p>In that case when you want to convert object to json, use this <a href="http://www.vogella.com/tutorials/JavaLibrary-Gson/article.html" rel="nofollow">link</a>. Gson can be used to do that.</p>
|
How can i convert string to date with some strange format <p>I am getting some strange date format as string from server<br>
<code>2016-10-03T17:28:34.773</code><br>
Which format I need to use to convert this string to date.</p>
| <p>You can use this function to get date from your string.</p>
<pre><code> - (NSDate *) dateFromServerAttributeDateFormat:(NSString *)dateString
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"];
[dateFormatter setL... |
Removing leading spaces on Pascals Triangle <p>I have some example code below to print Pascals Triangle. (I am using the test case = 14 on scanner) The code works, but there are leading spaces in the result. How do I remove these spaces in front of the triangle?</p>
<pre><code>import java.util.Scanner;
public class P... | <p>I think what is happening is you are outputting your numbers in 4 char 'blocks' this line looks after that part;</p>
<pre><code>String output = String.format("%4d", number);
</code></pre>
<p>The following would output the number to the left of the 'box' - Although the whitespace would now be trailing.</p>
<pre><c... |
get count of data from previous 12 months start with sysdate <p>I am having scenario like this : I have table has date field.like</p>
<pre><code>id | date |name |
1 |1/12/2012 |new |
1 |1/12/2012 |renew |
1 |1/09/2012 |new |
1 |1/12/2012 |renew |
</code></pre>
<p>i need to get count like |</p>
<pre><code... | <p>You would get the results that you have shown as row (one row for each month) rather than columns.</p>
<pre><code>Select to_char(YOUR_DATE, 'YYYY-MM'), count(id)
FROM table_name a
WHERE YOUR_DATE BETWEEN ADD_MONTHS(SYSDATE, -12) AND SYSDATE
GRoup by to_char(YOUR_DATE, 'YYYY-MM')
order by 1;
</code></pre>
<p>Someth... |
SLURM how to get CPUids and max memory of current job <p>i am working with slurm and i want to find out the cpu_ids and max memory my current process is allowed to use.
Is there a way to figure that out?</p>
| <p>Use <code>scontrol show job -d <jobid></code> and look for <code>CPU_IDs</code> and <code>Mem</code>. The information will be given node per node.</p>
<p>From within the process, you can look at the <code>SLURM_MEM_PER_CPU</code> and <code>SBATCH_CPU_BIND_LIST</code> env variables if <code>TaskPlugin=task/aff... |
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' +HOST <p>I am VERY new to programming and I found this program and APPLY IT BUT I FOUND THESE ERROR (I put error at the end of program),
import requests
import telnetlib
import time
import sys</p>
<pre><code>import numpy as np
import ... | <p>it should be <code>print ("\tlive \t=\tProcess live data from device ",HOST)</code> not <code>print ("\tlive \t=\tProcess live data from device ") + HOST</code></p>
|
The notification sound does not want to shut down by hardware key <p>"I'm making iOS alarm application.</p>
<p>currently it's proceeded through UILocalNotification.</p>
<p>but when alarming on scheduled time, I want to stop alarming only in the application.
app is backgrounded.
generally when alarming through UILocal... | <p>There's no published way currently to handle this. You can make this using any private API's like <a href="http://sharkfood.com/content/Developers/content/Sound%20Switch/" rel="nofollow">Sound Switch</a>. Apple will not accept your app in AppStore. </p>
|
Azure deployment source not showing private repository from BitBucket <p>I have a private repository hosted on BitBucket. On Azure I have created a web app and in the app service I want to set a deployment source to my BitBucket instance.</p>
<p>The authorization was ok, but when I want to select a project, the list s... | <p>It was a permission issue. To have deployment source attached to a BitBucket instance, you need admin rights on the repository.</p>
|
send Data to controller from Jquery. MVC C# <p>my jquery script code part , the script is working fine and set data array/object in dataBLL..</p>
<pre><code>var dataBLL = [];
$('#mytable tr').each(function (i) {
dataBLL.push({
id: $(this).find('td:eq(0)').text(),
ctype: $(this).find('td:eq(1)').text(),
cpath: $(thi... | <p>You've got a syntax error (which your browser console will have told you), and also you're producing invalid JSON. </p>
<p><code>data: { "dataBll": dataBLL }</code> </p>
<p>should work I think. Or</p>
<p><code>data: JSON.stringify({ "dataBll": dataBLL })</code></p>
<p>at worst. Also set </p>
<p><code>contentTyp... |
Unpredictable output from Excel Index-Match <p>I'm trying to do what should be a simple enough task: find the index of the last cell in an array that matches a certain value.</p>
<p>I am using a MATCH-INDEX function combination that is giving me incorrect, inconsistent results. I can't figure out the problem.</p>
<p>... | <p>It seems that match only finds first, but not last.</p>
<p>But I have a possible solution, I would do it the following way:</p>
<p>expect: your values are between H4 AND H27, the value you look for is "39"</p>
<p>1: find the rownum for all matching cells</p>
<blockquote>
<p>I4 --> I27: IF(H4 = 39; ROW(H4); -1)... |
Path to RouteValueDictionary in Asp.Net Core <p>I need to extract the route data (Controller, Action etc) from an <strong>arbitrary</strong> request path (<strong>not</strong> related to the current request) such as <em>/</em> or <em>/account/manage</em>. In previous versions of Asp.Net Mvc this could be accomplished l... | <p>You can use <code>TemplateMatcher</code> to extract route values:</p>
<pre><code>public class RouteMatcher
{
public static RouteValueDictionary Match(string routeTemplate, string requestPath)
{
var template = TemplateParser.Parse(routeTemplate);
var matcher = new TemplateMatcher(template, Ge... |
What is the difference between the two css selectors [class^=test] vs [class|=test] <p>These two <code>[class^=test]</code> and <code>[class|=test]</code> matches the same elements as I see.</p>
<p>Is there any real difference or case why should I use one over the other?</p>
| <pre><code>[class^="test"]
</code></pre>
<p>The above selects all elements that <strong>starts with class</strong> "test", it will fail to find if the test is second class.</p>
<p>But:</p>
<pre><code>[class|="test"]
</code></pre>
<p>finding elements that matches class, won't show you if the class is "testing"
but w... |
PHP user rating based on post and read count <p>Im trying to get user stars based on their post and read count.</p>
<ol>
<li>0 post, 0 reads â 0 stars </li>
<li>3 post, 3,000 reads â 1 star </li>
<li>15 post, 15,000 reads â 2 star </li>
<li>25 post, 30,000 reads â 3 star</li>
<li>35 post, 40,000 reads â 4 st... | <p>check this,</p>
<pre><code><?php
$read = 50;
$post = 44;
if($post >= 50 && $read >= 70000){
echo "5 stars";
}else if($post >= 35 && $read >= 40000){
echo "4 stars";
}else if($post >= 25 && $read >= 30000){
echo "3 stars";
}else if($post >= 15 &&... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.