Menu
  • HOME
  • TAGS

Chef Data Bags and dynamic variable passing

Tag: dynamic,data,chef,bag,databags

I am trying to figure out a way to get the below code work; I have tried various methods but the chef-client run breaks at the 3rd line.

lsf = "#{node[:env]}"+"_ls"
dsf = "#{node[:env]}"+"_ds"

dsTemplateBag = data_bag_item('configTemplates', "#{dsf}") 
lcTemplateBag = data_bag_item('configTemplates', "#{lsf}")

However on another test recipe I was able to successfully get the following working:

env = "test"

dsTemplateBag = data_bag_item('configTemplates', "#{env}")

I am quite new to Chef and please can someone advise me on how to get this working ?

Best How To :

After a little bit debugging I realised there was a typo preventing the data bag to be properly used; hence issue.

dsTemplateBag = data_bag_item('configTemplates', "#{node[:env]}_ls")

this worked for me. And as Tensibai suggested in the above comment mixing concatenation and interpolation is not a good practice (I was desperate to make it work! In my defense).

Trying to dynamically create divs that can also be closed

javascript,html,dynamic

The issue is in your for loop. It's really unnecessary as far as I can tell. The code could be cleaned up a bit, but to solve your issue I believe the following changes will work. For some reason the code has been copied twice, use the first code snippet...

How to show data from database depending on user's choice from a select

php,jquery,database,select,data

