#unix

1 messages Β· Page 43 of 1

sweet relic
#

so i created a file here /var/www/html/data.csv

#

just to test

#

how do I load it

#

putting the filename at the end of the url right?

tiny lava
#

yes

sweet relic
#

okay running localhost/data.csv downloaded the CSV

#

but i'd need to load into my JS code

tiny lava
#

Well everything from your webserver gets "downloaded"

#

Its just what your browser decides to do with them

#

if you load them from js the thing that is actually being sent is the content of the csv

#

if you used wget or curl before this might make more sense

#

the webserver simply serves files, it doesn't tell the client to download or display them

#

Actually I'm wrong lmao

#

its a http header

#

but that shouldn't matter for your js

sweet relic
#

yeah but what does 'serving' really mean then?

tiny lava
#

It sends some headers and then the content of the file over the connection

sweet relic
#

but then isn't it different than merely 'downloading' a file?

tiny lava
#

like how

#

The computer on the other side gets the content of the file either way, its just what they do with it

sweet relic
#

i was thinking i'd see a raw csv similar to what I see in gist

tiny lava
#

yeah thats because they sent a different HTTP header than you

#

but it shouldn't matter for loading it from JS

#

you'll get the same content

sweet relic
#

not sure how do I load it from JS

tiny lava
#

how are you getting it from gist?

sweet relic
#

i have its URL stored. so like:

var url = <gist_url>
var request = new XMLHttpRequest();
          request.open("GET", url, false);
          request.send(null);```
tiny lava
#

yep pretty sure that will work exactly the same with the new url

sweet relic
#

yeah that seemed to work! thanks

#

πŸ™‚

#

just playing around with it further...

sweet relic
#

do you know how to call a function only when a certain condition is true?

#
var myVar = setInterval(function() {
                       updateData();
                     }, 2000);
        }

calls updateData() every 2s. what if I want to call it only when a specific state changes

#

just to give you a context, i'd need to call updateData() when there's new data in the csv file which i'm checking by comparing the file length

tiny lava
#

I don't know javascript

#

but couldn't you just check if theres new data in the updateData function?

#

or call another function that checks that and runs updateData if so

obtuse depot
#

why not call updateData() when you check the file?

sweet relic
#

my bad. wrong channel

#

why not call updateData() when you check the file?
i need to separate out the code but currently i'm checking inside updateData() but logically it won't make any diff

obtuse depot
#

what about using signals?

sweet relic
#

cause instead of calling updateData(), i'd be reading in the file size every 2s instead

#

never used signals

#

you mean pattern?

obtuse depot
#

I'm sorry, I'm not quite sure what you're doing, or why you can't fire off an updateData inside your code that checks for file changes

#

if you need to decouple it, register it as a callback instead

tiny lava
#

You could have a backend that tells the javascript when the file size changes

obtuse depot
#

oh, are you saying your python watches the file, and has to communicate with Javascript?

#

there are a few interesting ways to do that python->javascript communication, but ultimately you're either going to be periodically polling HTTP, or you're going to establish a websocket connection (e.g. python/tornado server) and push the notification for change

#

but I'm kind of lost here, not sure what you're trying to do exactly

sweet relic
#

no i'm not using python. i have a C code that appends to a csv and JS to read off of it and plot it out

obtuse depot
#

node.js then?

#

are you using fs.watchFile()?

tiny lava
#

not node, he is just serving it from a webserver

obtuse depot
#

ok... so what's watching the file?

tiny lava
#

nothing

#

thats the problem he is trying to solve

obtuse depot
#

how does that file get into JS?

tiny lava
#

an http request

obtuse depot
#

browser uploading file to JS?

#

upload dialog?

tiny lava
#

not sure what you mean

#
var url = <gist_url>
var request = new XMLHttpRequest();
          request.open("GET", url, false);
          request.send(null);
#

this is what he is doing

obtuse depot
#

ok, this does an HTTP request to a url

tiny lava
#

yes

obtuse depot
#

how do we get from a file to here?

#

webserver serving CSV file as static content?

tiny lava
#

the file is in his web root

obtuse depot
#

ok, I'm going to just assume there's a webserver installed and it's serving files from there and you can point a browser at the URL and download the file

#

in that case you have no server-side file watching, therefore your javascript is going to have to poll the file. You either are going to have to GET the whole file every time, or depending on server you may be able to do a HEAD request to get the file size instead to save on having to fetch the whole thing

#

once you get the size, either because you grabbed the whole file again, or because you got it from the HEAD request, if the size is different from last time, run your updateData()

#

if you want to abstract updateData, from whatever's doing the Ajax, you can either do that having an object that's doing the ajax polling have a method that you can use to register the updateData function as a callback to it

#

or if you want more decoupling, you could use Events, and have the Ajax object emit an event, that the updateData is registered to

#

up to you really

#

also consider the Fetch API rather than old-school Ajax

sweet relic
#

so the syntax for a head request isrequest.open("HEAD", url);? where's the file size stored?

#

and which Fetch API are you referring to? sorry i'm not too into JS. just learning a bit on the side to get this part of the project done

obtuse depot
#

Fetch API is a newer interface for making HTTP requests, and supports promises, it's much nicer to use than XMLHttpRequest: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

#

before you commit to going with HEAD, I suggest you poke it with an HTTP tool, and see what it gives back. If it doesn't give back any data like file sizes or last update time that you can use to detect changes, you're going to have to go back to doing a GET and then checking the returned filesize

#

(HTTP tool like Postman)

sweet relic
#

but didn't we settle on that HEAD is used to give you a specific info while GET gives you the entire content?

obtuse depot
#

only if the server provides that info, and not all servers do. so I suggest you check first before going with that option

sweet relic
#

how do I check with an HTTP tool? it's a separate toolkit?

obtuse depot
#

there are lots of programs that frontend devs use, a popular one is Postman

#

here, I quickly spun up a python server (good old python -m http.server since we're in a Python discord), and then poked a file with a HEAD request. the return headers can be seen to the right, note that it does give me: Content-Length which is the filesize in bytes; and Last-Modified key which matches the file I have on disk:

#

(aside from timezones)

sweet relic
#

i'm using this server on an RPI and the only supported OS i'm seeing for postman is mac/windows

obtuse depot
#

Postman is a dev tool, use it to check your HTTP endpoints

#

you are just using it to figure out what a particular request is going to return. are you actually developing on an RPi?

#

I'm literally just asking you to use it or a related tool to confirm that your web server will return you file siz (content-length) headers for your file. It should but it's best to be sure. Do this before committing to using HEAD as a way to check for file changes

#

I'm not asking you to incorporate Postman or anything into your actual program, it is a development tool

sweet relic
#

i thought you mentioned postman in response to my question of going about checking the file size

obtuse depot
#
  1. get postman or related tool.
  2. use postman to confirm to yourself that your server is providing a content-length or last-modified header that you can use to detect file changes
  3. close postman
  4. write your javascript code to make this HEAD request and extract the content-length/last-modified header to use as part of your ap
  5. the rest
sweet relic
#

yeah that's what i understood, and that's what i'm doing right now and like i said i couldn't find a linux compatible OS version of postman

obtuse depot
#

Postman is on Linux

sweet relic
#

looks like i can't open the executable

obtuse depot
#

there's several chrome extensions as well

sweet relic
obtuse depot
#

nice

#

so yeah, it's giving you countent-length of only 42 bytes, check that this changes when you update the CSV file

#

if it does, you're all good to use file size for change detection through HEAD request

#

BUT also consider using the last-modified timestamp (or both!) as well

sweet relic
#

yeah but how does one access any of these headers?

#

getResponseHeader() apparently

#

so i'd still have to use the GET request to obtain the contents of the file once the condition is true anyways right

obtuse depot
#

yes

#

now, it should be pointed out that you could just GET all the time if you're not worried about latency of file transfer speeds, which would be the case if everything's local, but doing a HEAD for polling for file changes just feels neater

#

and since you're using fetch with promises, you can chain promises (or await) nicely

sweet relic
#

yeah I agree

#

but for some reason the HEAD request doesn't seem to take into account the latest changes in the csv

#
function readFileSize() {
  var request = new XMLHttpRequest();
  request.open("HEAD", url, false);
  request.send(null);
  len = request.getResponseHeader("content-length"); //   remains the same even tho the actual size has increased
}
  setInterval(function() {
            readFileSize();
          }, 500);```
#

actually now it seems to work. wasn't updating for some reason before

sweet relic
#

does anyone know why I don't have the permissions to write to /var/www/html?

#

even running chmod 766 -R /var/www/html doesn't help

obtuse depot
#

