w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I share options parsing code within bash functions when using getopts?
Pass the generic option parser a list of options that the calling script will be managing. For each option to be managed in the calling script, create a function called option_X_parser. These option parser functions should accept an optional argument ($OPTARG), and should return 0 (success) or 1 (error). The generic option parser should build a shell case statement using its generic options (e.g., "h", "n", and "v") as well as the supplied options from the calling program. For those options that have an associate option parser function, the case statement should include invocations of the option parsers. There should be a case statement for each configured option, which should invoke the user supplied functions, if defined, or be managed generically by setting global variables (.e.g.,

Categories : Bash

Parsing ALL Highcharts Options from JSON
Well, it should be valid json, not valid javascript. So strip the var and start immediately with the opening brace, remove the ; at the end and add double quotes around each property name. So it looks like this: { "chart" : { ... ... } Then do the same as your example, just pass the response as is to the HC constructor: $.getJSON( 'options.json', function( options ) { new Highcharts.Chart(options); });

Categories : Highcharts

switch case for parsing options
If you want to iterate through program arguments looking for the terminating null pointer, your outer cycle should be while (*++argv) not the while (++*argv) // <- incorrect! that you have in your code. Your switch expression is written incorrectly. While your intent is clear, your implementation ignores operator precedence. This switch (*argv[1]) { // <- incorrect! should actually be switch ((*argv)[1]) { The previous if if (**argv == '-') is fine, but since it is equivalent to if ((*argv)[0] == '-') // <- better maybe you should rewrite it that way as well, just for consistency with switch.

Categories : C

Changing the value of an argument and using options in bash
git() is the beginning of a function definition (the keyword function is optional when the function name is followed by parentheses). If you want to call a function git() you need to define it first, and call it without the parentheses: function git() { # do stuff } git It's not good practice to create functions with the same name as existing binaries, though. In your case you should probably just call git clone with the line read from the file: while read -r line; do git clone "$line" done < "${file}" Edit: Updated, since the question changed significantly. Your argument processing is … weird, to be frank. When you're using an option parser, you shouldn't work around the way that option parser works. "g:" means an option -g with exactly one argument. Don't try

Categories : Bash

Options for Parsing Excel Files in ExtJS
Number two is going to be the better option IMO. You can take a look at the FileUploadField control - there is a good example on submitting the Form that will upload the file to the server: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.File From there you can parse and return the json.

Categories : Node Js

getopts is not parsing my command line options
Unlike the (older) getopt, getopts does not rearrange the arguments to put the options first. Therefore, in ./getopt.sh arg1 -s opt1 option-parsing stops as soon as the non-option arg1 is seen.

Categories : Bash

Parsing command line options using TSQL
you can do something USE [DEI] GO /****** Object: UserDefinedFunction [dbo].[fnSplit] Script Date: 07/06/2013 00:00:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create FUNCTION [dbo].[fnSplit]( @sInputList VARCHAR(8000) -- List of delimited items , @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items ) RETURNS @List TABLE (item VARCHAR(8000)) BEGIN DECLARE @sItem VARCHAR(8000) WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0 BEGIN SELECT @sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))), @sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList)))) IF LEN(@sItem) > 0 INSERT INTO @List SELECT @sItem END IF LEN(@sInputList) > 0 INSERT INTO

Categories : Sql Server

Bash test with no options appears to work, but why?
You're correct. From the test(1) man page: -n STRING the length of STRING is nonzero STRING equivalent to -n STRING

Categories : Bash

Bootstrap Condensed Nav
You could create a new selector in your CSS to overrule the padding-top and padding-bottom rules of the .nav-tabs > li > a selector. See bootstrap.css line 4068 (as per the CSS file used on the Bootstrap documentation site). .nav-tabs.nav-stacked.nav-condensed > li > a { padding-top: 4px; padding-bottom: 4px; } /*original padding value 8px*/

Categories : HTML

Can Linux Bash scripts respond to install options
To establish whether the scripts support any command line options, you can: Read the readme file of the software, if there is one. This should explain any options. Read the top of the install.sh script. Usually options are at least listed there. Read the code itself, which might be a lot of work. Once you have established that the scripts do not support options, the standard way of automating this would be with an expect script. See for example automating install.sh script using an expect script. Depending on how the install script works, you may be able to send it commands on standard input. For example, if you press Tab once, then Enter, then y and lastly Enter again, you can try the following: printf %s $' y ' | ./install.sh

Categories : Linux

BASH string parsing
You could use for example sed. Follows an example to tokenize the string you pointed: #!/bin/sh DATA="CRITICAL - mempool lsmpi_io usage is 99.99%, mempool Processor usage is 34.38% | 'Processor_usage'=34.38%;80;90 'lsmpi_io_usage'=99.99%;80;90" echo "$DATA" | sed "s@.*'Processor_usage'=([0-9.]*)%;([0-9.]*);([0-9.]*) .*@1 2 3@" | while read p w c; do echo p=$p echo w=$w echo c=$c done

Categories : Bash

Boost program options- crash on parsing command line
Looking at the tutorial, I don't see commas between the options. ie: desc.add_options() ("help", "produce help message") // no comma here! ("compression", po::value<int>(), "set compression level") ; Try removing the commas you have at the end of each option.

Categories : C++

How to use Python condensed For loop with if else
Use a conditional expression on the left-hand side of the list comprehension: ["http://www.fetise.com/" + i if "http://www.fetise.com/" not in i else i for i in lista] This produces: >>> pprint(["http://www.fetise.com/" + i if "http://www.fetise.com/" not in i else i for i in lista]) [u'http://www.fetise.com/apparel/shirts', u'http://www.fetise.com/apparel/tees', u'http://www.fetise.com/apparel/tops-and-tees', u'http://www.fetise.com/accessories/belts', u'http://www.fetise.com/accessories/cufflinks', u'http://www.fetise.com/accessories/jewellery', u'http://www.fetise.com/accessories/lighters', u'http://www.fetise.com/accessories/others', u'http://www.fetise.com/accessories/sunglasses', u'http://www.fetise.com/accessories/ties-cufflinks', u'http://www.fetise.com/acces

Categories : Python

parsing an .kml file in bash script
With bash if your lines are in order: while read WHEN && read GXCOORD; do echo "$WHEN : $GXCOORD" done < test.kml Or perhaps do it this way: while read WHEN && read GXCOORD; do echo "$WHEN : $GXCOORD" done < <(exec grep -Fe "<when>" -e "<gx:coord>" test.kml) And also perhaps trim out the tags: while read WHEN && read GXCOORD; do WHEN=${WHEN##*'<when>'} WHEN=${WHEN%%'</when>'*} GXCOORD=${GXCOORD##*'<gx:coord>'} GXCOORD=${GXCOORD%%'</gx:coord>'*} echo "$WHEN : $GXCOORD" done < <(exec grep -Fe "<when>" -e "<gx:coord>" test.kml)

Categories : Linux

How to get condensed logging 'spring style'
If you are familiar with log4j I would use use logback: http://logback.qos.ch/ http://logback.qos.ch/manual/layouts.html#conversionWord EDIT: Apparently also supported in log4j: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/EnhancedPatternLayout.html

Categories : Java

Multiple tables condensed to one row with various totals
The database design seems seriously fubar'd, so the data appear to be inconsistent: These rows appear to contradict one another: H0001 Host_1 T0002 MS Windows Server 2008 H0002 Host_2 T0002 Red Hat Enterprise Linux 3 as do these: T0003 Red Hat Enterprise Linux 3 Operating System T0003 Oracle Database Server 9i 9.2 Software Product I'm gonna assume that the data is invalid, and that the correct data is along the lines in the SQL Fiddle. Under that assumption this code will get you what you need: select a.app_ID, a.app_name, (select Count(*) from apphost ah inner join hostti ht on ah.host_id = ht.host_id inner join ti on ht.ti_id=ti.ti_id where ti_type = 'Operating System' and ah.app_id = a.app_id) as OSCount,

Categories : Sql Server

Why are condensed fonts not displayed properly in FireMonkey?
This seems to only affect fonts within families - if the font does not exist in the fonts folder under its own family name. Arial Narrow, for example, is a font within the "Arial" font file (it exists within a family and is not, per se, a family unto itself). Typically a font family would include the four styles only Arial (naively contains) Arial Regular Arial Bold Arial Italic Arial Bold Italic "Arial Narrow", however, exists within the "Arial" family alongside the standard styles - ie : Arial (actually contains) Arial Regular Arial Bold Arial Italic Arial Bold Italic Arial Narrow Arial Narrow Bold Arial Narrow Italic Arial Narrow Bold Italic Arial Black It seems that FMX is only looking one level deep within any given font family and is not looking at any style variant th

Categories : Delphi

Trivial solution for parsing nested configuration in Bash?
Bash is not the right language for this. There are no nested arrays, and dynamic variable assignment is a bit of a mine field compared to languages like Python and Ruby. That said, it sounds like you're specifying the format and parser yourself, so you could simply use a hierarchical naming scheme for your configuration: foo_bar_key="value" foo_baz_key="value"

Categories : Bash

parsing urls from a text file to bash shell array
Pure bash way: array=($(<inFile)) then: # list all the elements of array echo "${array[@]}" # echo num of elements in array echo ${#array[@]} ## OR loop through the above array for i in "${array[@]}" do echo $i # or do whatever with individual element of the array done # 1st element of array echo ${array[0]} # 2nd element of array echo ${array[2]} # ...

Categories : Arrays

Roboto Condensed Font not rendering properly in mozilla firefox
I'm using the one off the Google Fonts Api and it works in Firefox: @font-face { font-family: 'Roboto Condensed'; font-style: normal; font-weight: 400; src: local('Roboto Condensed Regular'), local('RobotoCondensed-Regular'), url(http://themes.googleusercontent.com/static/fonts/robotocondensed/v7/Zd2E9abXLFGSr9G3YK2MsNxB8OB85xaNTJvVSB9YUjQ.woff) format('woff'); } Maybe try specifying style and weight.

Categories : CSS

Why is font-stretch:condensed an invalid property value in Google Chrome?
The font-stretch property isn't part of any final standard and Chrome doesn't support it. See font-stretch on MDN.

Categories : CSS

Bash / Regex Parsing only Domain Names In File containing both Domans and Email Addresses
if your file contains only domain and email addr, try this line: grep -v '@' file test with your example: kent$ echo "john3525@aol.com brenda392@yahoo.com xyx.net boxers.on.ca helloworlds.co.uk"|grep -v '@' xyx.net boxers.on.ca helloworlds.co.uk

Categories : Regex

how to pass parameters to Handlebars helper? What's the difference between options.hash & options.data
Parameters passed to a helper become arguments to the helper function. The values you provide in the template immediately after the {{helperName become the arguments. The last argument passed to the helper is an options object that provides additional information to helper like, an options.hash and options.contexts, etc. Key value pairs provided after the parameters correspond to the options.hash property. For a hello helper that takes 3 arguments, the helper would be, Ember.Handlebars.helper('hello', function(a, b, c, options) { return '%@ - %@ - %@'.fmt(a, b, c); }); The hello helper can be used in a template like so, {{hello lorem ipsum dolor}} Here the values of lorem, ipsum, and dolor properties would be used and returned as a combined string. In addition to the required ar

Categories : Ember Js

JComboBox in JTable not displaying options, only the correct number of blank options
After the first while loop navigates across the ResultSet rs the subsequent while loop is never entered as there as no more available records and rs.next() returns false while (rs.next()) { items[count] = rs.getString("parts"); ... } Rather than determine the size of the String array items using a separate loop, use an Vector<String> to build a collection of Strings. This can then be passed directly to the JComboBox constructor after a single navigation of the ResultSet. Vector<String> data = new Vector<>(); while (rs.next()) { data.add(rs.getString("parts")); } count = data.size(); JComboBox<String> jcb = new JComboBox<>(data); As a bonus the count variable equates to data.size()

Categories : Java

Allowed Options in NSJSONSerialization class method dataWithJSONObject:options:error
NSJSONWritingPrettyPrinted is the only option supported at this time. You can provide 0, of course, if you don't want pretty printing. You can find a discussion of it at the bottom of this page. kNilOptions equates to 0, but it's included as part of the Carbon APIs, not Cocoa.

Categories : Objective C

Disabling/Removing Select Options created via a Knockout options binding
Not sure if I understand correctly, but it sounds like you're looking for Computed Observables: self.AvailableItemTypes = ko.computed(function() { var selectedTypeIds = this.SelectedItemTypes().map(function(el) { return el.Id; }); return this.ItemTypes().filter(function(el) { return selectedTypeIds.indexOf(el.Id) === -1; }); });

Categories : Knockout Js

html select control click not showing options list until mouse is hovered towards the options
it seems IE9 is blocking javascript...i hope this helps http://answers.microsoft.com/en-us/ie/forum/ie9-windows_vista/internet-explorer-9-drop-down-menus-do-not-pull-up/954c5c71-5878-40a4-b9f8-68991922e85a

Categories : Javascript

Excel: Display value from list of options if numbers begin with value from options
VLOOKUP() I believe is the right function for this. Assuming that you want the area names in column E in Sheet1 as from row 2, the phone numbers are in columnB of that same sheet and the table with prefix and area code in Sheet2 columns A and B, you can use: =VLOOKUP(LEFT(B2,5), Sheet2!A:B, 2, FALSE) LEFT(B2,5) extracts the first 5 characters from the phone number stored in B2. If there are area codes of different lengths, then the formula will have to be revised and it will be much more complex. Sheet2!A:B is the table to lookup the data 2 is the index of the column containing the values you want to get (the first index is the column containing the area codes) FALSE means exact match. I don't think you'd like to get the area code immediately smaller than the one you're looking for,

Categories : Excel

Default state (Add options) overrides my update options?
If this is a plugin, you need to set the option for the first time with register_activation_hook. If a theme, use after_setup_theme. There's an alternative technique for run_once described in this WPSE Answer that works quite well too. Here's a working example loosely based on yours and some Codex samples using run_once. Note the use of the function checked(). add_action('admin_init', function() { // Change the "init_*" to anything else to `run_once` again if ( wpse_25643_run_once('init_checkbox_default') ) { add_option('my_checkbox_default', true ); } register_setting('media','my_checkbox_default'); add_settings_field( 'my_checkbox_default', 'Checkbox:', 'my_default_checkbox_settings_function', 'media' ); }); funct

Categories : PHP

Using ng-options within a directive and getting options data from injected service
In my opinion, you have several options (as pointed out in the comments): 1. create controller for the directive In you directive's template, use a controller, i.e. <div ng-controller="SelectController"> <!-- your select with the ngOptions --> </div> and create the SelectController as a regular controller: var app = angular.module("app.controllers", []) app.controller("SelectController", ['$scope', 'myDataService', function(scope, service) { scope.options = service.whatEverYourServiceDoesToProvideThis() }]); You can also give your directive a controller, which works just the same: recManagerApp.directive(myDirective, function () { return { restrict: 'E', templateUrl: '/templates/directives/mydirective.html', scope: { m

Categories : Angularjs

GCC compiler options: which set of enabled options is correct?
From GCC documentation: --help={class|[^]qualifier}[,...] Print (on the standard output) a description of the command-line options understood by the compiler that fit into all specified classes and qualifiers. whereas If the -Q option appears on the command line before the --help= option, then the descriptive text displayed by --help= is changed. Instead of describing the displayed options, an indication is given as to whether the option is enabled, disabled or set to a specific value (assuming that the compiler knows this at the point where the --help= option is used) It appears that --help simply shows which options one can enable, while -Q allows one to see if it is actually enabled. Also: The output is sensitive to the effects of previous command-line op

Categories : C

Show options of selected options inside the same
If you are looking for a tree view layout using jquery, try this code: $('.tree li').each(function(){ if($(this).children('ul').length > 0){ $(this).addClass('parent'); } }); $('.tree li.parent > a').click(function(){ $(this).parent().toggleClass('active'); $(this).parent().children('ul').slideToggle('fast'); }); Demo and Source: http://www.webstutorial.com/jquery-treeview-list/jquery

Categories : Jquery

Options with Options with Python argparse?
In general, I think what you want is impossible because you cannot associate the optional parameter values together. That is, I can't see how to associate --param 12 with --aligner aligner1. However. You can use argparse as follows: p = argparse.ArgumentParser () p.add_argument ("--aligner", action="append", nargs="+") This will create multiple aligner arguments, each requiring at least one argument (the aligner name). You then can use an additional encoding scheme (that you can document in the help text for the parser) which encodes the parameters for each aligner. For example, you could call your script with: ./script.py --aligner aligner1 param=12 --aligner aligner2 param=30 other_param=28 You then split out the additional arguments for each aligner into a list, split by '=' and

Categories : Python

Why Can't I have multiple ng-if options in a select when using ng-options
Basically for 2 options with ng-if = true, the code actually is equivalent to <option value=""> Please Select an Approver Type: </option> <option value=""> Please Select One: </option> Since ngOptions accepts only a single hardcoded option, Optionally, a single hard-coded element, with the value set to an empty string, can be nested into the element. This element will then represent null or "not selected" option. the 1st one will be overwritten.

Categories : Javascript

Parsing huge (~100mb) kml (xml) file taking *hours* without any sign of actual parsing
For a huge XML file, you should not use default XML parser from Nokogiri, because it parses as DOM. A much better parsing strategy for large XML files is SAX. Luckly we are, Nokogiri supports SAX. The downside is that using a SAX parser all logic should be done with callbacks. The idea is simple: The sax parser starts to read a file and let you know whenever it finds something interesting, for example a tag opening, a tag close, or a text. You will be able to bind callbacks to these events, and extract whatever you need. Of course you don't want to use a SAX parser to load all file into the memory and work with it there - this is exactly what SAX want to avoid. You will need to do whatever you want with this file part-by-part. So this is basically a rewrite your parsing with callbacks l

Categories : Ruby

SQL Server 2008 Error - XML parsing: document parsing required too much memory
8191 attributes sounds too much. If looks you are trying to store actual data in the attributes - apparently SQL Server parser has a limitation here. see article here: http://blogs.msdn.com/b/sqlprogrammability/archive/2006/05/23/605299.aspx?Redirected=true When a type is needed for validation, the validator loads its definition from metadata and compiles it into a format suitable for quick validation. In order to prevent any one type from using too much memory, SQL Server caps the size of a compiled type at one megabyte. SQL Server compiles all types and performs this check when the schema is imported in order to avoid accepting types which exceed the limit. I would suggest changing the way you use XML and store you information inside element. see http://www.ibm.com/d

Categories : C#

Redirecting standard input in Bash implies that Bash executes a default action?
exec 6<&0 0</tmp/lines.txt; exec 0<&6 6<&- Turns out that bash still executes what remains in the command specified or script before it reads input for commands again that's why your file /tmp/lines.txt is not read since exec 0<&6 6<&- is run before it. Please refer back to the previous solution if you want to execute commands in /tmp/lines.txt before exec 0<&6- is executed. Also it might have not been obvious but you could use . or source to achieve same output: . /tmp/lines.txt source /tmp/lines.txt

Categories : Bash

execute user inputed Windows (or bash) commands from batch (or bash) file?
Do you need a full bash prompt? Or would something like this be enough? #!/bin/bash echo -n "Enter cmd: " read COMMAND echo ${COMMAND} | bash Also, in a script, you can just execute bash and get a full prompt in the current environment.

Categories : Bash

Why does the child of an eval call from bash get orphaned once the parent bash script dies?
This is normal and expected. You sent a signal (presumably SIGTERM) to parent-script and it died, but no signal was sent to another-script. It keeps on running. This is different than what happens when the parent-script job is running interactively on a terminal and you type ^C (or ^Z). In that case, a SIGINT signal is automatically sent to the whole foreground process group. Since another-script is un the same process group as parent-script (by default), they both get the signal and they both die. If you want another-script to die automatically when its parent dies in any other context than when it's a job running in a terminal with job control, you have a few options. parent-script can trap the SIGTERM signal. In the signal handler, it kills its child, and then exits itself. This, o

Categories : Linux

Pass a full bash script line to another bash function to execute
optout is a command like any other, and so must be preceded by any local modifications to the environment. The command that optout runs will inherit that environment. CC=${BUILD_TOOL_CC} optout ./configure ${ZLIB_CONFIGURE_OPT} --prefix=${CURR_DIR}/${INSTALL_DIR} By the way, this is just one of the problems you are likely to encounter with your optout function. You cannot run arbitrary command lines in that fashion, only a simple command followed by zero or more arguments (and I would expect there are some exceptions to even that restricted set, as well).

Categories : Linux



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.