How to solve key issue of API [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Hi I try to call some data using API but it shows error message of "invalid key". But In the function I didn't figure out where I can input my key. The code is shown below:
sahie_years <- getCensus(
name = "timeseries/healthins/sahie",
vars = c("NAME", "PCTUI_PT"),
region = "state:01",
time = "from 2006 to 2018")
head(sahie_years)
Can anybody have some ideas?

See documentation here for setting up your API key.
You need to sign up for an API key here.
Once you've done that you can either specify your API key by setting an environment variable using Sys.setenv(CENSUS_KEY="YOUR_CENSUS_KEY_GOES_HERE"), or
just set it directly in your getCensus call by adding the argument key = "YOUR_CENSUS_KEY_GOES_HERE".
For API keys in general, it is often easiest to set them in a .Renviron file, which will make them available in each session using Sys.getenv.

Related

What datatype in C# should I use if mapping a database column of type money? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 months ago.
Improve this question
I am using Insight.Database version 6.3.10 for SQL Server ORM, using C# as the client. I have a run into an issue where the mapping does not return a correct value for money column data type. I am using decimal in C# client. Below is the sample code:
DROP TABLE IF EXISTS dbo.MyTestTable;
CREATE TABLE dbo.MyTestTable
(
AmountToAllocate MONEY
)
GO
INSERT INTO dbo.MyTestTable VALUES(177279.73)
GO
CREATE OR ALTER PROC [dbo].[MyTestProc]
AS
BEGIN
SELECT TOP 1 m.AmountToAllocate FROM dbo.MyTestTable m
END
GO
I have an object in C# client:
public class MyTestResponse
{
public decimal AmountToAllocate { get; set; }
}
Now, if I execute the store proc with Insight.Database, the returned object has AmountToAllocate property, but its value is 0, instead of 177279.73.
I have no idea what went wrong, and why the mapping does not work properly.
Does anyone know how to resolve it? Thank you
Despite you solving your own problem, for reference for anyone else in the future, you can find all of the SQL Server data type mappings in C# in SQL Server Data Type Mappings.
Money maps to Decimal.

Firebase Database Update creating duplicate node [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a users object, in that I am trying to update a specific node(status) by using the firebase update(payload) method. But when I try to do that, instead of updating the value in the parent node, it creates a new child node(duplicate node) with the value being updated there.
let firebaseApp = firebase.initializeApp(firebaseConfig);
let uniqueID = "OEHCrSnKFrd87JDivvA0sLMnj8u1"
firebaseApp.database()ref("users/" + uniqueID).update({
status: false
})
Duplicate node image
On .update() you have to specify the path for the key.
try the following:
let firebaseApp = firebase.initializeApp(firebaseConfig);
let uniqueID = "OEHCrSnKFrd87JDivvA0sLMnj8u1"
let updates = {};
updates["/status"] = false;
firebaseApp.database()ref("users/" + uniqueID).update(updates)

how to delete randomly generated id into sub node in firebase [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
{
"likes" : {
"-K_4PuiqVo6BsIsL0tMD" : {//post reference id
"-K_4Pv_JXQHW_LoDNUJY" : {//'like' id(randomely generated)
"id" : "TYS111088",
"photoUrl" : "https://web.smm:8081/Emp_Images/Upload/Emp_Photo/t_TYS111088-c22cbe899f.JPG",
"username" : "Anubhav"
},
"-K_4QP-lGvH9K2cljSIh" : {//'like' id(randomely generated)
"id" : "TYS111088",
"photoUrl" : "https://web.smm:8081/t_TYS111088-c22cbe899f.JPG",
"username" : "Anubhav"
}
}
}
I want to delete particular 'like'id node(with details),on click of dislike button. I am using android app.
We don't know the platform but the answer is very similar
let ref = myRootRef.child("likes")
.child("-K_4Fbj0wBmZf3_l-uXe")
.child("-K_4FdjaJgPoR0EGwexB")
ref.removeValue()
you can also delete data by setting using ref.setValue and setting it to nil.
I think that you have structured your data wrongly. You want to use on("child_added") on "likes". Once you have all childs,
you want to delete a child via user input (e.g. you have a delete button with the referense to the current key)
When storing: ref("likes").push()
When retrieving: ref("likes").on("child_added")
In the data viewer (what you're looking at) you can hover over a node and you'll have the ability to add a new child (green + button) or delete the node (red X button).

how to download all MS access attachments using R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Improve this question
I have around 100 rows in MS Access, each row includes an attachment. Using RODBC in R I can access the table but have no idea how to access attached files and download them in R
could you plz help me how to do it
Attachments in MS Access are special data types that actually involve nested tables for metadata (filename and filedata) information. Hence, you cannot access this data with DML SQL statements alone via RODBC but can using a COM interface, specifically connecting to the DAO SaveToFile() method.
Consider the following using the RDCOMClient package which allows interfacing to the Access Object Library. Do note: in order to run the below code, you must have MSAccess.exe (the MS Office GUI program) installed and not just the .accdb file. In the SQL query below, ColAttach is the name of the attachment field in your table and you must use those qualifiers .filedata and .filename. DAO recordset field numbers are zero based (hence the 0 and 1).
library(RDCOMClient)
# INITIALIZING OBJECTS
accApp <- COMCreate("Access.Application")
accApp$OpenCurrentDatabase("C:\\Path\\To\\Database.accdb")
docmd <- accApp[["DoCmd"]]
db <- accApp$CurrentDb()
rst <- db$OpenRecordset("SELECT ColAttach.filedata, ColAttach.filename FROM TblAttach")
while(rst$EOF() == FALSE){
rst$Fields(0)$SaveToFile(paste0("C:\\Path\\To\\Output_", rst$Fields(1)$Value()))
rst$MoveNext()
}
# CLOSING OBJECTS
rst$close()
docmd$CloseDatabase()
accApp$Quit()
# RELEASING RESOURCES
accApp <- db <- docmd <- rst <- NULL
rm(rst, db, accApp)
gc()
For multiple attachments, loop through the child recordset on each filename and filedata values (notice the different SQL). Be sure to check if file exists and destroy accordingly else you will receive a COM error:
rst <- db$OpenRecordset("SELECT ID, ColAttach FROM TblAttach")
while(rst$EOF() == FALSE){
childRS <- rst[['ColAttach']]$Value()
while(childRS$EOF() == FALSE){
if (file.exists(paste0("C:\\Path\\To\\Output_", childRS[["filename"]]$Value()))) {
unlink(paste0("C:\\Path\\To\\Output_", childRS[["filename"]]$Value()))
}
childRS[["filedata"]]$SaveToFile(paste0("C:\\Path\\To\\Output_",
childRS[["filename"]]$Value()))
childRS$MoveNext()
}
rst$MoveNext()
}

Wordpress; if user exists auto change username [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am coding a custom register page for my wordpress site. I am actually hiding the WP registering/member function a bit. This means that people fill in their info, automatically a username is created (combination first + lastname), auto a password is created, and people get logged in automatically. No confirmation e-mail is sent, so people are not aware that they actually created an account and are logged in. Now i have 2 questions:
I was wondering if it would be possible that if a username already exists, people get logged in automatically, for instance by updating all the fields (including password) and log in the user.
If that is not possible (I guess it is not); would it be possible that when the username exists, automatically the username is changed to a combination of: firstname, lastname+number. So: Peter Hanks, Peter Hanks 1, Peter hanks 2 etc. when a username exists?
Hope someone can help me out on this.
Thanks a lot!
You can update the password with wp_set_password
http://codex.wordpress.org/Function_Reference/wp_set_password
After that, you can auto login with wp_signon
http://codex.wordpress.org/Function_Reference/wp_signon
Example (Not tested)
wp_set_password($new_password);
$creds = array();
$creds['user_login'] = $username;
$creds['user_password'] = $new_password;
wp_signon( $creds, false );

Resources