is your FS mounted read-only?

#

sometimes due to fsck or other boot issues, booting falls back to mounting root as read only

sweet relic
#

i can modify files in other dirs

#

just can't seem to in /var/www/html

obtuse depot
#

weird, can you do it while sudo?

sweet relic
#

do what? run the chmod command?

obtuse depot
#

touch files in there

sweet relic
#

are you saying if i should create files using touch command or?

obtuse depot
#

something like that

sweet relic
#

i observed that i didnt have issues modifying via command line. but using the GUI is what seems to create an issue

icy flicker
dreamy wing
#

Any video editors for linux like Sony Vegas?

plush sparrow
#

KDENLive

#

or just use ffmpeg directly smugpepe

mossy wharf
#

How should I start

#

Unix

obtuse depot
#

usually the power button does it

urban axle
#

tsk tsk, or you can use jumper cables if you're running Debian :p

#

@mossy wharf are you getting into Unix?

silent vector
#

@mossy wharf Just burn ubuntu in an usb

#

and boot from it

urban axle
#

always a good suggestion for starting; you don't want to compile Linux from scratch until after a good couple of weeks

silent vector
#

If you wanna go hardcore

#

LFS is the way

#

@urban axle Wait have you done this before ??

urban axle
#

fool. foolish work. we must start from the basic silicon chip and go upward

#

@silent vector noooo

#

compiling Firefox was annoying enough

silent vector
#

@urban axle Yeah true

#

BUt its pretty cool though

#

If you want to get to the neety gritty

urban axle
#

I just poke at /etc/passwd for fun sometimes

silent vector
#

Yeah dont do that

urban axle
#

it's clean and easy and I can stop anyti

#

oh no the ghost of sudoers is haunting me now someone get a broom

silent vector
#

try ''' dd bs=4M if=/home/<your_user>/<.iso> of=/dev/sda '''

#

Thats a fun command

#

But seriously

#

DOnt try

urban axle
#

I saw bs=4M and was already scared

silent vector
#

You know what it does

#

??

urban axle
#

HEY

obtuse depot
#

this is called "can I reinstall my system from itself?"

urban axle
#

no resetting

obtuse depot
#

I wonder if you can achieve this without hard crashing....

silent vector
#

@obtuse depot Ma man

urban axle
#

just hotpatch each and every file and restart each service

obtuse depot
#

restart services just ahead of the DD write

urban axle
#

initd might be hard but I'm sure you can get a couple of magnets to do the trick

obtuse depot
#

you know if you're fast enough you can probably just do a hard drive platter swap while it's spinning

urban axle
#

something something xkcd butterfly :p

main olive
#

am I able to make my self a script where it would make a screen and go into it and run something and go out and make another one and do the steps over and over? for linux

main olive
#

"make a screen"?

#

@main olive

round shuttle
#

If you mean "open a window", yeah, it's possible, at in Python and/or C (as for bash, I doubt it). As to wether you're able to do it, I don't know you, so I can't tell πŸ˜‰. I have never done this yet, so I won't be much help, but it's definitely possible.

mossy wharf
#

@mossy wharf are you getting into Unix?
@urban axle yes

urban axle
#

@mossy wharf definitely go for Ubuntu, then. the UI might not be your thing but the internals are set up wonderfully easy and the package manager is pretty wide

main olive
#

I made an install.sh file, but the bash command to install gradle out of the other commands didn't work?
Does anybody know what could have gone wrong?
Is this a dependency issue?
Also should I use apt-get update just once in the starting and apt-get upgrade just once in the end?

obtuse depot
#

check line endings

#

it's a common issue, sometimes windows-style line endings crop in and the script doesn't work but it's non-obvious

#

but other than that, yea check your dependencies, check your env vars, and all that

formal schooner
#

@main olive can you clarify what "didn't work" means?

#

i've had all-in-one install scripts like that. and i did

apt-get update
apt-get upgrade
# install all your stuff
apt-get upgrade
#

worst case is that it tells you there's nothing to upgrade the 2nd time

tiny lava
#

I would think the second one always does nothing

#

first one upgrades all your currently installed packages, and then all the new ones are installed with their most current versions

formal schooner
#

yeah

#

im just never sure

#

knowing how squirrely dependency resolution can be

boreal falcon
#

@main olive out of curiosity, how did you try to install it ? I guess it's not available in package manager

main olive
#

gradle is installed using sdk right now, so u need to install sdk first

#

yes it isn't like apt-get install gradle

#

so it's a sdk manager.

mossy wharf
#

Ok I installed ubuntu

#

Wats next to learn in unix

#

How should I start after that @urban axle

worldly bridge
#

:0

boreal falcon
#

@main olive well the error messages usually tell exactly what went wrong

main olive
#

there is no error message, it was just not installed

#

also, u don't have to ping me, I am reading what you have to say to me πŸ˜‡

urban axle
#

How should I start after that @urban axle
@mossy wharf Well, what do you eant to do?

#

I would recommend messing with the terminal

#

Try GNU tools included

#

less, vi, nano, tee…

#

there are many many tools to build data together!

#

and pipes help you put them from one to the other

#

a rather basic example might be cat filepath | hello would take the contents of filepath and pipe it as input to hello

boreal falcon
#

then there is a manual way, which should work

#

actually never tried installing it with sdk manager

main olive
#

what manual way?

boreal falcon
#

need to download binaries, then set up environment variables

main olive
#

oh yeh

mossy wharf
#

O ok

silent vector
#

@mossy wharf Install gentoo

#

So you get the real linux experience

plush sparrow
#

Any stage 3 lads? πŸ€”

mossy wharf
#

Well i installed ubuntu maybe next tym will give it a try

round shuttle
#

You could learn to dual-boot, as well
That's some fun !

main olive
#

Are these necessary files in my root directory?

[shaen@xx /]$ ls -l | grep txt
-rw-r--r--   1 root root 23642 Jun  6 03:06 desktopfs-pkgs.txt
-rw-r--r--   1 root root  5037 Jun  6 03:04 rootfs-pkgs.txt

Aesthetically, I dont care for the length of the file names in my root where its nothing but short fnames that are fairly compactly viewed otherwise.

main olive
#

you can delete those

#

also, why is your pc named after me

#

@main olive

#

lol. because I started with x and decided it didn't look long enough. Then I tried xxx and that made me feel like people would think it was porn. And then I realized your name is perfect, and I did note that it is your name when I chose to name it after you, but not intentionally. πŸ˜›

#

the main reason x doesnt work is because x refers to something else already

#

I was reading about the significance of /run/media as a replacement spot for auto mounted drives. Someone on stackoverflow said it was due to somethings called udisks performing tasks before it has access to something. So /media/ was moved to there which apparently came from /var/run where it was originally. Kind of weird.

#

What does udisks do differently than... mount and a fstab?

mossy wharf
#

Why my is so slow while I copy things

#

In ubuntu

#

I'm new to this can anyone help

main olive
#

Does anyone know the command to install python on linux debian

#

its possible that this is not still a problem, also.

#

The time i did it they only had 3.5

#

maybe even 4

#

I'm noticing that I have both a /root dir and a /home/root dir. Hrmm...

#

What is the meaning of this...

formal schooner
#

imo just use pyenv

#

ignore all that junk

boreal falcon
#

or just use the version that is preinstalled

main olive
#

if you are on base debian, nothing is preinstalled.

#

Literally almost nothing.

#

The main reason I had to deal with it was I thought debian would be a good choice for my first server, and my first server needed python 3.7, because of the tech stack to run Django. But if you install from the source, it's not gonna be enough. For that reason I dont really start with debian anymore ha

#
[shaen@xx public]$ ls -l .. | grep public
drwxrwxr-x  2 root  public  4096 Jul  9 07:55 public
[shaen@xx public]$ groups
{REDACTED...} public
[shaen@xx public]$ touch test && ls -l | grep *test*
-rw-r--r-- 1 shaen shaen 0 Jul  9 07:56 test

How can I make it so that any file that goes into this public directory is automatically given the group of this directory, regardless of who makes it... it already gives the group sole access to write there.

#

I feel like there is probably a simpler way than some of the ways im imagining

formal schooner
#

@main olive chmod g+s public

main olive
#

hrmmm... Im not familiar with +s

#

let me see

formal schooner
#

this is the "setGID bit"

main olive
#

ty

main olive
#

Do these look like reasonable [fstab] options here, assuming to the left are correct UUIDs? I didn't put the swap partition on there. I didnt seem like there was a need to. I'm not certain about the fsck value on the Windows device. And because ive never seen the effects of the default options im not really sure if those are what i want for my internal storage and externals. or not.