Try this, It may help you. I have used JQuery Ajax. Also include JQuery library before use the below code. $('#myselect').change(function(){ var size = $('#myselect').val(); if(size != ''){ $.ajax({ type:'post', url:"/index.php/average_incomes_by_customer/" + size, cache:false, success: function(returndata){ console.log(returndata); //"returndata" is the result got from the DB. Use it where you want....

Polymer 1.0 data binding not working

data,binding,polymer

Call this.notifyPath('navigator.currentStep', this.navigator.currentStep). See https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#set-path. Sometimes imperative code needs to change an object’s sub- properties directly. As we avoid more sophisticated observation mechanisms such as Object.observe or dirty-checking in order to achieve the best startup and runtime performance cross-platform for the most common use cases, changing an object’s sub-properties directly...

Global name 'bluetooth' is not defined

python,data,bluetooth,connect

Hopefully this will help: http://lightblue.sourceforge.net/ This is an API for python's bluetooth feature...

javascript dynamic structure with array or object

javascript,arrays,object,dynamic

You can first create an empty object and fill it as and when the data comes like users[user.id] = {}; For an example: var users = {}; var user = {id : 1}; //Data received(Just an example) users[user.id] = {}; var session = {id1 : 1.1}; //Data received users[user.id][session.id1] =...

Data Analysis and Scatter Plot different file and different column

python,data,matplotlib,analysis

This seems like it would be a lot simpler using a Pandas dataframe. Then, part of your problem is analogous to this question: Read multiple *.txt files into Pandas Dataframe with filename as column header import pandas as pd import matplotlib.pyplot as plt filelist = ['data1.txt', 'data2.txt'] dataframe = pd.concat([pd.read_csv(file,...

Set value for Spinner with custom Adapter in Android

android,dynamic,android-arrayadapter,android-spinner

@Haresh Chhelana example is good, However if you want to show both name and code in spinner after selecting, check this out. List<Map<String, String>> items = new ArrayList<Map<String, String>>(); for (int i = 0; i < JA.length(); i++) { json = JA.getJSONObject(i); mapData = new HashMap<String, String>(); mapData.put("name", json.getString("Name")); mapData.put("code",...

How do I display my mysql table column headers in my php/html output?

php,html,mysql,table,data

Note: You can just make a single file out of it to achieve your wanted output Use mysql_real_escape_string() to sanitize the passed-on value to prevent SQL injections You should use mysqli_* instead of the deprecated mysql_* API Form them in a single file like this (display.php): <html> <form method="post" name="display"...

Convert String “2008-02-10T12:29:33.000” to a Date with the same format 2008-02-10T12:29:33.000 in Java [duplicate]

java,string,data,transform,simpledateformat

I don't believe you need to do any conversion, as there is a natural order of those strings (at least I can't see a counterexample). So Collections.sort() should do the trick....

AS3 Dynamic variable naming

actionscript-3,flash,variables,dynamic

You should use an array for this kind of list of variables. While you can create properties dynamically, you usually want to avoid it. Especially in your case, where the actual identifier of each variable is not a String, but a number. So why not use something that does exactly...

Android : Creating GUI programmatically at run time in java

java,android,user-interface,dynamic

Add a Linear/Relative layout in xml and on run time according to given number add view(buttons and text views) in this layout. See this tuts: https://androiddesk.wordpress.com/2012/08/05/creating-dynamic-views-in-android/ http://www.javacodegeeks.com/2012/09/android-dynamic-and-xml-layout.html

Ambari Monitoring raw data

api,data,monitoring,ambari

I don't clearly see why this got downvoted, but nevermind. I found the solution myself: The Ambari Metrics API can deliver the data in question, e.g. CPU load, memory usage, Network bandwith or load factors by sending a GET Request to http://&ltambari-server>:8080/api/v1/clusters/&ltcluster-name>?fields=metrics/&ltmetric>[&ltstart>,&ltend>,&ltstep>] while the metric can be network, cpu, cpus,...

AngularJS : How to make dynamic field button only for last button?

javascript,angularjs,dynamic,angularjs-ng-repeat

You can use $last inside ng-repeat which is true if the repeated element is last in the iterator. Or you can do it with css only with .row:last-of-type {/**/}.

I am getting error in this code as “invalid indirection”

c,memory,dynamic,indirection

ptr[i] means the value at address (ptr+i) so *ptr[i] is meaningless.You should remove the * Your corrected code should be : #include<stdio.h> #include<stdlib.h> #include<conio.h> int main() { int i; int *ptr; ptr=malloc(sizeof(int)*5); //allocation of memory for(i=0;i<5;i++) { scanf("%d",&ptr[i]); } for(i=0;i<5;i++) { printf("%d",ptr[i]); //loose the * } return 0; } //loose...

Use JSON file to insert data in database

javascript,json,mongodb,meteor,data

Simple use underscores _.extend function. Like this: var newProfile = _.extend( JSON.parse(Assets.getText('test.json')), {user: id} ) Profiles.insert(newProfile) ...

get value from the dynamic create textbox

c#,dynamic,value

Create an array or list of textboxes: private TextBox[] textBoxes = new TextBox[30]; And assign a new textbox to each position: for(int i =0; i<30; i++){ TextBox txt = new TextBox(); txt.Text = "ASDASDASD"; txt.ID = "txt - " + i.ToString(); textBoxes[i] = txt; data.Controls.Add(txt); } To get the value...

How to handle different event handlers with same parent?

c#,winforms,dynamic,parent

Why don't you just calculate the sum of your "point" labels at the end of both events? It is nice and simple(You could do it more efficiently but i don't this there is a reason... ) Just call TotalPoints() at the end of checkBox_CheckedChanged,txtBox_CheckedChanged int TotalPoints() { int total =...

Unknown Data Structure?

java,data-structures,data

There is no "name" for this that I know of, but an array of linked list nodes would work quite well for this. Traditionally linked lists are separate and simply a row of items pointing to the next. However, there is no reason why certain linked list nodes cannot point...

Double integration using experimental data

matlab,data,integration,splines

First of all, you should not use the same letter for a bunch of things; your code is pretty hard to read because one has to figure out what T means at every instance. Second, pure math helps: after a change of variables and simple computation, the double integral becomes...

Can I dynamically set the recipient of mailto: using only HTML and JavaScript depending on URL used to access the site?

javascript,html,email,dynamic,mailto

var l=window.location+''; l=l.replace(/http(s*):\/\/(www\.)*/,''); l=l.split('/')[0]; //get the domain var mailto='privacy-'+l+'@example.com'; ...

Trying to return one dataset from a function that prints from two functions

python,list,csv,input,data

Best part in Python is that creating new objects on the fly is very easy. You can make a method return a tuple of two values. def dataPrinter(): gen1 = headerBody(columns_no) gen2 = dataBody(columns_no) return gen1, gen2 And from the calling side, you can get them either as a single...

How to use Dynamic Variables?

excel-vba,variables,dynamic

Y10 cannot be the name of variable (because it could be confused with cell Y10). Code that attempts to use such variable names will not work. Try other name, for example y_10 will be fine.

Building totals based on condition in another row

tsql,data,pivot

Your table seems to have some serious normalization issues. You have to perform an INNER JOIN on AssessmentCode first: SELECT t1.StudentID, t1.AssessmentCode, t1.Result AS Level, CAST(t2.Result AS INT) AS Mark FROM ( SELECT StudentID, AssessmentCode, Result FROM mytable WHERE ResultGroup = 'IBLevel' ) AS t1 INNER JOIN ( SELECT StudentID,...

Swift xcode advise where to store data

ios,xcode,data,store

As the first comment says, your question is quite large. When you say 'one form on several view', I consider it as 'one form per view'. Keep It Simple S... ;) (Except if you use page control for your form.) Basically, you have three ways to store data : NSUserDefaults...

How to alter dynamic/live element attributes - (replaceWith()) used

jquery,dynamic,replace,live

I think the only thing you're maybe not wrapping your head around is the idea of callbacks and asynchronous methods. You're currently running your console.log statements before the replaceWith occurs. The function() { } block (your "callback") passed as the second parameter to $.get doesn't execute until the AJAX call...

C# Delete Row with Dynamic Textbox/Button/Grid

c#,wpf,button,dynamic,textbox

WPF's ItemsControl is the correct way to show items in your views when the number of items can change. Many controls inherit from ItemsControl, like the ComboBox itself, or the DataGrid, or the ListBox... But in this example I'll use ItemsControl directly, since what you're trying to do doesn't need...

SVG data image not working on Firefox

css,image,firefox,svg,data

The # character in a URL is reserved to indicate the start of a fragment identifier. You must URL encode the data URL contents, which means converting any hash characters in the data URL to %23...

How can I rewrite this LINQ query with reflection

c#,linq,dynamic,reflection

Use the reflection to create the query, not in the query. Consider: public static IQueryable<Profile> Filter( this IQueryable<Profile> source, string name, Guid uuid) { // .<name>UUID var property = typeof(Profile).GetProperty(name + "UUID"); // p var parExp = Expression.Parameter(typeof(Profile)); // p.<name>UUID var methodExp = Expression.Property(parExp, property); // uuid var constExp =...

At most k adjacent 1s (Maximum Value limited neighbors)

arrays,algorithm,dynamic,dynamic-programming

M[i, j] is max sum from 1 to i, with j adjacent 1s The answer we need is M[n, k] which can be computed as the max of 3 situations: a[i]=0 => S=M[i-1, j] a[i]=1 and a[i-1]=0 => S=M[i-2, j]+a[i] a[i]=1 and a[i-1]=1 => S=M[i-1, j-1]+a[i] so the recursive rule...

jquery use data tag selector after updating data tag on element

javascript,jquery,data,tags

Your question is answered here: jQuery .data() Not Updating DOM $('#foo li[data-my-key="54321"]') is a attribute selector. Using .data(..) changes the elements properties which you cannot select from without using a filter. If you want to get all the elements with a certain property you can do this (using filter(...)): $('#foo...

Dynamic lambda wrapped with try catch

c#,linq,dynamic,lambda

After some more tries I got this working. The solution was to use the trycatch to wrap the expression's body and not the expression itself then create the resulting lambda using the expression parameters. Otherwise I got something like (not sure there) a Func<ModulelItem, bool, bool> So the final code...

Method declared with dynamic input parameter and object as return type in fact returns dynamic

c#,.net,dynamic,visual-studio-2013

The problem is that you're calling a method with a dynamic argument. That means it's bound dynamically, and the return type is deemed to be dynamic. All you need to do is not do that: object dObj = "123"; var obj = Convert(dObj); Then the Convert call will be statically...

parsing JSON files in python to get specific values

python,json,parsing,data

Json.loads will also decode that dictionary. So to access cpu_count for example it would be json_data["Hosts"]["cpu_count"]. The json library will turn everything into a standard python data type (dict, list, int, str) or from those data type into a json readable format. You can also define a parser to parse...

Replicating tables within the database

java,database,database-design,data

If you can populate D via a single query, then back a view with that query and you're done (I'm pretty sure most popular sql servers don't allow, say, procedure backed views). Otherwise, yea, you'll have some process that turns data from a,b,c into d. That can be through stored...

Method for Storing and organizing data submitted by user to a website (form, pdf)?

php,sql,database,data,website

There are a lot of options: you might switch from Excel to Access (if your customer has a license for it) and have Access read the same database your PHP program writes to. To notify them of changes you can send an email (only for notification, not for transfer of...

Can I use scikit-learn with Django framework?

django,data,scikit-learn,analysis

Django is a python framework meaning that you need to have python installed to use it. Once you have python, you can use whatever python package you want (compatible with the version of python you are using).

Team Page With Dynamic Content - Need Help Using JQuery to Pull Image Content

javascript,jquery,html,css,dynamic

I think this is what you are looking for. $(function(){ $('.profilepic').on('click', function(e){ var $biginfo = $('#teamcontent'); var $bigname = $('#bigname'); var $bigjob = $('#bigjob'); var $bigdesc = $('#bigdesc'); var $pic = $(this).attr('src'); $('.bigimg').attr('src', $pic); var newname = $(this).attr('alt'); var newrole = $(this).siblings('.job').eq(0).html(); var newdesc = $(this).siblings('.desc').eq(0).html(); $bigname.html(newname); $bigjob.html(newrole); $bigdesc.html(newdesc); if($biginfo.css('display')...

Spring Data JPA user posts

java,spring,jpa,data

Create a second entity (java class) e.g. UserPost: @Entity @Table(...) public class UserPost { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private long userId; ... } Then add @OneToMany relationship field to User. Cascading, lazy-loading, etc. depends on how you'd use it. It'd look like this inside User: @OneToMany(cascade={...}) @JoinColumn(name="userId")...

R Data Wrangling for Emails

r,data,data-cleansing

try this df <- data.frame(Email.Address, First.Name, Last.Name, Company, stringsAsFactors = FALSE) Corp <- sapply(strsplit(sapply(strsplit(df$Email.Address,"@"),"[[",2),"[.]"),"[[",1) F.Name <- sapply(strsplit(sapply(strsplit(df$Email.Address,"@"),"[[",1), "[.]"),"[[",1) L.Name <- sapply(strsplit(sapply(strsplit(df$Email.Address,"@"),"[[",1),"[.]"),tail,n=1) L.Name[L.Name == F.Name] <- NA OUT <- data.frame(df$Email.Address, F.Name, L.Name, Corp) df[df=="NA" |is.na(df)] <- OUT[df=="NA" |is.na(df)] df the function...

IDynamicMetaObjectProvider set property using literal name

c#,dynamic

In some cases like ExpandoObject, then you can use the IDictionary<string,object> API instead: ExpandoObject obj = ... var dict = (IDictionary<string, object>)obj; object oldVal = dict[memberName]; dict[memberName] = newVal; In the more general case of IDynamicMetaObjectProvider: you could borrow the CallSiteCache from FastMember: internal static class CallSiteCache { private static...

How to store simple text data in the python program itself? [closed]

python,data

For basics, you should check out the JSON library from Python: https://docs.python.org/2/library/json.html Here's a quick example: >>> import json # grabs config.json in same directory as python file >>> with open("config.json", "r") as e: ... myconfig = json.load(e) >>> print myconfig {u'4': u'5', u'6': 7} # dump to string representation...

Send events to two separate google analytics accounts?

javascript,data,google-analytics

Sure. Just be sure each account has it's own tracking ID. Then, something like the following (after including the analytics code, of course): ga('create', trackingId1, window.location.hostname); ga('send', 'pageview'); ga('create', trackingId2, 'auto', {'name': 'secondAccount'}); ga('secondAccount.send', 'pageview'); I'm sure there is documentation for this on Google, but the Analytics docs are a...

Powershell Data input [closed]

powershell,input,data

Try this: $PCname = Read-Host "Please enter the PC Name" $Userid = Read-Host "Please enter the Uder ID" Copy-Item -LiteralPath \\$PCname\C`$\Users\$UserID\AppData\Roaming\Nuance\NaturallySpeaking12\Dragon.log -Destination "\\Static PC\C`$\Users\MyName\Desktop\Dragon Logs" -Force $PCname and $Userid are examples of powershell variables. The values are to be entered when you run the script. The other answer is trying...

Oracle Apex dynamically enable/disable text field depending on LOV selected value

javascript,dynamic,action,oracle-apex,lov

Create a Dynamic Action with the following parameters: Event: Change Selection Type: Item Item: Condition: in list Values: < The LOV values that should disable the other items separated by comma > True Action: Action: Disable Selection Type: Item Item: < Choose the item(s) to disable > False Action: Action:...

Insert data in collection at Meteor's startup

javascript,json,meteor,data,startup

Ok, you'll want to check out Structuring your application. You'll have to make the file with the definition load earlier, or the one with the fixture later. Normally you have your collections inside lib/ and your fixtures inside server/fixtures.js. So if you put your insert code into server/fixtures.js it'll work....

How can I set a Button's type to “Button” (as opposed to the default “Submit”) in C#?

c#,dynamic,sharepoint-2010,submit-button,htmlbutton

Use HtmlButton instead of Button if you want the "HTML button tag" var btn = new HtmlButton(); btn.Attributes["class"] = "bla"; btn.Attributes["type"] = "button"; Button renders <input type="submit" /> and Button.UseSubmitBehavior renders <input type="button" />. HtmlButton will render <button type="YOUR_DEFINITION"></button>....

Most efficient way to implement table with multiple column?

java,data,structure

You can use Guava's Table. For instance using a HashBasedTable: Table<RowType, ColumnType, String> table = HashBasedTable.create(); ...

Extjs building form on metadata

json,extjs,model-view-controller,dynamic

Surely possible. Basically you use your metadata as items and create the form at any time: var metadata = [ { "allowBlank": false, "fieldLabel": "labelText1", "name": "labelName1", "emptyText": null }, { "allowBlank": false, "fieldLabel": "labelText1", "name": "labelName1", "emptyText": null } ]; Ext.create('Ext.form.Panel', { defaultType: 'textfield', width: 300, bodyPadding: 10, renderTo:...

Read data only when it is present

matlab,data,serial-port,fscanf

Read only when data present You can read out the BytesAvailable-property of the serial object s to know how many bytes are in the buffer ready to be read: bytes = get(s,'BytesAvailable'); % using getter-function bytes = s.BytesAvailable; % using object-oriented-addressing Then you can check the value of bytes to...

Make dynamic links (with ?) return error 404 not found

apache,.htaccess,dynamic,hyperlink,http-status-code-404

I assume you're asking for any request containing a query string to return a 404. If that is what you want, use the below: RewriteEngine On RewriteCond %{QUERY_STRING} .+ RewriteRule .* - [R=404,L] This will use the regex .+ to check if there are one or more characters in the...