I have this bit of code (part of an interpreter for a garbage-collected Forth system, actually):
#define PRIMITIVE(name) \
do \
{ \
VocabEntry* entry = (VocabEntry*)gc_alloc(sizeof(VocabEntry)); \
entry->code = name; \
…
When I try to refer to two process substitution pipes in a bash function, only the first one referenced works. The second one gives a "bad file descriptor" error like so:
$ foo(){
> cat "$1"
> cat "$2"
> }
$ foo <(echo hi) <(echo bye)
hi
cat:…
I want to add a + (plus sign) before all the occurrences of image names in a huge file, using sed.
This is an example of one line:
DAUSSI-H22-14K White Gold-Princess-1.00ct-G-SI1orH-VS2-EGL-mm-3.5,,H22,,7050,5720,3/5/2012…
Lately I've been yanking and putting a lot of code that needs to be altered somewhat (usually just a simple substitution). I can manually select it after it's pasted in, or for longer blocks I suppose I could look at the number of lines pasted (20…
I have an SQLite database with three columns, and I'm trying to use parameter substitution for tuples to SELECT rows. This is my table:
conn = sqlite3.connect("SomeDb.sqlite3")
conn.execute("""
CREATE TABLE RoadSegmentDistribution(
Source…
France 211 55 Europe
Japan 144 120 Asia
Germany 96 61 Europe
England 94 56 Europe
Taiwan 55 144 Asia
North Korea 44 2134 Asia
The above is my data file.
There are empty lines in it.
There are no spaces or tabs in those empty…
For long and repeating models I want to create a "macro" (so called in Stata and there accomplished with global var1 var2 ...) which contains the regressors of the model formula.
For example from
library(car)
lm(income ~ education + prestige, data…
I have a document that I need to dynamically create/update the indexes in. I am trying to acomplish this with awk. I have a partial working example but now I'm stumped.
The example document is as follows.
numbers.txt:
#) Title
#) Title
…
Is there any way to apply Bash variable substitution on find's output? I know I've seen someone do it on Stack Overflow but I can't seem to find that particular post anymore.
As an example, let's say I want to rename files ending in *.png to…
I got a headache looking for this:
How do you use s/// in an expression as opposed to an assignment. To clarify what I mean, I'm looking for a perl equivalent of python's re.sub(...) when used in the following context:
newstring = re.sub('ab', 'cd',…
For string matching purposes I need to define a bash variable with leading spaces.
I need to define this starting from an integer, like:
jj=5
printf seems to me a good idea, so if I want to fill spaces up to 6 character:
jpat=`printf " %6i" …
I have the following expression:
from sympy import pi, sin, cos, var, simplify
var('j,u,v,w,vt,wt,a2,t,phi')
u0 = v*a2*sin(pi*j/2 + pi*j*t*phi**(-1)/2) + pi*vt*a2*cos(pi*j/2 + pi*j*t*phi**(-1)/2)*j*phi**(-1)/2 + pi*w*a2*cos(pi*j/2 +…
I'm trying to write a program that takes an expression as an input and returns a function with that expression bound as its body.
caller <- function (expr, params) {
Function <- function (params, body, env = parent.frame()) {
# returns…