EzDevInfo.com

term.js

A terminal written in javascript.

How can I echo to /dev/tty?

Is there a way to send something like an "end of data" after executing

echo "test" > /dev/tty1

in order to gain the "input cursor" back to "receiving" terminal (in this case tty1)?

Screenshot: http://picload.org/image/acdwigg/tty.png


Source: (StackOverflow)

Different color themes per mode in Emacs

How can I ask Emacs to automatically use a different color theme (e.g. using the Elisp ColorTheme package) depending on the mode of the buffer?

Some color-themes work great when editing code, but not in Dired+, TERM or shell mode.

Thanks


Source: (StackOverflow)

Advertisements

grep-like tool that colors/boldens but not filter?

For years I've noticed GNU's grep in Unixes (not just Linux flavors) detected that I was using a color-capable TERM interactively like xterm/gnome-terminal/kconsole, and nicely colored my search expressions among the context.

What might be a simple cli tool that only boldens/highlights your regex or simple search string, but unlike grep, doesn't otherwise filter out any lines? Maybe a sed trick can do this, which I can alias and later pipe commands to?

EXAMPLE

So I wrote a program pricehist.sh which normally produces CSV-like data for another program, but I frequently visually inspect it like so:

./pricehist.sh mostalexp-GPW  28 |sort -r -g -k 3 -t ' ' |column -t -s", "
MOSTALEXP,20120222,0.78,0.79,0.76,0.77,63900,0.77    0.04000   5.00000   -0.01000  -1.25000  49203
MOSTALEXP,20120203,0.82,0.82,0.78,0.78,446089,0.78   0.04000   4.87805   0         0         347949
MOSTALEXP,20120124,0.71,0.71,0.69,0.71,61478,0.71    0.03000   4.16667   -0.01000  -1.38889  43649
MOSTALEXP,20120130,0.73,0.73,0.70,0.73,59488,0.73    0.03000   4.10959   0         0         43426
MOSTALEXP,20120210,0.79,0.81,0.77,0.81,104120,0.81   0.03000   3.75000   0.01000   1.25000   84337
MOSTALEXP,20120213,0.80,0.80,0.78,0.80,86606,0.80    0.03000   3.70370   -0.01000  -1.23457  69284
MOSTALEXP,20120126,0.69,0.75,0.69,0.72,146353,0.72   0.02000   2.81690   0.04000   5.63380   105374
MOSTALEXP,20120131,0.72,0.73,0.71,0.72,72734,0.72    0.02000   2.73973   0         0         52368
MOSTALEXP,20120123,0.72,0.73,0.71,0.72,24133,0.72    0.02000   2.73973   0         0         17375
MOSTALEXP,20120214,0.78,0.81,0.78,0.79,56990,0.79    0.02000   2.50000   0.01000   1.25000   45022
MOSTALEXP,20120209,0.79,0.82,0.79,0.80,65243,0.80    0.02000   2.46914   0.01000   1.23457   52194
MOSTALEXP,20120118,0.69,0.70,0.68,0.69,62520,0.69    0.01000   1.44928   0.01000   1.44928   43138
MOSTALEXP,20120125,0.70,0.71,0.70,0.71,92317,0.71    0.01000   1.40845   0         0         65545
MOSTALEXP,20120201,0.71,0.74,0.71,0.74,199791,0.74   0.01000   1.38889   0.02000   2.77778   147845
MOSTALEXP,20120127,0.73,0.73,0.71,0.73,38157,0.73    0.01000   1.38889   0.01000   1.38889   27854
MOSTALEXP,20120207,0.78,0.79,0.77,0.79,56243,0.79    0.01000   1.28205   0.01000   1.28205   44431
MOSTALEXP,20120206,0.78,0.80,0.77,0.78,133597,0.78   0.01000   1.28205   0.02000   2.56410   104205
MOSTALEXP,20120221,0.81,0.81,0.79,0.80,112738,0.80   0.01000   1.25000   0.01000   1.25000   90190
MOSTALEXP,20120217,0.80,0.85,0.79,0.80,272245,0.80   0.01000   1.25000   0.05000   6.25000   217796
MOSTALEXP,20120216,0.81,0.81,0.79,0.80,30814,0.80    0.01000   1.25000   0.01000   1.25000   24651
MOSTALEXP,20120113,0.66,0.66,0.65,0.65,90267,0.65    0.00500   0.76336   0.00500   0.76336   58673
MOSTALEXP,20120220,0.80,0.82,0.80,0.80,83881,0.80    0         0         0.02000   2.50000   67104
MOSTALEXP,20120215,0.80,0.82,0.79,0.80,128714,0.80   0         0         0.03000   3.79747   102971
MOSTALEXP,20120208,0.79,0.84,0.79,0.81,280446,0.81   0         0         0.05000   6.32911   227161
MOSTALEXP,20120120,0.74,0.74,0.72,0.73,128831,0.73   0         0         0.02000   2.77778   94046
MOSTALEXP,20120117,0.67,0.71,0.67,0.69,284886,0.69   0         0         0.04000   5.97015   196571
MOSTALEXP,20120116,0.65,0.67,0.65,0.67,9548,0.67     0         0         0.02000   3.07692   6397
MOSTALEXP,20120202,0.75,0.87,0.75,0.82,1270955,0.82  -0.01000  -1.35135  0.13000   17.56757  1042183
MOSTALEXP,20120119,0.70,0.74,0.70,0.72,320471,0.72   -0.01000  -1.44928  0.05000   7.24638   230739