#

I should have done this a long time ago on my old system lol. But I was too much of a newb when i started and then i never got around to it

#

the storage one works. Some is off about the hotplugable one. I'll figures it out.

#

It doesnt like that hotplug option i saw someone use but since i dont want it on auto anyway, hopefully it wont have trouble trying to boot. according to some random poster.

#

it otherwise work tho

silent vector
#

@main olive The boot,root and home look fine

thin hawk
#

Hey, how do I bootstrap my dotfiles(vim, polybar, i3, ncmcpp etc.)? I've heard about yaml, could you suggest me how do I acheive easier management of dotfiles?

#

I know it's off-topic, but any suggestions would be appreciated.

formal schooner
#

that's an open question

#

there are a few solutions

#

some people use GNU Stow

#

some people write their own scripts

#

some people use a tool that i used to use called Dotbot

#

(incidentally written in python)

pulsar vapor
#

Guys! What is the best method to watch a folder in unix for changes? I've heard "inotify" is one way of doing it, but I think I've heard of others too and want to use what's best. Thank you and sorry if this is a dumb question. :I

robust cave
#

@thin hawk GNU stow, yadm, dotdrop, dotfiles, chezmoi, homeshick, etc.. pick your poison

#

@pulsar vapor try entr

pulsar vapor
#

@robust cave Thank you Kosayoda!

thin hawk
#

Thanks

modern kestrel
#

how can i follow a port forwarding request?

#

trying to see if it is actually going via a remote bastion before hitting the endpoint i want

obtuse depot
#

$$ in bash is a process ID

#

you don't have a space between echo and $$

mossy wharf
#

Ho ok tq

plush sparrow
#

I love to swap. I do it all the time. I wake up, I do some swapping to get my day started. Sometimes I swap just for fun and sometimes I do it to relax myself in the evening before going to bed. I love to swap. I removed most of the ram, left only 20mb for the swapping. I use old hdd that my dad gave me before he passed away. With his last breath he told me: "Son, do not listen to the naysayers, swap is all that matters, swap is the answer to the meaning of life, swap swiftly, swap with pride." I always listen to those words in my head when i swap with that hdd, my eyes tear up and sometimes I get a tingling sensation through my whole body. I need to swap right now. I failed school because all I did was swap, they fired me from numerous jobs because all I did was swap. I swapped my wife and kids, I swapped my career, I swapped my future. I want to swap my life. I love swap. pls help

obtuse depot
#

you know, these days I've noticed by default linuxes (by which I mean ubuntu since that's all I seem to install these days) has switched from swap partitions to swap files

#

I think this is a good thing. I'm fed up with losing disk space to swap partitions just because the RAM in this computer is disproportionately large compared to the drive space

#

16GB RAM on a machine with only 100gb of drive space, if you follow the old 1.5x rule of thumb for swap partitions, you've just lost 25% of your drive to a swap partition

main olive
#

1.5x swap for 16G ram is ridiculous

#

i don't think you even need 0.5x of that

#

16 + (16 x 1.5) = 40. I have 40G memory and no swap, and regularly have a pretty heavy workload (multiple browsers, VMs, Burp, electron apps etc) and I've never encountered my memory getting full to the point where I'd need to swap

obtuse depot
#

depends if you want to hibernate on swap

#

πŸ€·β€β™‚οΈ

main olive
#

ah yeah that's one downside

#

but meh, sleep is fine for me

obtuse depot
#

that is true, and on server machines none of this applies anyway. but my point still stands that swap on root fs is probably a better option for most people these days despite the drawbacks, and I'm happy that that's the case

main olive
#

it depends on your host fs, to be honest

#

if your swapfile is on a journaling or COW fs, it's going to drastically hit the performance of the drive and perhaps even the lifespan

#

the main benefit of swap-as-partition is that it runs its own fs with basically no overhead and potentially troublesome fs features, such as cow

obtuse depot
#

my thoughts on this is that you want to not swap. and swapping is a backup plan in case things go south in the RAM department. Things will be terrible, but you're not going to hard crash while you're swapping heavily

#

if you do swap a lot, then yeah, swap partition might be the way

thin hawk
#

@robust cave You told me a hell of a thing, chezmoi is wow, i'm working on makefile, would surely share my dotfiles. Thanks man!

pale harness
#

how to i upgrade my python version on ubuntu 18?

#

i wanna upgrade from 3.6 to 3.8

main olive
#

@pale harness pyenv

pale harness
#

what

main olive
pale harness
#

sry uh

#

im completely new to this stuff

#

ah wait- nvm i got it

obtuse depot
#

ah wait- nvm i got it
no, nvm is for node versions, you should be using pyenv

hollow linden
#

Guys is there any like free SSH server I can connect to?

#

(Not heroku please)

boreal falcon
#

do you need remote server specifically ?

hollow linden
#

I mean , only I want to mess with it and have some files in it

#

and I wanna run the files sometimes

main olive
#

@hollow linden google cloud

#

gives 12 months

#

of free vps

hollow linden
#

I see

main olive
#

AWS does the same as far as i remember

#

but google one is the one i've been using myself

hollow linden
#

Do they need credit card info?

main olive
#

ye

#

they dont charge

#

though

hollow linden
#

So I can't do it

main olive
#

even after 12 months expire

#

dont you have a credit card

#

maybe they added paypal as an option

hollow linden
#

Ik , bur the problem is , I don't have a valid card

#

but*

main olive
#

well

#

maybe your relatives do

#

its free of charge

#

they just require information

#

as far as i remember

hollow linden
#

ok...I live in Iran and it's not supported

#

Neither does paypal

main olive
#

you can use vpn

#

there are many cheap ones

hollow linden
#

But the problem isn't the site

#

It doesn't support credit cards

#

Iranian credit cards*

main olive
#

oh

#

does it only accept credit card

#

or paypal too

#

perhaps

summer trail
#

