So i was ask to make a function that determinate if a number is a perfect square but it has a catch they ask me to operate using an auxiliary function that i should write based on this fact:
The first perfect square is 0, to get to the second i need to add up 1 (the second perfect square is 1), to get to the third i need to add up 3 (the third perfect square is 4), and so on ... so the rule is that as you keep adding odd numbers to the previous perfect square you get the next one.
Also they ask me to avoid using operations that involve float numbers.
I wasnt able to make any progress with it i hope someone could help me, thanks.
The problem is I want the "Var1" column to be the variables, like if it was a table. I want this in order to merge this dataframe with other. I would like to obtain something like this:
I have a UISearchController with a tableview which displays the searched PFusers from Parse. When the user tab on a row, the cell will segue to another view controller displaying info about the PFUser. The segued view controller has a button to unwind segue back to the tableview. The problem happens when I segue back to the tableviewcontroller; the tableviewcontroller is no longer like it was before I segue to another view controller (the searched PFUsers are gone, the table is empty) and when I search again, no results are fetched but I can see it is using data because of the spinner on the battery status bar. Any idea why this is happening? thanks!
Preface: I do understand the standard definition for attr_accessor and know that attr_accessor stands for two instance methods-a setter and a writer, and attr_accessor allows instances variables to be accessible throughout the class.
But now and then I see an element included in attr_accessor AND is defined as a method.
So my question is: Why does that happen? Is it just bad code I saw?
Pseudo/example code:
class Such_n_such attr_accessor :name, :color #code omitted def color=(color) (some code) end
I am running a PHP script, and keep getting errors like:
Undefined variable: user_location in C:wampwwwmypathindex.php on line 12
Line 12 looks like this:
$greeting = "Hello, ".$user_name." from ".$user_location;
What do these errors mean?
Why do they appear all of a sudden? I used to use this script for years and I've never had any problem.
What do I need to do to fix them?
Is there a quick fix?
This is a General Reference question for people to link to as duplicate, instead of having to explain the issue over and over again. I feel this is necessary because most real-world answers on this issue are very specific.
Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals tued on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized.
Some explanations:
Although PHP does not require variable declaration, it does recommend it in order to avoid some security vulnerabilities or bugs where one would forget to give a value to a variable that he will use later in the script. What PHP does in the case of undeclared variables is issue a very low level error, E_NOTICE, one that is not even reported by default, but the Manual advises to allow during development.
Ways to deal with the issue:
Recommended: Declare your variables. Or use isset() to check if they are declared before referencing them, as in: $value = isset($_POST['value']) ? $_POST['value'] : '';.
Use empty(), so no waing is generated if the variable does not exist. It's equivalent to !isset($var) || $var == false. E.g.
echo "Hello " . (!empty($user) ? $user : "");
Set a custom error handler for E_NOTICE and redirect the messages away from the standard output (maybe to a log file). set_error_handler('myHandlerForMinorErrors', E_NOTICE | E_STRICT).
Disable E_NOTICE from reporting. A quick way to exclude just E_NOTICE is error_reporting( error_reporting() & ~E_NOTICE ).
Q1: this notice means $vaame is not defined at current scope of the script.
Q2: Use of isset(), empty() conditions before using any suspicious variable works well.
// recommended solution
$user_name = $_SESSION['user_name'];
if (empty($user_name)) $user_name = '';
OR
// just define at the top of the script index.php
$user_name = '';
$user_name = $_SESSION['user_name'];
OR
$user_name = $_SESSION['user_name'];
if (!isset($user_name)) $user_name = '';
QUICK Solution:
// not the best solution, but works
// in your php setting use, it helps hiding site wide notices
error_reporting(E_ALL ^ E_NOTICE);
A (often discouraged) alteative is the error suppression operator@. It is a specific language construct to shut down undesired notices and waings, but should be used with care.
First, it incurs a microperformance penalty over using isset. That's not measurable in real world applications, but should be considered in data heavy iterations. Secondly it might obstruct debugging, but at the same time suppressed errors are in fact passed on to custom error handlers (unlike isset decorated expressions).
It means you are testing, evaluating, or printing a variable that you have not yet assigned anything to. It means you either have a typo, or you need to check that the variable was initialized to something first. Check your logic paths, it may be set in one path but not in another.
Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example:
The above code will create error as The if loop is not satisfied and in the else loop '$user_location' was not defined. Still PHP was asked to echo out the variable. So to modify the code you must do the following:
I use all time own useful function exst() which automatically declare variables.
Your code will be -
$greeting = "Hello, ".exst($user_name, 'Visitor')." from ".exst($user_location);
/** * Function exst() - Checks if the variable has been set * (copy/paste it in any place of your code) * * If the variable is set and not empty retus the variable (no transformation) * If the variable is not set or empty, retus the $default value * * @param mixed $var * @param mixed $default * * @retu mixed */
function exst( & $var, $default = "")
{ $t = ""; if ( !isset($var) || !$var ) { if (isset($default) && $default != "") $t = $default; } else { $t = $var; } if (is_string($t)) $t = trim($t); retu $t;
}
In a very Simple Language. The mistake is you are using a variable $user_location which is not defined by you earlier and it doesn't have any value So I recommend you to please declare this variable before using it, For Example:
$user_location = ''; Or $user_location = 'Los Angles';This is a very common error you can face.So don't worry just declare the variable and Enjoy Coding.
<?php
error_reporting(E_ALL); // making sure all notices are on
function idxVal(&$var, $default = null) { retu empty($var) ? $var = $default : $var; }
echo idxVal($arr['test']); // retus null without any notice
echo idxVal($arr['hey ho'], 'yo'); // retus yo and assigns it to array index, nice
?>
I am trying to do some hacking (I need to run the linker on a device to link some object files stored there) during the linking stage of Xcode on my ios app project. My first thought is to use the open-source lld linker to replace the native ld linker. I tried to replace ld with lld in the default xcode toolchain, and sent the same arguments to lld, but unfortunately many arguments are not recognized. If I remove these arguments, I get errors like:
I think it's because lld maybe not a direct replacement for ld. Then I am thinking is it possible to first link multiple object files into a single object file with lld (and do the hacking during this step) using -r option and then do the full link with ld?
So, my question is, is that possible to replace mac ld with lld? If not possible to fully replace it, is that possible to use lld to generate a single intermediate single object file and then input it to ld?
I have an SKEmitterNode in SpriteKit. I Added a separate .sks file and even replaced the standard texture with a red spark. Then I added it to my bird node. I see red sparks coming out of it, But only on the Black Burton out. My SKScene in background color is white and I can only see the sparks on dark background
#!/bin/bash
rename_files() { title="${1##*${2} - }" for filename in "$1/"*.*; do case "${filename##*.}" in doc|doc|doc) mkdir -p -m 777 "/Users/Desktop/Documents Share/Downloaded/${title}" new_path="/Users/Desktop/Documents Share/Downloaded/${title}/${title}.${filename##*.}" let "iters=1" while [ -f $new_path ] ; do new_path=$new_path"$iters" let "iters++" done echo "moving $filename -> $new_path" mv "${filename}" "${new_path}" ;; esac done
}
rename_category() { for path in "/Users/Desktop/Documents Share/Downloads/${1}"*; do rename_files "$path" "$1" done
}
rename_category DOC
This script automatically moves and renames files contained in /Users/Desktop/Documents Share/Downloaded. All is working fine if I use a folder called Documents instead of Documents Share. I tried to do use Documents Share but it doesn't work.
Here is the error log
/Users/Desktop/Script.sh: line 11: [: /Users/Desktop/Documents: binary operator expected
i need ur help figuring out this problem... im new to angular just started playing on ground.
Initially i have only one button on load "Add list", with add list user can able to add multiple lists with itself have a button("Add Phase") for each list, on click of Add phase it should show the content related to that phase.
Suppose there is a scenario of Users having Tasks. Each User can either be a Watcher or Worker of a Task.
Furthermore, a Worker can file the hours he has worked on a given Task.
Would the following diagram be correct? I have looked around at domain models and I have not seen one with the two associations (works on, watches). Is it acceptable?
I was reading the book "Text Analysis with R for Students of Literature" and trying to reproduce the example. Therefore I have a vector in which every element is one line of text from a book and I am now attempting to merge these into a vector of the length one with the past() function. I have tried to play around with the arguments and read about it but no matter what, the resulting vector keeps the original length. I am using R studio 0.99.484 with R 3.2.3 on a linuxMint 17.2, in case that makes a difference.
This is my reproducible example
> a <- rep("blabla", 5) > b <- paste(a, colapse= "X") > b [1] "blabla X" "blabla X" "blabla X" "blabla X" "blabla X" > length(b) [1] 5
The way I understand the documentation, I would expect the results be more like "blablaXbla... and the length have a value of 1.
Is there a way to get the result from the Example sheet Columns J:K using a single function?
I.e. is there a way to count unique / disctinct values within QUERY function, or any other single function that would create a pivot-like set of data with two columns?
In the example sheet I have a set of data, which I need to group by one column and count unique values in the other one. There's a workaround there, but it involves two formulas plus another one that would sort it properly (data set is growing and rows get added, so sorting manually is not the best option).
Query function (or, my knowledge of Query function) doesn't seem to be able to count unique values, so it's not working. Googling hasn't helped me much with this.
(Windows platforms) Run the EC2Config service Sysprep. For information about EC2Config, go to Configuring a Windows Instance Using the EC2Config Service. Ensure that Sysprep is configured to generate a random password that can be retrieved from the AWS Management Console
However when I attempt to change this setting, I cannot apply the changes. I have run the EC2Config service as administrator. How do I complete this step?
i install a eclipse mars and download maven plugins but when i create my first app in pom it is showing the error Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-compile)
i try all possibilty but can not resolve so what is the solutation
I have used the following code but when i click on the login button i'm redirected to a blank page.in this i have created a login pAGE that checks if the user is present in database.i have not given a sign up page instaed manually added values to the database.in sign-in.html i have given the form and in connectivity.php file i have given the code to check if user and password are present in database. as per code the output should have been "succesfully logged in" or "error could not login" but instead i get a blank page.how do i resolve this.please help!! the php file that connects to db
I have vs2013 and ie11 on my system. I have created virtual directory for my web application. I have crystal report version "10.5.3700.0". But when i generated report paging,print btn not loading and report format is also not good.If i run same url in ie8 it works fine.
Some crystal report css and js not loading properly