At the end of the pipe (after |column -t) it'd be nice to add something which highlights at least the string $(date +%Y%m%d), which at the moment evaluates to 20120222

Another example is tail -F /tmp/*.log | grep -C 9999 YouJustGotHacked except I wouldn't want the grep to actually filter out any lines, just make YouJustGotHacked a lot easier to spot in the noise.


Source: (StackOverflow)

scripting MySQL from BASH over SSH

I have a CentOS server that I want to script from BASH running it on my laptop.

run a script locally that: - logs into the server over ssh and executes some mysql statements - copies files that I need to where I need them

THe file copying is easy. I can do that.

But how can one connect to a MySQL server over the SSH port and execute statements? I think I am just stuck on the connect part. executing the statements I can build up on a variable and batch execute.

I have an SSH pub/priv keypair from my laptop to this server as well.

any help?


Source: (StackOverflow)

Elasticsearch term filter not working?

I'm trying to do the following term filter

{
  "query": {
    "term": {
      "name": "terry harvey"
    }
  }
}

and I'm getting 0 hits

{
  took: 3
  timed_out: false
  _shards: {
  total: 5
  successful: 5
  failed: 0
}
hits: {
    total: 0
    max_score: 0
    hits: [ ]
  }
}

When I used the "match filter" instead "term filter", I get 48 hits.

What am I doing wrong? =(

Thanks!


Source: (StackOverflow)

C++, the term/idiom for programming using template

I keep reading the term :

  1. template programming
  2. generic programming
  3. meta-programming
  4. maybe another idiom/term..

for any c++ code that use template, which one is the correct or more accurate term of this?


Source: (StackOverflow)

Elastic Search Hyphen issue with term filter

I have the following Elastic Search query with only a term filter. My query is much more complex but I am just trying to show the issue here.

{
    "filter": {
            "term": {
                    "field": "update-time"
                }
        }
}

When I pass in a hyphenated value to the filter, I get zero results back. But if I try without an unhyphenated value I get results back. I am not sure if the hyphen is an issue here but my scenario makes me believe so.

Is there a way to escape the hyphen so the filter would return results? I have tried escaping the hyphen with a back slash which I read from the Lucene forums but that didn't help.

Also, if I pass in a GUID value into this field which is hyphenated and surrounded by curly braces, something like - {ASD23-34SD-DFE1-42FWW}, would I need to lower case the alphabet characters and would I need to escape the curly braces too?

Thanks


Source: (StackOverflow)

Terminal in Emacs in Windows - Error message: "Spawning child process; invalid argument"

I'm trying to start a cmd terminal in Emacs 23.2 (latest version) in Windows.

According to the Manual, I can enter in terminal mode (starting a new buffer for the terminal) in Emacs by typing M-x term.

When I do this, I get prompted for:

Run program: path_to-emacs/bin/cmdproxy.exe

When I type RET, I get the following error message in the minibuffer:

Spaning child process: invalid argument

Any ideas how to make it work?

Thanks,


Source: (StackOverflow)

What does 'seeding' mean?

Very simple question. What does the term 'seeding' mean in general? I'll put the context, i.e., you must seed for random functions.


Source: (StackOverflow)

Lucene TermFrequenciesVector

what do I obtain if I call IndexReader.getTermFrequenciesVector(...) on an index created with TermVector.YES option?


Source: (StackOverflow)

zsh in Emacs output junk characters

No matter I use term or ansi-term to start zsh in Emacs, I encounter this problem, whenever I input commands, the output will have some junk characters like:

[ruby-1.9.2] ~ pwd 2;pwd1;pwd/Users/tyraeltong

the "2;pwd1;pwd" is screwing the output, don't know whether others are experiencing same problem? I found a similar thread here Getting Emacs ansi-term and Zsh to play nicely but by [[ $TERM == eterm-color ]] && export TERM=xterm I still see the junk characters.


Source: (StackOverflow)

elasticsearch boost importance of exact phrase match

Is there a way in elasticsearch to boost the importance of the exact phrase appearing in the the document?

For example if I was searching for the phrase "web developer" and if the words "web developer" appeared together they would be boosted by 5 compared to "web" and "developer" appearing separately throughout the document. Thereby any document that contained "web developer" together would appear first in the results.


Source: (StackOverflow)

Shapeless Generic, stratego-like strategic term rewriting, strongly typed with first class polymorphic functions doable?

I would like to find a way to build a Kiama like library with an added feature that would be to have strongly typed rewrite rules. (In Kiama eveyrything is a Term, and rewrite rules are Term => Option[Term]

I know that shapeless allows to convert arbitrary case class hierarchies to a sum of products representation using hlists behind the scenes.

Based on this generic representation I imagine it could be fairly doable to write a generic library of traversal combinators (in the style of stratego) for applying rewrite rules on the generic version of a term made of nested case classe,

I have the feeling that it could be possible to use shapeless polyN functions to encode polymorphic term rewrite rules that would yield precise types, however these rewrite rules would have to operate on Hlists representing the case classes, which could be quite cumbersome to use compared to how pattern matching allows to match and transform sub trees

The simple example I have is this one

sealed abstract trait Expr { type Repr }
sealed abstract trait BoolExpr extends Expr { type Repr = Boolean }
sealed abstract trait IntExpr extends Expr { type Repr = Int }
case class BoolVar(sym: Symbol) extends BoolExpr
case class Not( l: BoolExpr ) extends BoolExpr
case class And( l: BoolExpr, r: IntExpr ) extends BoolExpr
case class Or( l: BoolExpr, r: IntExpr ) extends BoolExpr 
case class IntIte( cond: BoolExpr, thenExpr: IntExpr, elseExpr: IntExpr) extends IntExpr
case class IntConst( value: Int ) extends IntExpr
case class IntVar( sym: Symbol ) extends IntExpr

rule1 { case Not(Not(e)) => Some(e) }

rule2 { case IntIte(Not(c), t, e) => Some( IntIte(c, e, t) }

however, I fear that the rewrite rules would have to be expressed over hlists and hence I would loose the power of simple pattern matching as illustrated above. The only thing I can imagine is to, while traversing the shapeless.Generic structure, convert back bits of it before matching a rule and convert back the result to generic and update the generic structure with the new term represented as a hlist.

Even better would be a rewriting system working on a GADT Expr[T] where T is the type of the expressions and rewrite rules would preserve that T. Regards.

How feasible does this look to you?


Source: (StackOverflow)

If has_term, load other Wordpress theme

This is what I want to accomplish. In Wordpress I've created a taxonomy called categorie with the terms app, web and branding. When a project has the term app, I want to load another theme / blog. When a project has the term web or branding, I want to load single.php. The last one works just fine.

This is my code so far

function load_single_template($template) {
$new_template = '';

if( is_single() ) {
    global $post;

    if( has_term('app', 'categorie', $post) ) {
        $new_template = get_theme_roots('themeApp');
    } else {
        $new_template = locate_template(array('single.php' ));
    }
}
return ('' != $new_template) ? $new_template : $template;

}
add_action('template_include', 'load_single_template');

So when a project has the term app, I want to load the theme themeApp. Any suggestions? Thanks in advance.


Source: (StackOverflow)

`M-x term' with Emacs on MS Windows: error Spawning child process: invalid argument

whenever I try to launch M-x term from my Windows distribution of GNU Emacs, I get the error:

apply: Spawning child process: invalid argument

after accepting the default program to run (either "bash.exe" or "zsh.exe", from Cygwin, and present in my Windows PATH environment variable).

M-x shell does work with Zsh/Bash from Cygwin. But I'd like to use Term to get more features...

Any help?


Source: (StackOverflow)