ok...I live in Iran and it's not supported
@hollow linden (not that this is on-topic for this channel, but in case you don't realize this): US companies are not allowed to do business with Iranian nationals. If they were to take your money, they'd be committing a crime.

digital haven
#

is anyone able to record audio from their terminal using mac os? I'm trying sox, it's not working for me

#

ok.... it works on Terminal but not iTerm, why would that be?

brisk sky
#

hi anyone here knows about raspberry pi? I have a one from 2012 I believe, when I try to sudo apt-get update, it manages to fetch some things, but then it tries to reach some links and it gives me a 404 Not Found error, this happens to every update/install that I try to make
I tried to get pip by sudo apt install python3-pip and it happens the same
if someone could please help me I would really appreciate it

obtuse depot
#

likely it's running quite an old OS, which has since moved their apt lists elsewhere

#

you can either go look at your apt lists and get new URLs

#

or, consider reinstalling a newer OS

#

I'd recommend reinstalling if you're starting fresh. now's a good time for it

ionic swift
#

Does top show if it's using 100% of the core or utilizing 100% of the core?

fresh saddle
#

100% of the core available time

boreal falcon
#

what's the difference between using and utilizing ?

fresh saddle
#

I think it is the same idea

#

Well, that's the same word, just not at the same tense

round shuttle
#

It's the same idea, but not the same word : 'to use' vs 'to utilize'.
I think there's a minor subtelty between the two, but I can't put my finger on it…

dreamy wing
#

Anyone know how to launch a new vlc process from terminal in such that when the terminal closes, it is still open?

round shuttle
#

yeah

#
nohup vlc &
dreamy wing
#

thanks

warped nimbus
#

<IN> is just a placeholder

#

I think the way this works is you specify a prefix once to i and your files are supposed to be named like the docs show

#

So if your prefix is hello then your files should be named hello_params hello0_int and so on

#

Probably, but I am not sure

round shuttle
#

To me, you wouldn't omit anything, you hust should rename your files according to the pattern; then, you just pass the common prefix as paramter to -i. For example, rename your files hello_params, hello0_int, hello1_int, hello_blast, and then just call ./networkblast -i hello -o whatever

swift pond
#

But it doesn't work when I try it in my terminal

warped nimbus
#

I don't know of a site to test egrep specifically. Your site does support the PERL style, and so does GNU grep with grep -P.

swift pond
#

I'll try grep -P, thanks so much man

main olive
#

anyone have any good vm recommendations cuz im thinking about setting up a unix flavour on there

warped nimbus
#

What kind of recommendation? VM software, or a Linux distro to put on it?

main olive
#

vm software

warped nimbus
#

Virtualbox is easy to set up

#

Qemu if you're feeling spicy

main olive
#

and flavour lol

#

dont know what to choose lol

warped nimbus
#

Wdym by flavour?

main olive
#

like unbunto

#

mint

warped nimbus
#

Yeah, that's typically called a distro (short for distribution)

main olive
#

lol ive been calling em flavors

warped nimbus
#

Everyone is gonna have a different preference. Just trying something out and see if you like it. Don't get too caught up trying to find what is "best"

main olive
#

ic

#

ima just download one and try it i guess

warped nimbus
#

I use Arch Linux but I would absolutely not recommend it for a Linux beginner.

#

Maybe Debian?

#

Heard good things about Mint and Manjaro too, but cannot speak from experience.

main olive
#

ima try unbunto first

#

see if i like it

warped nimbus
#

It's spelled Ubuntu

main olive
#

lol

#

tx for the advice tho

nimble panther
#

which distro do you guys recommend for turning an old laptop into a server of sorts to run discord bot(s)

round shuttle
#

Same as for a "regular" use, i.e. Ubuntu/Debian, imho

#

just boot it in init 3 / use the server version of the distro

nimble panther
#

thank you
I was thinking of init3 but felt that Manjaro (my main OS) is not the best choice.
I think I'll go with Debian.

formal schooner
#

debian for sure

#

old laptop seems like a good idea for a server, should be a lot more power effecient than e.g. an old workstation pc

plush sparrow
#

Rolling distros are easier ... change my mind. I would absolutely recommend arch/manjaro for your avg. window gamerchan over Debian/Ubuntu.

formal schooner
#

debian testing is damn near rolling

#

i dont have anything against arch

#

arch might be better just for the sheer breadth of the package ecosystem

summer trail
#

Rolling distros are easier until you hit a world-breaking bug, like a package that removes everything in the root filesystem when the package manager (running as root) tries to remove it, or something like that.

#

getting the latest and greatest packages as soon as they're available is all well and good until the latest and greatest version of a package corrupts a file you need, or breaks a feature you rely on, and then they're annoying, and in those cases you would have been thankful for the distribution to have gone through a testing period before you got that package.

serene eagle
warped nimbus
#

Are you on linux?

#

If so, it's source ./activate

#

Well, you don't necessarily have to be on linux. The above will work if you're using something like bash as your shell.

#

Oh this is #unix, silly of me to ask even

serene eagle
#

lol it's alright

#

lemme try it

warped nimbus
#

You didn't type what I showed

serene eagle
#

oh sorry

warped nimbus
#

Though I wonder why you have exe's in your environment if you're on linux

serene eagle
#

oh

warped nimbus
#

Did you copy it over from a Windows machine?

serene eagle
#

this is WSL lol

#

since I thought it's a linux thing

#

I should be asking here

warped nimbus
#

Yeah that's fine

#

I just didn't get that at first

serene eagle
#

well source didn't work

#

I wanna activate it cause all my modules are in there

#

I can't start without being able to activate it

#

and I gotta figure out the path

#

or I can't use selenium :3

warped nimbus
#

I'm honestly not sure. I've barely used WSL. Is it possible for you to recreate the venv through WSL?

serene eagle
#

Should be able to

#

because the commands work fine

#

docker works

warped nimbus
#

I wonder if it will still generate exes in there if you do it inside WSL

serene eagle
#

well yeah

#

not sure though

#

without a UI I had to navigate everythiing in a CLI

#

which I guess was the point

#

plus i'm liking the CLI

#

it's so much faster

warped nimbus
#

Usually on linux the venv activate will be in a bin folder instead of Scripts, and you'll have linux binaries instead of exes. Not sure what happens in WSL though

#

source .venv/bin/activate is how I activate venvs in bash on linux.

serene eagle
#

yeah let me try that actually

#

i'll make a new venv

warped nimbus
#

By the way, you can create a new venv with python -m venv /path/to/new_venv_folder

serene eagle
#

yeah

#

It needs

#

python3-venv

#

so i'm getting that

#

it worked

#

yeah

warped nimbus
serene eagle
#

I just gotta find the path

#

add gecko driver to it

#

I just have no idea how to do that

#

theres always yt lol

nimble panther
#

Rolling distros are easier ... change my mind. I would absolutely recommend arch/manjaro for your avg. window gamerchan over Debian/Ubuntu.
@plush sparrow sorry for the late reply, but would you recommend a rolling distro for a server?

#

I like Manjaro for the rolling releases but was not sure whether that would be the best choice for a server (guys feel free to ping me)

wicked aspen
#

The problem is that reading it in a usual way produces 63-char long string

#

While simply copying it into ipython produces 36-char long string

#

I tried various encodings, etc, but can't find the way to read it in such a way to produce the same 36-char string as I'd get by simply copying

#

Anyone knows the solution?

plush sparrow
#

@summer trail yay is not running as root

obtuse depot
#

why not python open() the file?

silent vector
#

@nimble panther Nope Debian /CentOS/Ubuntu

#

Do the job fine

#

Also they are the standad

#

And you can find solutions very easily if a problem occures

wicked aspen
#

why not python open() the file?
@obtuse depot well, try opening and reading that file, it produces different result from just copying the string.

obtuse depot
#

maybe you have some kind of encoding issue

#

I suggest exploring why your encoding is off, and using appropriate encoding options to load it correctly, otherwise open as binary and do the conversion yourself

#

a hex editor can help

nimble panther
#

thanks XLM

#

I have the live usb ready

#

with debian

plush sparrow
#

NixOS for servers is incredibly stable.

#

But I run Ubuntu on my personal one :-)

silent vector
#

@plush sparrow Whats nix based

#

On

#

Have heard of it

#

But just dont know what distro family it belongs to

formal schooner
#

Totally custom

silent vector
#

@formal schooner Ow so its similar to gentoo

#

You compile all your libraries

formal schooner
#

P sure it's source only yes

tawdry sonnet
#

I got no interest in linux as my os, I'm very happy with windows, however I would like to get comfortable using ubuntu server. I have a spare partition on my computer, can it be installed there no problem or will that not work?

tiny lava
#

it can be installed there but be prepared to do some troubleshooting, dual booting isn't always just plug and play

tawdry sonnet
#

Do you mean that the server version requires special boot options? I've used the partition with a few other distros to familiarize myself and never had issues.

tiny lava
#

I mean windows isn't great about being dualbooted

#

on ubuntu your bootloaders should work fine, but you'll still have to deal with like clock differences and such

tawdry sonnet
#

Oh okay. Yeah im familiar with that. Thanks for the heads up!

nimble panther
#

but how are you planning on using ubuntu as a server? You will not be able to use windows and ubuntu simultaneously

tiny lava
#

Well he can still practice on it without running persistent services

tawdry sonnet
#

Yeah that's the plan, I just want to play with it for future reference. I've been using docker containers, which work fine, however I want to compare them to the real thing.

summer trail
#

using WSL on Windows might be a better way to learn the Linux command line.

#

lower commitment than dual booting, and most everything will work the same.

formal schooner
#

Or a VM i guess

bright oasis
#

any one working on kernel module??

limpid fox
#

yeah. what's up?

topaz hemlock
#

Why is this working? ./foxit-reader-install.run but this one isn't working source foxit-reader-install.run ?
I Googled it and as far as I know sourcing runs the script in the current shell, while executing will run the script in another shell. But why would running the installer script in the current shell not work?

silent vector
#

@dr777#3880 Been reading the linux device drivers book

#

Its pretty cool

heady shore
#

@topaz hemlock What isn't working about that?

topaz hemlock
#

~/Downloads $ source FoxitReader.enu.setup.2.4.4.0911\(r057d814\).x64.run
FoxitReader.enu.setup.2.4.4.0911(r057d814).x64.run:20: parse error near )' ~/Downloads $ ./FoxitReader.enu.setup.2.4.4.0911(r057d814).x64.run`
[this time no errors! installed successfully]

formal schooner
#

@topaz hemlock look at the shebang

#

It probably isn't a shell script

#

Or might be for a different shell

main olive
#

