Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-09-23T21:24:57Z
Updated: 2 hours 5 min ago

R language - package pdf2 - How to create Hiperlinks in a new PDF file

Thu, 09/21/2017 - 09:05

I'm using R to generate pdf reports using pdf2 package.

I need to place in the pdf a table with some hiperlinks but it seems to be impossible :(

Years ago, mtext (of pdf2 package) had the parameter 'url' but not now :(

This should be the final result

Please, Can anybody help me?

Thanks in advance.

WKWebview get content height, always return some extra space

Thu, 09/21/2017 - 09:05

I am trying to get html content's height or scrollview's proper content height from WKWebview.if wkwebview include twitter, it always gives some extra space height

How to exclude files with sparse-checkout?

Thu, 09/21/2017 - 09:05

I'm having bare git repo in which I created post-receive hook which looks like this:

#!/bin/sh git --work-tree=/var/www/html/test/test_3 --git-dir=/var/www/html/test/test_2.git checkout -f

Then I created test_2.git/info/sparse-checkout file with this lines:

!bootstrap !config /*

Basically I want to checkout all files except /boostrap/* and /config/* folders.

P.S.

git config core.sparsecheckout true is done.

Pattern matching in regex

Thu, 09/21/2017 - 09:04

I have below dictionary that I created in such a way that the key is the length of the values.

{4: {'lost', 'lust', 'list', 'last', 'lest', 'blue'}, 5: {'beryl'}, 8: {'blowlamp', 'blimbing', 'bluejays', 'jigsawed'}, 9: {'blistered', 'oospheres', 'blackcaps', 'blastular', 'blotchier', 'troweller'}, 10: {'blancmange', 'blackguard', 'volcanizes'}, 6: {'blague', 'blacks', 'blonde', 'blocks'}, 7: {'blawort', 'blinder', 'blender', 'blonder', 'blunder', 'blander'}}

I want to pull out a list of values in this dictionary in such a way that the vowel comes at the same place for 5 words like [lost,lust,list,last,lest],[blinder,blender,blonder,blunder,blander]]

I am not having any idea on how to get the list in such a way. One way I thought could be through regex but on what basis do I match? The length of the words could be anything and vowel could be anywhere.

PS this is a codewars question. https://www.codewars.com/kata/vowel-alternations/train/python My approach so far that I got the values with same length in a dictionary so that I can work on the values. I just have no idea how to work on the values. It would be helpful if anyone can explain me what they are thinking and what is the best way to do this.

The rest of the code

mdict={} rev_multidict = {} for i in words: for sublist in i: mdict[sublist] = len(sublist) for key, value in mdict.items(): rev_multidict.setdefault(value, set()).add(key) for key,value in rev_multidict.items(): i = rev_multidict[key] print(i)

Change appearance of placeholder text in ruby

Thu, 09/21/2017 - 09:04

I'm currently using placeholders in number field tags like this:

<%= number_field_tag, ..., placeholder: 50, ... %>.

However, the appearance of the placeholder is too similar to the input, which makes it hard to differentiate. So I simply want to make the placeholder text brighter. I haven't found any answers for this yet through google so I thought I'd try my luck here.

Javascript - self-executing functions : why to use them if I can create local scope with not self-executing functions?

Thu, 09/21/2017 - 09:04

I know there are a lot of posts here and elsewhere about selfexecuting functions but I still have some questions after reading posts.

  1. why would I ever assign a self-executing function to a variable? If seems that they execute themselves anyways.

    var myFunc=(function() { console.log('Hello World'); })();
  2. I read a lot that the reason to use self-executing functions is to keep variables private. If I have a not self-executing function, everything I define inside that function is gonna be private anyways?!

    (function() { var name="my Name" console.log(name); })(); vs. function() { var name="my Name" console.log(name); }; //its the same

So I dont quite understand how self-executing functions are to keep local scope (as you can do that using not self-executing functions) so the only reason I see is to use them when you want to execute automatically for example on page load.

Thanks!

Why preserveOriginal doesn't work as descrobed in java doc?

Thu, 09/21/2017 - 09:04

I have the following configuration:

@AnalyzerDef(name = "autocompleteNGramAnalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = { @TokenFilterDef(factory = WordDelimiterFilterFactory.class, params = @Parameter(name = "preserveOriginal", value = "1"))

preserveOriginal doc:

/** * Causes original words are preserved and added to the subword list (Defaults to false) *

* "500-42" => "500" "42" "500-42" */

According this one I have added following word:

500-42

I rebuild index, reopen Luke and see following:

only 500 and 42 tokens where are no 500-42

Why?

Extract tar and exclude files and create new tar

Thu, 09/21/2017 - 09:02

I am attempting to extract a tar (whilst excluding some files) and pipe the output of tar to stdout and create a new tar from the output.

I am using Centos 7. Here is the syntax I am using

tar -xvOf orginal.tar --exclude='a/*' | tar -cf new.tar tar: Cowardly refusing to create an empty archive Try `tar --help' or `tar --usage' for more information. tar: --to-stdout: Cannot open: No such file or directory tar: Error is not recoverable: exiting now

Could someone explain what I am doing wrong?

Thanks

Densha

how to insert decimal data type into sql server from php

Thu, 09/21/2017 - 09:01

This error annoyed me

Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 8114 [code] => 8114 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Error converting data type varchar to numeric. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Error converting data type varchar to numeric. ) )

