AmplifyJS , remove a stored object - amplifyjs

I started using amplifijs and I successfully stored and retrieved my objects in the storage, but I don't know ho to remove them by name.
I used this syntax:
amplify.store("name",{valName1:"val1", ...});
var storage = amplify.store("name");
var val1 = storage.valName1;
How can I remove them by name like?
amplify.remove("name");

I found the answer :
amplify.store("name",null);

Related

Terraform: getting project id from azuredevops_project resource. Error data.azuredevops_projects.projectname.projects is set of object with 1 element

I am trying to access azuredevops project from terraform using azuredevops_devops resource. Using that project, I want to access repositories and create a new repo. But I am getting error in the second data block where I try to assign to project_id, but the output block prints the correct details.
data "azuredevops_projects" "sampleproject"{
name = "sample"
}
output "projectdetails"{
value = [for obj in data.azuredevops_projects.sampleproject.projects : obj.name]
}
error I receive here is: Incorrect attribute value type.data.azuredevops_projects.sampleproject.projects is set of object with 1 element :
data "azuredevops_git_repository" "samplerepo"{
project_id = [for obj in data.azuredevops_projects.sampleproject.projects : obj.name]
name = "Services-Template"
}
I am new to terraform, just practicing this for learning purpose.
Thanks for your answers, I tried everything but the below solution worked
initial outcome:
+ projectdetails = [
+ "74899dhjhjk-8909-4a97-9e9b-73488hfjikjd9",
]
outcoume after below solution:
element(data.azuredevops_projects.sampleproject.projects.*.project_id,0)
"74899dhjhjk-8909-4a97-9e9b-73488hfjikjd9"

Set map id using folium?

I m using folium (Django/Python), I create a map:
def create_map():
m = folium.Map(location=[9.934739, -84.087502], zoom_start=7 )
.....
folium creates the map in JS this way:
var map_e87b2e996ca04be59a5cfedabc0bf1ad = L.map(
"map_e87b2e996ca04be59a5cfedabc0bf1ad",
{
center: [9.934739, -84.087502],
.....
}
);
What I need is a way to set the my own id from folium(Django) instead of the on-the-fly id created by deafult: map_e87b2e996ca04be59a5cfedabc0bf1ad
I need to do this because I want to create custom events on the map that affects others part of the html file where this map is embedded .
The full id is a combination of map._name and map._id If you want to override it, you can use something like:
map = folium.Map()
map._name = "map_name"
map._id = "1"
then if you call it with map.get_name() it will be map_name_1
You could reverse the problem, and rather managing the name yourself, use the specific one folium assigns in your custom HTML/CSS/JS, which you can access via some_map.get_name().

Name email attachment in Google Apps Script

I have the following G.A.S script to email a google sheet as a pdf attachment.
var spreadsheet = SpreadsheetApp.getActive();
var subject = spreadsheet.getRange("U1:U1").getValues();
var emailTo = spreadsheet.getRange("V1:V1").getValues();
var message = spreadsheet.getRange("W1:W1").getValues();
var pdf = DriveApp.getFileById(spreadsheet.getId()).getAs('application/pdf').getBytes();
var attach = {fileName:subject,content:pdf, mimeType:'application/pdf'};
MailApp.sendEmail(emailTo, subject, message, {attachments:[attach]});
The above code works well except that the file attached to the email message has a bizarre name like "[Ljava.lang.Object_#4e63998c" with no ".pdf" extension!
I am looking for a way to set a name for the pdf file before being attached to the email. The file name should equal the "subject" variable.
Thanks in advance.
Omid
Values retrieved by getValues() is 2 dimensional array. I think that the filename becomes such string because the array is used as the filename. Please retrieve the element from the array and try again. So could you please modify as follows?
From :
var attach = {fileName:subject,content:pdf, mimeType:'application/pdf'};
To :
var attach = {fileName:subject[0][0],content:pdf, mimeType:'application/pdf'};
You can also use the following modification. In this case, getValue() can retrieve the value as a string from the cell "U1".
From :
var subject = spreadsheet.getRange("U1:U1").getValues();
To :
var subject = spreadsheet.getRange("U1:U1").getValue();
Reference :
getValue()
getValues()
If this was not what you want, please tell me. I would like to think of other solutions.
I'm a bit late, but another way to solve this problem might be:
var spreadsheet = SpreadsheetApp.getActive();
var subject = spreadsheet.getRange("U1:U1").getValues();
var emailTo = spreadsheet.getRange("V1:V1").getValues();
var message = spreadsheet.getRange("W1:W1").getValues();
var pdf = DriveApp.getFileById(spreadsheet.getId())
.getAs('application/pdf')
.getBlob()
.setName(subject);
MailApp.sendEmail(emailTo, subject, message, {attachments:[pdf]});
The Blob class has a setName method https://developers.google.com/apps-script/reference/base/blob#setName(String), that can be chained into a Blob object (which is the result of getBlob())
After that you just need to add the Blob object inside attachments array of function MailApp.sendEmail

Swift: Indirect access / mutable

I need to go to a referenced structure:
class SearchKnot {
var isWord : Bool = false
var text : String = ""
var toNext = Dictionary<String,SearchKnot>()
}
When inserting, I need to update values in toNext dictionary. Because I want to avoid recursion, I do it in a loop. But there I need a variable which jumps from one toNext item to the other, able to change it.
var knots = toNext
...
let newKnot = SearchKnot()
knots[s] = newKnot
The last command only changes a local copy, but I need the original to be changed. I need an indirect access. In C I would use *p where I defined it as &toNext. But in Swift?
I found a solution. I remembered old pascal days. ;-)
I don't use the last reference, but the second last. Instead of
knots[s]
I use
p.knots[s]
For hopping to the next knot, I also use
p = p.knots[s]
and could use
p.knots[s]
again. Also p.knots[s] = newKnot works, because p is local not the entire term.

split values of couch db result

I want to split the values selected from couch db in gwt according to a particular id. I tried to use the String tokenizer but couldn't found something useful. the result returned from couch db is in the following format:
{"_id":"2","_rev":"1-717f76046030a683687ace9ac8f7bdbf","course":"jbdgjbj","passwd":"rty","phone":"24125514444","clgnme":"bjfbjf","address":"jbjfbjb","name":"meenal","cpasswd":"rty","user":"2","fname":"jfbg"}
I just want to get the values and set them in textboxes.
how to do it?
try this ...
Session studentDbSession = new Session("localhost",5984);
Database studentCouchDb = studentDbSession.getDatabase("student");
System.out.println("select");
Document d = studentCouchDb.getDocument(input);
if(d.containsKey("FirstName")){
fname=d.getString("FirstName");//fname is variable
}
if(d.containsKey("LastName")){
lname=d.getString("LastName");//lname is variable
}
if(d.containsKey("Address")){
add= d.getString("Address");//add name is variable
}
finally concatenate all strings and return to client...
all=fname+" "+lname+" "+add;
return all;
This looks like JSON. You can parse it using JSONObject:
JSONObject obj = new JSONObject(yourString);
String course = obj.getString("course");