Hello! I am new to Python (also I don't know where to fit my question). I wanted to ask if it is possible to have two different versions of Python installed on Mac? I have currently Python 3.7.7. but I need Python 2 to run a program which is working only on Python 2.

trail grove
#

yes, it's very possible, and easy to manage using pyenv: https://github.com/pyenv/pyenv

main olive
#

Thank you for quick reply! I will try

topaz hemlock
#

@formal schooner it's not a script, I open it with a text editor and there's no shebang. Just gibberish.

main olive
#

do file xxxxxx it'll tell you what type of file it is

#

and yea source runs a script

#

.run isnt normally a script, but a binary executable

heady shore
#

Right, can't source a binary

formal schooner
#

@topaz hemlock that means it's definitely not a shell script. so obviously sourceing it would fail

#

source just reads one line at a time and executes it in the current shell session

topaz hemlock
#

right

#

thanks yes that was the case

main olive
#

you can source binary files

#

There isn't a build of Python for PPC higher than 2.5, correct?
(Debian Etch)
If I posted in the wrong channel, let me know.

#

seems right

#

Fook.

#

@main olive pyenv should be able to bootstrap you a 3.x though

#

On Debian 4?

#

Cause I'm doing this whole thing on a Wii XD

#

maybe

#

also isn't there a newer distro for the wii?

#

building python3 on the Wii will take quite a bit of time

#

There's Debian Jessie, but I spent so much time configuring Etch that I'd need a separate SD card.

#

and you may need to give it a large swap space

#

ie on the SD card itself

#

the Wii doesn't exactly have a lot of memory

#

88mb

#

Yep

#

what kernel version is it running btw?

#

Uhh

#

XWhiite V0.2 kernel 2.0 maybe?

#

I don't know how compatible newer python versions are with older kernels

#

The kernel version on the Wii is 2.6.27b.

#

(XWhiite)

#

@main olive I have heard of swap but I don't know how to use it/create a swap space

#

and 2.6 should be fine

#

Okay I'll check synaptic if it has pyenv

#

just use pyenv-installer

#

apt-get install pyenv-installer or just pyenv-installer?

main olive
#

@main olive curl https://pyenv.run | bash

main olive
#

@main olive bash: curl: command not found

main olive
#

do you have wget?

#

wget https://pyenv.run -O pyenv-install && chmod +x pyenv-install && ./pyenv-install

main olive
#

Okay I'll look into it

#

I don't have wget btw

main olive
#

@main olive

blissful sage
#

help

#

terminal keeps using the > symbol

sinful solar
#

what do you mean?

blissful sage
#

i was trying to run a cat command

#

and now

#
> :q
> :
> q
> exit
> wq
> q
> :wq
> :qw
> 
#

this keeps happening

sinful solar
#

in the terminal?

blissful sage
#

yea

#

well

#

i mean i typed those letters

sinful solar
#

press ctrl + c

blissful sage
#

ok thx

#

tht worked

#

what was going on?

sinful solar
#

you just typed cat?

blissful sage
#

well there was a file path after

#

but it had a ' by mitake at the end

sinful solar
#

you cna press the up arrow to see what you typed

#

or the command history

#

i forgot the specifics to be honest

#

i think there's a command to prepend everything you type in cat with a certain char

heady shore
#

You were just stuck in a string? @blissful sage

sinful solar
#

perhaps someone else can shed some light

heady shore
#

but it had a ' by mitake at the end
Then you were stuck in a string

#

You can either get out by completing the string, or sending a SIGINT

blissful sage
#

Gotcha thnks

heady shore
#

πŸ‘

pseudo barn
#

anyone here an expert at terminal manipulation?

#

i have a program which has a spinner indicating what is running, and the output scrolling above it. the problem is i don't know how to do that, and it looks like this:

β£½ Updating Git repo 'cna-mme_cc'Already up to date.
⣟ Updating Git repo 'cna-mme_cc'Already up to date.
β£» Updating Git repo 'cna-mme_cc'Already up to date.
β£· Updating Git repo 'cna-mme_cc'Already up to date.
β£― Updating Git repo 'cna-mme_cc'Already up to date.

what i want it to look like:

Already up to date.
Already up to date.
Already up to date.
Already up to date.
Already up to date.
β£― Updating Git repo 'cna-mme_cc'
#

similar to npm's output, or apt's

formal schooner
#

you can use \r to overwrite the previous line instead of printing to a new one

humble onyx
#
# ./simple_program --script=helloworld
# ./simple_program --script helloworld
# ./simple_program script=helloworld```
What is the difference between those?
fresh saddle
#

It simply depends on how the software parses commandline args

#

Some softwares do it the first way, some the second, others the third...

formal schooner
#
  1. kernel runs ./simple_program with args: --script=helloworld
  2. kernel runs ./simple_program with args --script, helloworld
  3. kernel runs ./simple_program with args script=helloworld
#

so yes it's entirely up to simple_program to determine how to handle the args

humble onyx
#

in the third case isn't it an env variable?

formal schooner
#

no

fresh saddle
#

Nope

formal schooner
#

an env var would be script=helloworld ./simple_program

fresh saddle
#

Using an env var would be $MYVAR for instance

humble onyx
#

so it has to go before the program

formal schooner
#

yes

humble onyx
#

thanks

fresh saddle
#

Ah right

formal schooner
#

note that make lets you get loose with this. CC=gcc make and make CC=gcc do completely different things but have the same effect in most simple cases

#

so that is one potential source of confusion

humble onyx
#

I have never used make

formal schooner
#

then ignore what i just said πŸ™‚

humble onyx
#

is it something I should definetely look into?

#

I am not doing anything complicated so far

sinful solar
#

it's mostly for writing C programs so you don't compile by hand as your project structure grows

edgy matrix
heady shore
#

Don't know if there's a way to retrieve that info after it's crashed if it's not piping to a file. If you know how to reproduce, just run it from the term and pipe it to a logfile

#

Alternatively you can edit the startup file to do the same, and then next time it happens to crash, you can check the logs

modern kestrel
#

Anyone well versed in makefiles here?

heady shore
#

DATAJA - Don't ask to ask, just ask. ;]

modern kestrel
#

Sorted it

main olive
#

currently for a program im making, there is a script that is supposed to run every x hours. should i rely on telling the user to make crontab entries for the script, to allow greater customization, or should i find another way to cover it automatically in the setup.py script, at the cost of the users customizability, with the advantage of an easy setup

spare lagoon
main olive
#

thanks!

main olive
robust cave
#

what program does this? Id raise an issue, code shouldnt hard code path separators

main olive
#

i wrote sth in python for windows

#

and i kinda hardcoded seperators

#

now i kinda dont want to find em all

#

now im kinda sad

robust cave
#

how big is the code that you wouldn't want to "find them all"?

main olive
#

it occurs in multiple modules....

#

is os.path.join the perfered way

#

to prevent sth like this from happening

robust cave
#

is os.path.join the perfered way
@main olive that works, but if you're using >Python 3.4? I think use the pathlib module and PurePath.joinpath

main olive
#

i guess this is a lesson learned lol

formal schooner
#

os.path.join is fine if you dont like pathlib

main olive
#

ive been sticking with os.path.join cuz i tried pathlib once in a 3.8 venv and it said it couldnt import the pathlib module so ive just stayed away from it

main olive
#

like how would i edit as root

tiny lava
#

Chmod is the way to change permissions

#

Chown will change the owner

main olive
#

like i wanna login as root with winscp cuz im using that as a file navigator

tiny lava
#

then login as root

#

whats the issue

main olive
#

yeah i fixed it

#

i first tried chmod

#

but i didnt have permission

#

i didnt realize i could login as root

tiny lava
#

generally you shouldn't

#

but its okay to do it occasionally for things that require it

main olive
#

i wanted to add a bind-address

vital spire
#

@main olive Why not use sudo?

rocky plank
#

^

broken maple
#

can anyone help me with linux ?

robust cave
#

please don't ask to ask in this server, just state your question so anyone who is capable of answering can answer

broken maple
#

just a question dang no need to agro

#

ight heres my question

#

were do i start

main olive
#

when installing ubunt on VM, it freezes on install

heady shore
#

@broken maple DATAJA - Don't Ask To Ask, Just Ask

#

@main olive Where in the process?

main olive
#

When i install first time on VB

#

VM

#

first time it starts up to install

#

when it gets to the ubuntu logo and the loading icon it freezes completely

#

i increased the clocks in settings

#

and turned off/on 3d acceleration

boreal falcon
#

what about disk space and memory ?

main olive
#

i got 10gb virtual memory assigned ; s

#

thats probably why

boreal falcon
#

i dunno that should be enough

#

do you install fully from image or use network installation too ?

main olive
#

fully from image from ubuntu site

boreal falcon
main olive
#

how do i change it?

main olive
#

@boreal falcon

#

i changed the size

#

still freezes

boreal falcon
#

how many cpu cores did you assign ?

tawdry sonnet
#

I've been reading through the readline manual and playing around with it in bash. I'm looking for some kind of focused exercise type thing. Anyone know of something like that?

#

Something like "Do X manipulation in Y seconds using Z keystrokes"

#

Like touch-typing practice, but for readline and/or vim keystrokes.

heady shore
#

I don't know of anything like that, @tawdry sonnet, but that sounds like an excellent idea

clear scarab
vital spire
#

@clear scarab That's the same page. (EDIT: Fixed)

robust cave
vital spire
#

That's fun. I just tried one.

#

I only don't like that it doesn't reward generic solutions. Like all the input files are really small. So if you go manually through the lines to perform necessary operations it's fewer keystrokes/more points than creating a generic solution that works on files of any size.

digital haven
#

is there any reason that alias grep=egrep would be a bad idea?

#

seems that it'd do exactly the same thing just means I can use regex if i want

vital spire
#

Why not just use grep -E for regex support?

#

As for bad idea, maybe you don't always want regex? E.g. grepping for the literal character . as opposed to the regex equivalent. You'd need to escape these always then.

worn apex
#

well

#

you have to escape . anyway for regular grep

#

egrep just has more magic characters, regular grep doesn't have none, that's fgrep

#

it's still regex it just doesn't have some magic characters ( ) + by default [you can still get them with \ prefix on most systems]

vital spire
#

* for example.

worn apex
#

I tend to just put up with having to use \( \) \+ since i have to do that with vim anyway [vim regexes are an entirely different animal than the ones most people are used to from javascript/perl/etc once you get beyond the basics]

#
  • works in regular grep
vital spire
#
[me@linux ~]$ cat test
asdf.
*fda
.hi
[me@linux ~]$ grep '*' test
*fda

I mean this.

worn apex
#

well, that's because it isn't after anything

vital spire
#

Ah okay.

worn apex
#

'.*' has the same meaning in both grep and egrep

vital spire
#

The more you know

tawdry sonnet
#

On windows there is PortableApps, which is amazing for hopping across computers and performing regular resets. Anyone use something similar on linux? I've gotten use to never having to reconfigure my most important programs.

plush sparrow
#

I've gotten use to never having to reconfigure my most important programs

That's what you have dotfiles for

tawdry sonnet
#

You referring to the hidden files like .vimrc and .bashrc? Not really what I'd call portable since I'd have to relocate them off the usb and into the right directories.

formal schooner
#

yeah, applications on linux typically don't have "portable" version

#

sometimes you can customize the settings directory/file location with an environment variable

#

but other times they just hard-code to $XDG_CONFIG_PATH or worse to $HOME

#

if you compile the appliction from scratch often you can change the "prefix" which is usually / by default

#

e.g. ./configure --prefix=~/portableapps/myapp will install the app to ~/portableapps/myapp/{bin,var,lib,etc....}

rocky plank
#

anybody has any idea to why my chromium isn't displaying emojis?

#

like, my firefox displays em just fine, but chromium isn't

tawdry sonnet
#

Decoder problem? A buddies phone was doing that, turns out he had unicode disabled.

rocky plank
#

how can I check the decoder?

#

I'm relatively new to unix-like systems

#

(I don't even know if it's possible for instance)

tiny lava
#

Actually the script would be quite different, but the gist is you probably are using a font that doesn't support them

main olive
rocky plank
#

@tiny lava it worked! thank you so much for sending that solution (:

karmic owl
#

unix, minix, linux

plush sparrow
#

@tawdry sonnet USB? This is 2020, just have a git repo with your dotfiles that way they are always in sync.

tawdry sonnet
#

Not a bad idea, and I'll definitely use it for myself, but I was thinking more along the lines of not modifying any local files, should I be on a computer that isn't mine (friend, work, etc).

That said, the odds of that happening with a linux machine are almost non-existant. Happens frequently with windows.

loud monolith
#

Hello! Guys

modern kestrel
#
AVAILABLE_ENVS := eng transit-gateway
.PHONY: format
init:
    @cd $(BUILDPATH) && terraform init --reconfigure
test-%:
    $(eval ENV = $*)
    echo "env: $(ENV)"
ifneq ($(filter $(ENV),$(AVAILABLE_ENVS)),)
    $(eval BUILDPATH='$*/eu-west-2')
    @MAKE init BUILDPATH=$(BUILDPATH)
    @cd $(BUILDPATH) && terraform plan -var 'eks_cluster_name=$(cluster-name)'
else
    @echo "Invalid environment specified '$(ENV)'. Must be one of: $(AVAILABLE_ENVS)"
    exit 1
endif```
#

Anyone know why this makefile isn't working correctly? πŸ˜„

#

I just want it to make sure i'm passing either eng or transit-gateway through

formal schooner
#
.SHELL := /usr/bin/bash
AVAILABLE_ENVS := eng transit-gateway

.PHONY: format

init:
    @cd $(BUILDPATH) && terraform init --reconfigure

test-%:
    $(eval ENV = $*)
    echo "env: $(ENV)"
ifneq ($(filter $(ENV),$(AVAILABLE_ENVS)),)
    $(eval BUILDPATH='$*/eu-west-2')
    @MAKE init BUILDPATH=$(BUILDPATH)
    @cd $(BUILDPATH) && terraform plan -var 'eks_cluster_name=$(cluster-name)'
else
    @echo "Invalid environment specified '$(ENV)'. Must be one of: $(AVAILABLE_ENVS)"
    exit 1
endif

discord has makefile syntax πŸ™‚

#

what's wrong with the makefile currently?

#

what does $* mean in Make syntax?

#

ah implicit rule match

#

it looks right just eyeballing it

#

so im curious what the problem is

summer trail
#

I believe the ifneq is evaluated at the time the rule is defined, not when it's being executed - so, before ENV has been set.

formal schooner
#

presumably ENV is set before the makefile is run though right?

#

oh i see

#

yeah thats very very likely whats happening

#

youd need to wrap all this up in a macro and then call it

#

lots of $$ escaping

#

yuck

#

im not sure how youd even write that honestly

#
define test-rule =
    $(eval ENV = $*)
    @echo "env: $(ENV)"
ifneq ($(filter $(ENV),$(AVAILABLE_ENVS)),)
    $(eval BUILDPATH='$*/eu-west-2')
    @MAKE init BUILDPATH=$(BUILDPATH)
    @cd $(BUILDPATH) && terraform plan -var 'eks_cluster_name=$(cluster-name)'
else
    @echo "Invalid environment specified '$(ENV)'. Must be one of: $(AVAILABLE_ENVS)"
    exit 1
endif
endef

test-%:
    $(test-rule)

this might work as per https://www.gnu.org/software/make/manual/html_node/Canned-Recipes.html#Canned-Recipes

#

try it. you still might need to do a lot of $$ escaping to make it work

modern kestrel
#

@formal schooner hey thanks i actually gave up because it was just an additional layer i was adding to make it user friendly but ill take a look thank you

formal schooner
#

sure thing. as a starting point try $$-escaping everything in the define except $* itself

modern kestrel
#

@summer trail I believe the ifneq is evaluated at the time the rule is defined, not when it's being executed - so, before ENV has been set.

what did you mean by that sorry i just read bvack properlu

summer trail
#

the ifneq that you wrote is taking effect before the rule target is run, and the ENV isn't defined until the rule target is run.

modern kestrel
#

Ohh okay thats so weird but thanks for clarifying

formal schooner
#

that's just how make works

#

it interpolates all the variables first

topaz hemlock
#

Hi all

#

I have a git repository inside another git repository, and so I had problem staging all the files from the containing repo. So I searched it and it's called a submodule. Now my problem is, the command git submodule add needs a remote-url as one of its argument, while mine is here locally, what do I do?

trim girder
topaz hemlock
#

thank you

formal schooner
#

summary: git submodules without remotes dont really make sense πŸ™‚

digital haven
#
-> % if [[ "hello there" ~= .*?"there" ]]; then echo "yes"; fi
zsh: condition expected: ~=

-> % if [[ "hello there" =~ .*?"there" ]]; then echo "yes"; fi
zsh: failed to compile regex: repetition-operator operand invalid

how do i test for substring with a regex? πŸ€”

static cosmos
#

usually you jsut type the substring

#

if I want to search for hello in a file example I would type grep "hello" example

#

but for your code, it looks like you are trying to run bash code with zsh

digital haven
#

@static cosmos yeah i couldn't seem to find the zsh version of this

static cosmos
#

Why not just run it with bash?

digital haven
#

well my shell is zshell

static cosmos
#

you can still do bash <script> tho

#

unless you actually don't have bash installed

digital haven
#

so zshell doesn't have regex?

static cosmos
#

I'm pretty sure it just doesn't have that one conditional operator

digital haven
#

i can't find the one that it uses

static cosmos
#

actually this says it does have that operator

#

πŸ€”

#

So actually maybe its your regex thats broken

digital haven
#

looks ok, perhaps tho

#

it doesn't like *

static cosmos
#

Yeah I think there is something funky with the specific regex implementation or something

digital haven
#

weird, tested as a POSIX extended regular expression

#

I'm sure .*? is valid in that

static cosmos
#

I don't think this is related to the problem, but pretty sure the quotes will make it not match

digital haven
#

what do you mean

static cosmos
#

the quotes around there

digital haven
#

no that's fine

static cosmos
#

.*?"there" would only match like something"there"

digital haven
#

hrm

#
-> % if [[ 'hello there' =~ 'el' ]]; then echo 'yes'; fi
yes
#

no, seems ok

static cosmos
#

about about making the pattern .'el'

#

I wish I was booted into linux rn lmao

digital haven
#

also fine πŸ˜„

#
-> % if [[ 'hello there' =~ .'el' ]]; then echo 'yes'; fi
yes
static cosmos
#

weird I wonder how that works

digital haven
#

no idea lol, bash strings are always a mystery to me

#

i ended up solving this with if [[ "$(which python | sed -E 's/\/\.|\///g')" == *"virtual"* ]]

trim girder
#

You're trying to see if the current python executable points to a virtual environment?

warped nimbus
#

A better way may be to run a Python script that prints the site packages, or parse the python -m site output

#

Even then, the path doesn't necessarily have to have venv or virtual anywhere in its name

#

Or check environment variables, though I don't know which ones a venv sets

digital haven
#

@warped nimbus in general, no, in my usecase they're within ~/.virtualenvs though

#

env variable might make more sense though πŸ€”

formal schooner
#

afaik theres an env variable like $PYTHON_VIRTUALENV or something that should do it

robust cave
#

I test for $VIRTUAL_ENV, works with pipenv, poetry, pyenv-virtualenv

formal schooner
#

all of those use venv or virtualenv under the hood

#

and venv should be backward compatible with virtualenv

#

so makes sense

trim girder
#

Yeah I'd likely lean towards check the environment as well.

summer trail
obtuse depot
#

looks like a non-greedy dot match all to me

#

but I guess depends on flavour

main olive
#

Hi, since pipenv takes forever to check all the dependencies, I'd like to send a desktop notification whenever a pipenv command finishes

#

problem is, that I somehow dont manage to run that notification always after some pipenv command finishes

#

tried to make a function and set an alias to pipenv to call that function

#

but that somehow doesnt work out

#
        pipenv $@;
        notify-send 'Pipenv' 'has finally finished!'
}

alias pipenv='run_pipenv' ```
#

What am I doing wrong?

#

Hmm now its working as expected ...

#

not sure though

robust cave
#

I don't see anything wrong

#

if you're using bash there's a small chance you have an alias called alert in your ~/.bashrc, in which case you can just run

pipenv <args>; alert

and it'll send you a notification when the command finishes

main olive
#

Seems to be running now. Didnt change code, maybe just remainder of my failed tries

#

on an old terminal window

frosty patrol
#

Likely you didn't open a new terminal or source the changes?

main olive
#

yep, probably. It's working as expected now

#

should limit the output to install, sync, update

main olive
#

Hi. I was looking for some help regarding powerlevel10k. Could you please help me with this error in my terminal?

Last login: Thu Jul 30 on ttys002
/Users/useruser/.cache/p10k-instant-prompt-useruser.zsh:local:28: key: inconsistent type for assignment

_p9k_dump_instant_prompt:217: parse error near }' _p9k_dump_instant_prompt:zcompile:331: can't read file: /Users/useruser/.cache/p10k-instant-prompt-useruser.zsh _p9k_dump_state:53: parse error near )'
_p9k_dump_state:zcompile:23: can't read file: /Users/useruser/.cache/p10k-dump-useruser.zsh