I try to insert amount data from web page(PHP), but I don't know if I can use CAST or CONVERT

if ($_SERVER['REQUEST_METHOD'] =='POST' && isset($_POST['save'])) { $save = "INSERT INTO trans_details (badge_id,user_id,comp_id,amount,cash,subsidy,trans_date) values('$badge_id','$user_id','$cid','$amount','$total_need','$amount',$stamp)"; $result = sqlsrv_query($conn, $save); }

meanwhile, At the my database amount and total_need are declared as decimal(12,2). And I tried to use isNumeric() function but it store value 1? What can I do to store directly from php?

SQL working strange

Thu, 09/21/2017 - 09:01

When I execute this SQL code:

select id, opis, vidrabota, tipprov, hitnost, valuta, drzava, zbirnaprov, tip_zbirprov, kanal from dev_1450autoebanktip where opis is null or Opis like case when isnull('','') = '' then Opis else '%' + '' + '%' end and VidRabota = case when isnull('','') = '' then VidRabota else '' end and TipProv = case when isnull(0,0) = 0 then TipProv else 0 end and Valuta = case when isnull('','') = '' then Valuta else '' end and drzava is null or Drzava = case when isnull('','') = '' then Drzava else '' end

I get this set of results:

But when I add one more condition (last row):

select id, opis, vidrabota, tipprov, hitnost, valuta, drzava, zbirnaprov, tip_zbirprov, kanal from dev_1450autoebanktip where opis is null or Opis like case when isnull('','') = '' then Opis else '%' + '' + '%' end and VidRabota = case when isnull('','') = '' then VidRabota else '' end and TipProv = case when isnull(0,0) = 0 then TipProv else 0 end and Valuta = case when isnull('','') = '' then Valuta else '' end and drzava is null or Drzava = case when isnull('','') = '' then Drzava else '' end and KANAL = case when isnull(0,0) = 0 then KANAL else 0 end

I am losing one row in the result. What is causing this change?

get parent div id by using image src inside that div using jquery

Thu, 09/21/2017 - 09:01

I am having a parent div say div_parent with 4 div elements say div1, div2, div3 and div4 and 1 button add image.

When I click add image button, it adds 2 images to all div.

Now I have 1 image with src say 1.png which is inside one of these 4 divs. So my question is that by just src (1.png) how can i get its parent div id?

I have tried following code

$('#div_parent > div > img').map(function() { if (($(this).attr('src')) == '1.png') xx = $(this).attr('id'); p = xx.parent(); }); alert("--" + xx + "---" + p.attr('id'));

Xcode, stack view wont fit edges

Thu, 09/21/2017 - 09:01

I cant figure out what I did wrong. In xcode I have used stack view and constraints. If I see it in xcode:

Here is how I see it in the simulator:

Constraints is set to edges 0 and 0. I have added spaces (8) between the label and the textfield. I have made 1 label and 1 textfield to a stack view for every label and textfield, then added the button to all the labels and textfields so it ends in 1 stack view. Only the stack view with labels and textfields have been given 0-0 constrains.

Any idea?

checked the all checkboxes of form in angularjs

Thu, 09/21/2017 - 08:59

Hi i have form in angularjs and that form have many checkboxes on clicking first checkbox i,e check All i want to checked the all checkboxes . how i can i do that with angular for each field loop here is my sample code I am trying in code snipt.

vm.asas = function() { angular.forEach($scope.quizSettingsForm, function(field) { console.log(field); angular.forEach(field, function(errorField) { errorField.$setTouched(); }); }); console.log(vm.QuizSettings); }; <form name="quizSettingsForm" novalidate> <div class="panel panel-default"> <div class="panel-heading"> QUIZ SETTINGS </div> <div class="panel-body"> <ul> <li> <div class="checkbox"> <input type="checkbox" id="checkall" ng-model="vm.checkAll" ng-click="vm.asas()" /> <label for="checkall">Check /Uncheck ALL</label> </div> </li> <li> <div class="checkbox"> <input type="checkbox" ng-model="vm.QuizSettings.IsOpened" id="Cohort" /> <label for="Cohort">Have a open Quiz</label> </div> </li> <li> <div class="checkbox"> <input type="checkbox" ng-model="vm.QuizSettings.IsMandatory" id="mandatory" /> <label for="mandatory">Is Mandatory</label> </div> </li> <li> <div class="checkbox counterdiv"> <input type="checkbox" ng-model="vm.QuizSettings.ShouldExpireAfterExpiry" id="invitation" /> <label for="invitation"> <p>The quiz will expire <input type="number" ng-model="vm.QuizSettings.Expiry" ng-min="1" name="expiry"> days after invitation</p></label> <span class="validation-message" ng-show=" vm.QuizSettings.ShouldExpireAfterExpiry && quizSettingsForm.expiry.$touched && quizSettingsForm.expiry.$error.min"><i class="fa fa-warning"></i> The minimum value is 1.</span> </div> </li> <li> <div class="checkbox"> <input type="checkbox" ng-model="vm.QuizSettings.AllowRetakes" id="dontallow" /> <label for="dontallow">Allow Retake and dont allow more than </label> <input type="number" ng-model="vm.QuizSettings.AlllowMoreThen" ng-min="1" name="dontallow"><span style="color: #696969;font-size: 18px;font-weight: normal;"> Retakes </span> <span class="validation-message" ng-show="quizSettingsForm.dontallow.$touched && quizSettingsForm.dontallow.$error.min"><i class="fa fa-warning"></i> The minimum value is 1.</span> </div> </li> </ul> </div> </div> </form>

