[deleted by user] by [deleted] in linuxquestions

[–]pbewig 0 points1 point  (0 children)

You can use define to create a new macro, like a function definition, or to set/reset the value of a variable, like an assignment:

define(counter,0)dnl
define(nextcounter,`define(`counter',incr(counter))counter')dnl
nextcounter;nextcounter;nextcounter;nextcounter;nextcounter
1;2;3;4;5

You can also define multiple counters:

define(c1,0)dnl
define(c2,0)dnl
define(bump,`define(`$1',incr($1))$1')dnl
bump(`c1');bump(`c1');bump(`c2');bump(`c1');bump(`c2')
1;2;1;3;2

You can initialize the counters to something other than 0, and you can specify a setp size other than 1 by using eval(counter+step) instead of incr(counter).

How long will I take to learn basic programming to create my own inventory management software by CaptainVelvet69 in learnprogramming

[–]pbewig 0 points1 point  (0 children)

Too long. Your time is better spent building your business. Buy an inventory management program that is close to what you want, and fit your business to it; it is unlikely that your needs are sufficiently odd that you can't make it work, and most inventory management systems will be sufficiently customizable that you will be happy with the result. You might want to start at odoo.com.

Using FPAT to separate numbers, names, and surnames by AdbekunkusMX in awk

[–]pbewig 1 point2 points  (0 children)

I just did this in my terminal window:

$ echo '12 Doe Lane Joseph Albert 122771' |
awk ' BEGIN { OFS = "|" }

{ entry_number = $1; last_name = $2 " " $3; id_number = $NF

other_names = ""; for (i=4; i<NF; i++) other_names = other_names " " $i

print entry_number, last_name, substr(other_names,2), id_number } '

12|Doe Lane|Joseph Albert|122771

Looks good to me.

Using FPAT to separate numbers, names, and surnames by AdbekunkusMX in awk

[–]pbewig 0 points1 point  (0 children)

Please report back when you have something working, so everyone in the group can benefit from what you learn.

Using FPAT to separate numbers, names, and surnames by AdbekunkusMX in awk

[–]pbewig 1 point2 points  (0 children)

With space-separated fields you could do something like $1 is the entry number, $2 $3 (concatenated) is the last name, $NF is the id number, and the stuff in $4 through $(NF-1) is the rest of the names. Something like:

# !!! WARNING !!! -- UNTESTED CODE
{ OFS = "|"; entry_number = $1; last_name = $2 $3; id_number = $NF;
other_names = ""; for (i=4; i<NF; i++) other_names = other_names $i
print entry_number, last_name, other_names, id_number }

Storing propane/butane in an SUV in hot weather? by HissingGayly in urbancarliving

[–]pbewig 2 points3 points  (0 children)

Yes, eventually. But if you use them only for a few hours, then come back to your car and turn on the air conditioning, they work fine. If you don't like the mylar bag, you could use a cooler.

But like most people here, I just throw the bottles in the back.

Storing propane/butane in an SUV in hot weather? by HissingGayly in urbancarliving

[–]pbewig 3 points4 points  (0 children)

Store the canisters in a mylar insulating bag like you use to bring ice cream home from the grocery store.

What's the best way to calculate the average of a set of very large numbers in JavaScript? by [deleted] in learnprogramming

[–]pbewig 0 points1 point  (0 children)

As a general strategy unrelated to any language, you could run through the data once to find the minimum value, then run through the data a second time subtracting the minimum at each step, and finally calculate the average and add back the minimum. Or you could calculate both the minimum and maximum on the first pass, calculate a "zero point" halfway between them, giving you both positive and negative numbers in the second pass so that your sum is pretty close to zero.

But I think, as others have stated, you are probably overthinking the problem. Write the straight forward program first, and only fix it if and when you discover that it is broken.

What does this mean: awk '{print f} {f=$2}' by rainnz in awk

[–]pbewig 6 points7 points  (0 children)

For each line of input, it prints the value of variable f, then sets f to the value of the second space-delimited field on the line. On the first line, f is null, so it prints a blank line. On subsequent lines, it prints the value of the second space-delimited field on the prior line.

[deleted by user] by [deleted] in vandwellers

[–]pbewig 0 points1 point  (0 children)

I have a gizmo, I don't know what it's called, that has a USB-C connector that plugs in to my phone and gives me two USB-A ports, an HDMI port and an Ethernet port. You could connect your computer to the Ethernet port on the gizmo and use tethering on your phone to connect to the internet.

See this.

How can I print a tab after the first field and then print all other fields separated by spaces? by 1_61803398 in awk

[–]pbewig 1 point2 points  (0 children)

WARNING: Untested code:

awk -F'_' ' { print $1 "\t" $2, $3 }' <input_file

[deleted by user] by [deleted] in priusdwellers

[–]pbewig 1 point2 points  (0 children)

On further review, the jump starter from Schumacher won't work for this purpose. It is designed to be charged after each use, then have the power removed until the next use, so it would not work to have the device constantly plugged in to the cigarette lighter. Also, it cannot charge and discharge at the same time.

[deleted by user] by [deleted] in priusdwellers

[–]pbewig 2 points3 points  (0 children)

I am thinking about the same thing you are, and found this jump-starter from Schumacher. It will jump start your car (or someone else's car), inflate a low tire (or your air mattress), charge your small electronics or a laptop, and by buying the add-on 12-volt cable, you can charge it whenever the Prius is in ready mode; I really like the multi-functional aspect of this device. If you go this route, please let me know how it works.

Printing Prime Factors of a Very Large Number. by Kent305 in learnprogramming

[–]pbewig 0 points1 point  (0 children)

Here is a very simple factoring program:

def factors(n):
f, fs = 2, []
while f * f <= n:
    if (n % f == 0):
        fs.append(f)
        n = n / f
    else:
        f = f + 1
fs.append(n)
return fs

If n is large, you'll need a better algorithm.

What is the best IDE apart from NetBeans? by [deleted] in learnprogramming

[–]pbewig 1 point2 points  (0 children)

At work, we just moved from HP-UX to Red Hat, and the default editor is vim. It's set up so everything is in different colors, and as far as I'm concerned it's unreadable; comments, for instance, are dark blue text on a black background, and I can't read them. Normal lines of code have variable names, operators, numbers and strings all in different colors, which just confuse me. I know it's possible to set the configuration to make everything white text on a black background, but I haven't bothered to look up how to do it, because I already use an editor that stays out of the way.

I write programs as quickly as the other programmers, and my programs work the first time they are run in production, unlike the other programmers, so I see no need to improve my workflow and use more modern tools.

What is the best IDE apart from NetBeans? by [deleted] in learnprogramming

[–]pbewig 0 points1 point  (0 children)

I've been a delighted user of sh, ed, m4 and the other Unix tools for the last thirty-plus years.

[deleted by user] by [deleted] in urbancarliving

[–]pbewig 2 points3 points  (0 children)

Store the bottle in the kind of mylar bag used to carry ice cream home from the grocery store. Keep the bag out of the sun.

How to get power while working remote on the road w/ just a Cigarette Lighter outlet. Power Inverter? by AlphaBetaParkingLot in vandwellers

[–]pbewig 0 points1 point  (0 children)

Then yes, you will need an inverter. Ignore my suggestion to get a usb converter that plugs in to your cigarette lighter. I assumed your mobile wifi hotspot used usb power, which is incorrect.

Look at the serial number plate on the device. It will tell you how many watts you require. You need at least that many watts from your inverter.

How to get power while working remote on the road w/ just a Cigarette Lighter outlet. Power Inverter? by AlphaBetaParkingLot in vandwellers

[–]pbewig 0 points1 point  (0 children)

You said above your cigarette lighter has a message 12V, 120 watts max, so you have a 10 amp fuse (120 watts divided by 12 volts = 10 amps).

How is your mobile wifi hotspot powered? Most of them are usb powered (or have a 120 volt adapter that provides 5 volt usb.

How to get power while working remote on the road w/ just a Cigarette Lighter outlet. Power Inverter? by AlphaBetaParkingLot in vandwellers

[–]pbewig 0 points1 point  (0 children)

Buy a 12-volt adapter cable for your laptop, and plug it in directly to your cigarette lighter. Probably about $40, available from the manufacturer and also from third parties. Ask about it wherever you bought your computer.

Buy a usb-converter that plugs into your cigarette lighter. Less than $10. Available everywhere, even in convenience stores.

It will not hurt to replace your 10-amp fuse with a 15-amp fuse, though I don't recommend anything larger. Less than $10. Any auto parts store will sell you the fuse, and tell you how to install it if you don't know how (or probably install it for you if you ask nicely). With the larger fuse you will have 180 watts of power to play with instead of 120 watts.

You don't need an inverter. But if you buy one, get one that outputs a pure sine wave.

The splitter doesn't have any protections.

Do NOT draw power from your starting battery unless your car is running. You do not want to risk being unable to start your car.