??

formal schooner
#

@main olive are you sure you're running this with zsh and not bash or something?

main olive
#

Yes, macos

#

zsh

#

catalina

#

Was working just fine till one hour ago

#

@formal schooner

formal schooner
#

huh.

#

did you install it with homebrew, then brew update?

#

maybe something went wrong there

#

or maybe theres a bug in powerlevel 10k

main olive
#

I believe I installed it like this ^

#

@formal schooner

formal schooner
#

@main olive do you have a lot of things in your zshrc file?

main olive
#

Yup

#

Why?

formal schooner
#

can you share it?

#

!paste

shy yokeBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

main olive
#

I did share pastebin

formal schooner
#

that's fine

#

oh i see

#

i can't use pastebin at work :/

main olive
#

Not that too

formal schooner
#

you have the line source ~/powerlevel10k/powerlevel10k.zsh-theme in your zshrc file?

#

what happens if you run source ~/powerlevel10k/powerlevel10k.zsh-theme in ZSH?

#

same errors?

main olive
#

❯ source ~/powerlevel10k/powerlevel10k.zsh-theme ─╯
_p9k_dump_state:416: unmatched '
_p9k_dump_state:zcompile:23: can't read file: /Users/useruser/.cache/p10k-dump-useruser.zsh

#

@formal schooner