How to validate Australian Phone Number using html pattern

Thu, 09/21/2017 - 08:56

In PHP, I can easily validate the Australian Phone Number from Input using PHP Regex.

The Regex I'm using is:

/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/

I tried to use same regex to valid on client side using HTML5 Pattern attribute but I'm not getting desired result.

Can anyone help me find out what is wrong with above regex while using in HTML5? If anyone could suggest also javascript solution that mimics the HTML5 form validation, I would really appreciate it

Count unique values in a filtered table without volatility

Thu, 09/21/2017 - 08:53

I need to count the unique values in a column of a filtered table.

The formula must be in one cell only (no added columns with flags), and must be non-volatile (e.g. no OFFSET)

So far, I have this beast: =IF(COUNTA(A1:A3043) = SUBTOTAL(3, A1:A3043), SUMPRODUCT(1 * (A1:A3043 <> A2:A3044)),SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(A1,ROW(A1:A3043)-ROW(A1),0,1)),MATCH(A1:A3043,A1:A3043,0)),ROW(A1:A3043)-ROW(A1)+1)>0,1)))

but it's very slow when filtering large tables due to it's volatility.

To be clear, if I filter "Item Purchased" in the following table, to just include the value a, then my unique count of customers would be 4 (customerIDs 1, 4, 5, 6):

enter image description here

Thanks in advance.

Connecting to PostgreSQL instance hosted in cloud foundry

Thu, 09/21/2017 - 08:53

I have created an postgresql instance from market place in my space who's instance name is : stack-uaa-postgresql

I want to connect to it from console so that i can execute sql queries .

I followed this document :

https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-services.html

and executed this command :

cf create-service-key stack-uaa-postgresql postgresqlkey

and then validated it using :

cf service-key stack-uaa-postgresql postgresqlkey

and I got following response :

{ "dbname": "removed", "hostname": "removed", "password": "removed", "port": "33784", "ports": { "5432/tcp": "33784" }, "uri": "removed", "username": "removed" }

I have removed values.

But when I am trying to do tunneling using ssh in my postgresql using below command I am getting exception :

> cf ssh -L 63306:<username>:<password>@<host internal ip>:33784 > stack-uaa-postgresql

FAILED App stack-uaa-postgresql not found

what is it that I am missing , is there alternate way to making connection with cloud foundry postgresql

Java : how java transform line of image to code? [on hold]

Thu, 09/21/2017 - 08:52

how to transform line of picture to digit / int ?

here the example

Show delegate derived from in debug mode

Thu, 09/21/2017 - 08:49

I have delegate:

public delegate void PhotoFilterHandler(Photo photo);

Creating variable:

PhotoProcessor.PhotoFilterHandler filterhandler = ApplyBrightnes;

Why I can't see what it derived from in debug mode:

Arrayname about XML serialization in C# language

Thu, 09/21/2017 - 08:41
public class A { [XmlArrayItem("Cargo", IsNullable = false)] public Cargo[] Cargos { get; set; }}

I want to get a result like this by use XMLSerializater

<A><Cargo ........../><Cargo ........../><Cargo ........../></A>

But in fact ,it is

<A><Cargos><Cargo ........../><Cargo ........../><Cargo ........../><Cargos></A>

How can I get i want without

Convert long single line command to a bash shell script

Thu, 09/21/2017 - 08:30

Im working on the following command in crontab:

nice --20 iperf3 -c somelocation.com -f k | while IFS= read -r line; do echo "$(date) $line"; done | tee onespeed.txt | tee -a speeds.txt; sleep 30 ;cat onespeed.txt | grep sender >> concentrated.txt; sleep 2 ;cat onespeed.txt | grep sender | awk -F' ' '{print $13}' | while IFS= read -r line; do echo "$(date) $line"; done | tee onerawspeed.txt | tee -a rawspeeds.txt

I understand that the job could be done in a far more elegant way but Im looking to find out how I go about breaking this down so that its structured properly to act as a bash shell script.

Specifically Im focused on structuring it over multiple lines so that it is more readable.

Pages