substitution

Dynamic inclusion of piwik code by means of server side filtering inside apache server

▼魔方 西西 提交于 2019-12-07 05:54:16
问题 After a few hours of fruitless attempts I would like to ask you all for a little assistance with a simple setup: For a bunch of web applications and sites I run using the apache2 http server I use Piwik for a simple statistical overview. That works fine. What annoys me is that with every additional app/page and every update/upgrade I have to take care to manually maintain the javascript code required by piwik to be included into the html markup. To simplify that maintainance I want have that

Substituting everything from = to end of the line in VIM

谁说胖子不能爱 提交于 2019-12-06 10:16:20
Let's say I have several lines like: $repeat_on = $_REQUEST['repeat_on']; $opt_days = $_REQUEST['opt_day']; $opt_days = explode(",", $opt_days); ... and so on. Let's say I use visual mode to select all the lines: how can I replace everything from = to the end of the line so it looks like: $repeat_on = NULL; $opt_days = NULL; $opt_days = NULL; With the block selected, use this substitute: s/=.*$/= NULL; The substitution regex changes each line by replacing anything between = and the end of the line, including the = , with = NULL; . The first part of the command is the regex matching what is to

VIM substitution: Using the current line as the search string

痴心易碎 提交于 2019-12-06 09:17:54
问题 Assuming the following text file, which is actually a data dump of funds and price statistics: PBCPDF 05/01/2006 0.0000 0.0000 PBCPDF 0.0000 06/01/2006 0.0000 0.0000 PBCPDF 0.0082 [… lines repeat …] What I wanted to achieve is to delete all instances of PBCPDF except for the first one, which I could write the substitution command as :.+1,$s/PBCPDF\n//g . However, since I wanted to program a macro to process multiple fund names, I need a means to use some sort of pattern that would retrieve

Log4J – Runtime variable substitution

混江龙づ霸主 提交于 2019-12-06 02:21:26
Log4J appears to have an annoying restriction – at runtime, variable substitution does not appear to work. In this example File: Log4j.properties file_pattern=%d{ISO8601} %-5p %m%n log4j.rootLogger=DEBUG, FileAppender log4j.appender.FileAppender=org.apache.log4j.FileAppender log4j.appender.FileAppender.layout=org.apache.log4j.PatternLayout log4j.appender.FileAppender.layout.ConversionPattern=${file_pattern} log4j.appender.FileAppender.File=log4jtest1.log log4j.appender.FileAppender.Threshold=ERROR The FileAppender configured in the log4j.properties file produces the correct output: File:

Change lines that match a pattern in between delimiters using awk

别来无恙 提交于 2019-12-06 02:07:22
I have an input file something like this: some line some other line another line start_delimiter interesting stuff more interesting stuff even more interesting stuff end_delimiter possibly more stuff I want to manipulate the lines between start_delimiter and end_delimiter that match a regex pattern and write the results to the input file. For example, add '//' to the beginning of the lines containing the word 'more' (as long as those lines are between the delimiters): some line some other line another line start_delimiter interesting stuff //more interesting stuff //even more interesting stuff

Substitution with sed + bash function

时间秒杀一切 提交于 2019-12-06 02:06:36
问题 my question seems to be general, but i can't find any answers. In sed command, how can you replace the substitution pattern by a value returned by a simple bash function. For instance, I created the following function : function parseDates(){ #Some process here with $1 (the pattern found) return "dateParsed; } and the folowing sed command : myCatFile=`sed -e "s/[0-3][0-9]\/[0-1][0-9]\/[0-9][0-9]/& parseDates &\}/p" myfile` I found that the caracter '&' represents the current pattern found, i

Monadic substitution under binders

喜夏-厌秋 提交于 2019-12-06 01:36:16
In the following Agda code, I have a term language based on de Bruijn indices. I can define substitution over terms in the usual de Bruijn indices way, using renaming to allow the substitution to proceed under a binder. module Temp where data Type : Set where unit : Type _⇾_ : Type → Type → Type -- A context is a snoc-list of types. data Cxt : Set where ε : Cxt _∷_ : Cxt → Type → Cxt -- Context membership. data _∈_ (τ : Type) : Cxt → Set where here : ∀ {Γ} → τ ∈ Γ ∷ τ there : ∀ {Γ τ′} → τ ∈ Γ → τ ∈ Γ ∷ τ′ infix 3 _∈_ data Term (Γ : Cxt) : Type → Set where var : ∀ {τ} → τ ∈ Γ → Term Γ τ 〈〉 :

Adding a newline in a substitute() expression

主宰稳场 提交于 2019-12-05 22:11:00
I'm trying to annotate a plot in ggplot with relevant data from a regression model. I've followed the suggestions in this SO post and tried to modify the function to have a couple additional items in a newline in the plot. This is my attempt at a new function: lm_eqn = function(m){ eq <- substitute(italic(y) == a %.% italic(x)^b*","~~italic(r)^2~"="~r2*","~~italic(n)~"="~nn*","~~italic(p-value)~"="~pv, list(a = format(exp(coef(m)[1]), digits = 3), b = format(coef(m)[2], digits = 3), r2 = format(summary(m)$r.squared, digits = 3), nn=format(summary(m)$df[2]), pv=format(summary(m)$coefficients[,4

Termination-checking substitution via (monadic) join and fmap

杀马特。学长 韩版系。学妹 提交于 2019-12-05 21:30:59
I'm using sized types, and have a substitution function for typed terms which termination-checks if I give a definition directly, but not if I factor it via (monadic) join and fmap. {-# OPTIONS --sized-types #-} module Subst where open import Size To show the problem, it's enough to have unit and sums. I have data types of Trie and Term , and I use tries with a codomain of Term inside Term , as part of the elimination form for sums. data Type : Set where 𝟏 : Type _+_ : Type → Type → Type postulate Cxt : Set → Set -- Every value in the trie is typed in a context obtained by extending Γ. data

why process substitution does not always work with while loop in bash?

放肆的年华 提交于 2019-12-05 17:44:37
问题 The process substitution works with filenames fine, e.g. both $ cat <FILENAME and $ while read i; do echo $i; done <FILENAME work. But if instead of FILENAME we use echo command (or any other, which generates output to stdout), cat continues to work $ cat <(echo XXX) XXX while the loop $ while read i; do echo $i; done <(echo XXX) bash: syntax error near unexpected token `<(echo XXX)' produces error. Any ideas why? 回答1: Note: < filename is not process substitution. It's a redirection. Process