#

Found a workaround

#

That is the zshrc file

rotund imp
#

@rich sierra you can ask your question here probably

rich sierra
#

Any linux developer here? Familier with environment variables and cmake? Please

main olive
#

@formal schooner ?

rotund imp
#

@rich sierra just ask your question, someone here will know

rich sierra
#

Hello I am trying to compile firestorm https://blog.sarapayne.co.uk/2020/07/01/compile-firestorm-on-ubuntu-20-04/
I followed all the steps and it compiles and then i get error undefined reference to boost:details. Libboost is installed qnd updated but still getting this error

Compile Firestorm on Ubuntu 20.04. A guide to compiling the Firestorm Viewer using Ubuntu 2.04 Focal Foassa. Each stage broken down and explained.

main olive
#

@formal schooner

formal schooner
#

@main olive i saw and was away. One ping is enough.

#

It looks like your file got modified somehow

#

Try just deleting the repo and re-downloading it

rich sierra
#

I tried many times and even on different linux distribution

#

I think its environment variable issue cmake can't find boost libraries

main olive
#

@formal schooner Hi. How come the file was modified?

formal schooner
#

I have no idea

main olive
#

I fixed it but once that software/thing runs again it will again break my shell

#

How can I identify what software that is?

#

@formal schooner

formal schooner
#

How did you fix it

#

You are not giving enough detail

#

What "software/thing"?

main olive
#

The owner of the repo said run exec zsh -fc '{ rm -rf -- ~/powerlevel10k ~/.cache/p10k*(N); mv ~/.zshenv ~/.zshenv.bak; mv ~/.zprofile ~/.zprofile.bak } 2>/dev/null; git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k; exec zsh'

#

I ran it, got fixed

#

He said I have some bad software and "If you run it again, it'll again break your shell."

#

@formal schooner

formal schooner
#

Share your zshrc and zprofile and zshenv files

main olive
#

Would it still help even if my problem was for now fixed?

formal schooner
#

I probably wont be able to find the problem...

#

But you need to start disabling programs one by one

#

It sounds like you have something that is modifying other files

#

Eg inserting itself into zshrc

main olive
#

Not malware right?

formal schooner
#

Probably not

#

Just other badly designed software

main olive
#

Like what could it be for instance?

#

Example?

formal schooner
#

I have no idea

#

I am only able to guess

#

Unless i can see your files

#

Try pastebin again

#

I am on my phone now

main olive
#

What files? The zshrc and zprofile and zshenv files ?

formal schooner
#

Yes

main olive
formal schooner
#

Why are you sourcing bash profile in zshrc

main olive
#

What directory is zprofile file in?

#

My bash profile is literally export PATH="/usr/local/bin/python3.8:${PATH}"

~
"~/.bash_profile" 1L, 47C

#

2 lines

formal schooner
#

I see

#

I don't see anything obvious in here

main olive
#

I need to send you my zprofile file too. What is its directory?

formal schooner
#

If you didnt create one, you dont have one

#

Same with zshenv

#

Do you get the same error every time with p10k? Or different errors

#

The repo owner simply had you reinstall p10k with that command

main olive
#

Before I "fixed"/reinstall it using the owner's command exec zsh -fc '{ rm -rf -- ~/powerlevel10k ~/.cache/p10k*(N); mv ~/.zshenv ~/.zshenv.bak; mv ~/.zprofile ~/.zprofile.bak } 2>/dev/null; git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k; exec zsh' during problem my zshrc was https://pastebin.com/aPdhwGpq

formal schooner
#

If the problem happens again

#

Go to the p10k dir on your computer

#

And run git diff

main olive
#

Do you get the same error every time with p10k? Or different errors
What do you mean? It was working just fine till day before yesterday and something made me get the errors ```Last login: on ttys001
/Users/useruser/.cache/p10k-instant-prompt-useruser.zsh:local:28: key: inconsistent type for assignment

_p9k_dump_instant_prompt:217: parse error near }' _p9k_dump_instant_prompt:zcompile:331: can't read file: /Users/useruser/.cache/p10k-instant-prompt-useruser.zsh _p9k_dump_state:53: parse error near )'
_p9k_dump_state:zcompile:23: can't read file: /Users/useruser/.cache/p10k-dump-useruser.zsh``` and once I reinstalled p10k using the repo owner instruction the error for now has gone

formal schooner
#

I think you accidentally edited a file in there

#

So if it happens again

#

Go to the p10k repo and run git diff

main olive
#

Ok, give me a sec

formal schooner
#

Does the problem happen now ?

main olive
#
❯ vim ~/.zprofile
❯ cd ~/powerlevel10k
❯ ls
LICENSE                powerlevel10k.zsh-theme
README.md            powerlevel10k.zsh-theme.zwc
config                powerlevel9k.zsh-theme
gitstatus            powerlevel9k.zsh-theme.zwc
internal            prompt_powerlevel10k_setup
powerlevel10k.png        prompt_powerlevel9k_setup
❯ git diff



#

I did this and when I ran git diff nothing happens

formal schooner
#

Do it only if the problem starts to happen again

main olive
#

What will that tell me?

formal schooner
#

It will tell you if something changed in those files

#

For now it seems to be fixed, so there's no way to diagnose what happened

main olive
#

Ok, thanks. Would it tell me what changed those files?

formal schooner
#

No

#

But if we can see what changed that can help

#

It might also be some program modifying the cache

#

Which is harder to find

#

Either way, if the problem doesn't happen again then don't worry about it

main olive
#

So out of the owners suggestion of what happened we have ruled out the first once since I don't have zshenv and zprofile?

Something on your machine has created either ~/.zshenv or ~/.zprofile with bad content.
Something on your machine has corrupted files in ~/powerlevel10k.
Something on your machine has corrupted files in ~/.cache.
#

I got zprofile.bak content ```

Setting PATH for Python 3.8

The original version is saved in .zprofile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

Your previous /Users/useruser/.zprofile file was backed up as /Users/userjaii

n/.zprofile.macports-saved_2020-06-23_at_20:51:27

MacPorts Installer addition on 2020-06-23_at_20:51:27: adding an appropriate PP

ATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

Finished adapting your PATH environment variable for use with MacPorts.

"~/.zprofile.bak" 14L, 544C

Setting PATH for Python 3.8

The original version is saved in .zprofile.pysave

PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

Your previous /Users/useruser/.zprofile file was backed up as /Users/useruser/.zprofile.macports-saved_2020-06-23_at_20:51:27

MacPorts Installer addition on 2020-06-23_at_20:51:27: adding an appropriate PATH variable for use with MacPorts.

export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

Finished adapting your PATH environment variable for use with MacPorts.

#

No zshenv or ~/.zshenv.bak but I have a zprofile.bak

#

Which zprofile was probably moved to my running exec zsh -fc '{ rm -rf -- ~/powerlevel10k ~/.cache/p10k*(N); mv ~/.zshenv ~/.zshenv.bak; mv ~/.zprofile ~/.zprofile.bak } 2>/dev/null; git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k; exec zsh'

#

@formal schooner

formal schooner
#

I see

#

I don't see a problem there either

#

It is the 2nd or 3rd option

main olive
#

So for now can we ~~~/.zshenv ~~or ~/.zprofile as the cause of problem?

#

= edit no zshenv file is there

formal schooner
#

Correct. I believe it was caused by corrupted files in ~/powerlevel10k or in ~/.cache

main olive
#
/Users/useruser/.cache/p10k-instant-prompt-useruser.zsh:local:28: key: inconsistent type for assignment

_p9k_dump_instant_prompt:217: parse error near `}'
_p9k_dump_instant_prompt:zcompile:331: can't read file: /Users/useruser/.cache/p10k-instant-prompt-useruser.zsh
_p9k_dump_state:53: parse error near `)'
_p9k_dump_state:zcompile:23: can't read file: /Users/useruser/.**cache**/p10k-dump-useruser.zsh```
#

This mentions cache

#

Why?

#

The cache is boldened by ** by me

formal schooner
#

p10k apparently puts files there

#

It probably pre-generates them to speed up the prompt

main olive
#

What do you think is more likely? something corrupted files in ~/powerlevel10k or ~/.cache ??

formal schooner
#

Cache

#

Very strange problem though

main olive
#

Then how did running what the owner sent me fixed it?

#

Didn't that just reinstall powerlevel10k?

formal schooner
#

Because the cache was probably regenerated by p10k

#

But that is a good point

#

Very hard to say

#

All i can say is, be careful running commands that automatically modify files for you

#

I dislike commands like that

main olive
#

All i can say is, be careful running commands that automatically modify files for you
@formal schooner Like what?

formal schooner
#

Conda init, for example

#

And it looks like macports did it too

main olive
#

But doesn't it kind of just add itself to the files, why would it mess up the file?

#

conda init or macports

formal schooner
#

I don't know, I never saw this happen

#

It is an unusual problem

#

I think you should just not worry about it

#

Put zprofile back

#

If the problem happens again, do the git diff

#

And @ me with the output

main olive
#

And since we have come to the conclusion that most probably cache was corrupted and not powerlevel10k since the cache was probably regenerated by p10k once I ran owners command, what generally corrupts cache?

formal schooner
#

Otherwise I don't think we can learn anything else

#

I have no idea

main olive
#

Put zprofile back
@formal schooner Why and by what command?

formal schooner
#

You ran mv ~/.zprofile ~/.zprofile.bak right? So move it back to its old name

main olive
#

So mv ~/.zprofile.bak to ~/.zprofile ?

formal schooner
#

Yes. It looks like macports has code in there

main olive
#

So running this might make the issue happen again and if so I have to run git diff?

formal schooner
#

I don't think zprofile caused the problem. I just want to make sure you don't break something else by removing a file you need.

#

But yes. If the problem happens again, do the git diff

main olive
#

I restarted terminal. Moving zprofile back from zprofile.bak to zprofile did not cause any issue at all

#

@formal schooner Also is it possible that my issue was a one of problem that maybe accidentally in vim I manually modified the file yesterday?

formal schooner
#

Yes

#

That was my first thought

main olive
#

Which file most likely I modified?

formal schooner
#

The one with the syntax error, in cache

#

Maybe a file in the p10k dir itself

main olive
#
/Users/useruser/.cache/p10k-instant-prompt-useruser.zsh:local:28: key: inconsistent type for assignment

_p9k_dump_instant_prompt:217: parse error near `}'
_p9k_dump_instant_prompt:zcompile:331: can't read file: /Users/useruser/.cache/p10k-instant-prompt-useruser.zsh
_p9k_dump_state:53: parse error near `)'
_p9k_dump_state:zcompile:23: can't read file: /Users/useruser/.**cache**/p10k-dump-useruser.zsh``` This file in cache /Users/useruser/.cache/p10k-instant-prompt-useruser.zsh   in cache?
#

Maybe a file in the p10k dir itself
@formal schooner Yes but didn't you say cache is more likely than something in p10k directory since more likely some program or me by mistake modified cache but except now I have never ever visited p10k directory

#

Right?

formal schooner
#

Programs are more likely to mess with cache than other directories

#

But both are unlikely and i am only able to speculate

#

It's more likely that you accidentally opened and edited a file

#

I don't have any idea what file

main olive
#

Programs are more likely to mess with cache than other directories
@formal schooner Yes, specially since macs are locked down well enough

#

Could it also be a one off thing that a program/software for the first and last time accidentally messed with my cache?

formal schooner
#

Maybe

main olive
#

Could it also be a one off thing that a program/software for the first and last time accidentally messed with my cache?
Likely?

#

@formal schooner

main olive
#

@formal schooner Do respond when you are done with . work. Thanks

tender plinth
#

Hello , I just installed irccloud from sudo snap install irccloud on my ubuntu 20.04 , the gui wasnt opening so I tried opening from /snap/bin/irccloud but it gives me segmentation fault

[1]    259646 segmentation fault (core dumped)  /snap/bin/irccloud```
any ideas on how to fix it would be appreciated , thank u
formal schooner
#

@main olive that's my guess, yeah. but really it's just a guess

main olive
#

So your guess is that it is likely that is was a one off thing that a program/software for the first and last time accidentally messed with my cache?

formal schooner
#

that, or you opened the file and accidentally edited in vim