Top Gun Coolmadness Whoopi Goldberg As Guinan's Eyebrows

User avatar
Muirium
µ

17 Jul 2014, 01:07

ENJOY YOUR MEAL

Image
Last edited by Muirium on 17 Jul 2014, 01:14, edited 1 time in total.

User avatar
Daniel Beardsmore

17 Jul 2014, 01:14

Reading this blog makes me feel like a lab rat who's figured out what's going on and escaped.

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 08:26

Daniel Beardsmore wrote: Reading this blog makes me feel like a lab rat who's figured out what's going on and escaped.
Discuss!

Speaking of, I was just thinking about the Rats of Nimh. Good story. I liked the books as a kid. I wonder if the writing will rate now. I wasn't too stoked when I re-read some Redwall books so I decided to keep them as good memories rather than re-read the entire series of what is practically the same story. I have a Redwall tattoo though and I'm probably gonna get another one.

:x

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 08:54

Hm, I've got a scripting question and I know there are some pretty sharp folks that deign to visit my Blog (I can't imagine why but hello chaps) so I won't burden our Fledgling (m'webwit) Club with an unnecessary thread. Unless this doesn't work out. Then I'm headin' out to Off-Topic,

I have this for loop I'm working on and it strikes me that the way I'm doing it is sort of clunky. At least, I know there are at least five ways I could do this more elegantly but I'm just not really sure what they are. Here's the do part:

Code: Select all

    do
#     make a working file from the target file
        cp "$f" "$f"_tmp
#     find and replace a variable
        sed 's/\_\@fg_color/$fgcolor/g' > "$f"_tmp
#     rename the working file to the target file
	mv $f_tmp $f
        sed 's/\_\@bg_color/$bgcolor/g' "$f"_tmp
	mv $f_tmp $f
        sed 's/\_\@link_color/$linkcolor/g' "$f"_tmp
	mv $f_tmp $f
        sed 's/\_\@disabled_color/$disabledcolor/g' "$f"_tmp
	mv $f_tmp $f
    done
frankly, copying to a temp file and then moving it back four times feels pretty disgusting. revolting? i'm perturbed.
my first idea is to figure out a way to run the sed all at once on a temp file and then move it back once all the work is done. that would save like four redundant cps but I'm not sure how to do that. nested loop? is that possible? god help me. or 7bot.

User avatar
Halvar

17 Jul 2014, 09:33

sed is nifty, I wish I could do more in it.

I'm not wholly getting what files you are trying to manipulate (does the script work in its current form?)
Anyway, whatever else you're doing there, you can put more than one command in one call of sed using {} :

Code: Select all

sed '{ 
      s/\_\@fg_color/$fgcolor/g 
      s/\_\@bg_color/$bgcolor/g
      s/\_\@link_color/$linkcolor/g
      s/\_\@disabled_color/$disabledcolor/g 
       }' "$f"_tmp

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 09:38

Halvar wrote: sed is nifty, I wish I could do more in it.

I'm not wholly getting what files you are trying to manipulate (does the script work in its current form?)
Anyway, whatever else you're doing there, you can put more than one command in one call of sed using {} :

Code: Select all

sed '{ 
      s/\_\@fg_color/$fgcolor/g 
      s/\_\@bg_color/$bgcolor/g
      s/\_\@link_color/$linkcolor/g
      s/\_\@disabled_color/$disabledcolor/g 
       }' "$f"_tmp
you sly dog. i had no idea you could do that with sed; that may be just what the doctor ordered. I'm still working on the script leading up to this point so I can't test it quite yet but I think that's on the right track. thanks man 8-)
basically this script is trawling through a set of predefined files and replacing a temporary placeholder with the contents of a variable that is set earlier in this script.

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 09:55

after a bit of research i'm not able to find any examples using curly braces, but it looks like sed has the -e flag to run multiple operations. i'll report back later if it works.

User avatar
7bit

17 Jul 2014, 10:12

@sth: Your script does not what you want it to do.
The most primitive way would have been to do it as a pipe, but Halvar's version is more elegant.

However, you can do it even shorter:

Code: Select all

      's/\_\@\(fg\|bg\|link\|disabled\)_color/$\1color/g'
:shock:

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 10:15

7bit wrote: @sth: You script does not what you want it to do.
The most primitive way would have been to do it as a pipe, but Halvar's version is more elegant.
here's what I have so far,

Code: Select all

for f in "$THEMES"
    do
        sed 's/\_\@fg_color/$fgcolor/g;s/\_\@bg_color/$bgcolor/g;s/\_\@link_color/$linkcolor/g;s/\_\@disabled_color/$disabledcolor/g' > "$f"_tmp
        mv "$f"_tmp "$f"
    done

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 10:22

Code: Select all

      's/\_\@\(fg\|bg\|link\|disabled\)_color/$\1color/g'
:shock:
now that's the kind of corn i'm trying to shuck here. after i get the basic functionality hammered out, the obfuscation begins 8-)

User avatar
7bit

17 Jul 2014, 11:03

I'm not 100% sure what you want to do, but it should be better this way:

Code: Select all

for f in "$THEMES"
  do
    sed -i 's/\_\@\(fg\|bg\|link\|disabled\)_color/$\1color/g' $f
  done

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 11:33

i've been doing this

Code: Select all

for f in "$THEMES"
    do
       sed 's/\_\@\(fg\|bg\|link\|disabled\)_color/$\1color/g' > "$f"_tmp
        mv "$f"_tmp "$f"
    done
because i didn't know you could actually edit the file with sed. I thought the point was to edit a text stream, but it would normally leave the input file intact and leave you to do something else with the stream when it's done.

i guess i can let on what i'm doing. basically this is a script that requests some hex values and then edits a bunch of config files to change some variables into those hex values. what i was doing was making the copy during/after the replacement, and then once the replacement is done, moving the copy back to its original name. that's the complete for loop up there; the rest of the script is probably not important to this particular portion.

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 11:35

holy clam cakes*. sed -i. look, i CAN read. and learn.

but for portability's sake, i still wonder if I should do it the olden way. gnu... we live with it, and it works fine enough for me, but some people feel more strongly about their environment.

edit= can't settle on an exclamation.

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 12:20

heck, you know what? this isn't for bsd users because they have no problem editing config files by hand anyways. or they better not :x :x :x :x

User avatar
Muirium
µ

17 Jul 2014, 12:48

Forum feature request: option to render code blocks as Emoji. Cause none o what you gentlemen been saying gone done make a single lick of sense to yours true. Might as well have been cat pictures to me. Good IDEs accept those nowadays, surely?

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 13:08

Muirium wrote: Forum feature request: option to render code blocks as Emoji. Cause none o what you gentlemen been saying gone done make a single lick of sense to yours true. Might as well have been cat pictures to me. Good IDEs accept those nowadays, surely?
given a capable parser there are a lot of ways you could substitute commands/operations for emojis :lol: and hark: https://github.com/wheresaddie/Emojinal

but i'm not even coding. this is just bash scripting. child's play. for children. i am a child. :x :x :x :x :x :x :x

User avatar
Halvar

17 Jul 2014, 13:41

Regular expressions are designed to be indistiguishable from magic for the uninitiated.

https://xkcd.com/208/

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 13:49

Halvar wrote: Regular expressions are designed to be indistiguishable from magic for the uninitiated.

https://xkcd.com/208/
one of my favorite parts of xkcd is having seen randall's attitude go from humorous insecurity to, like, pretty much the total opposite: http://xkcd.com/1053/

that strip really brightened my outlook!

User avatar
7bit

17 Jul 2014, 13:50

Here is the emoji-code:

:-) file :? filelist
-- :!:
---- :sad: ' :twisted: \_\@(fg :?: bg :?: link :?:disabled)_color :P $ :roll: 1color/ :idea: ' ;-) file
-- :cool:

User avatar
Muirium
µ

17 Jul 2014, 13:52

Sed, huh? I used awk once. To process star catalogues into xyz coordinates, which was pretty nice. I then rewrote my script to generate lists of the brightest stars visible from any given 3D point inside that model of our corner of the galaxy. And then five minutes went by and I forgot everything I learned about awk.

Programmer's mind: I don't have it!

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 16:52

the regex don' work. it don't properly 'spand the variable with $\1color. already done changed to single quotes. jus' don' like it i guess. what'n ends up hap'nin's that the sed machine replaces the text with the name of the dang variable, not it's ol' contents.

so'ns i get this type'a nonseense:

window.inactive.border.color: $bgcolor
menu.border.color: $bgcolor
window.active.client.color: $fgcolor
window.inactive.client.color: $bgcolor

i reckon the problem is the regex leadn' up to it. sed, you're a literal somebitch and a harsh mistriss.

User avatar
Muirium
µ

17 Jul 2014, 16:56

Ole Sed's just foolin' with ya, Sth. Gone get him some Dutch hospitality an he might well limber up to ya, all's I'm sayin'. 'N if it don't gone work by day's end, threaten him with a Bourne Again Shell between the eyebrows! Concentrates the mind, they say.

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 17:04

I brought him an ampersand, I think he might like it. Not sure 'bout the hospitality; probably don' take too kindly to a shove in the ribs and a face full of cigarette smoke. he DOES wear a lot of gel in his hair though.

User avatar
Halvar

17 Jul 2014, 17:51

Sed's dead baby. Sed's dead.

User avatar
BlueBär

17 Jul 2014, 17:53

Are you guys hackers? I'm scared! Please don't hack me ok?

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 18:01

now now, we're all deskthoritarians here.

User avatar
Muirium
µ

17 Jul 2014, 18:16

Hacker? Slacker! And I'm a gonna slack you, BlueBär! See that pickanick basket you got there? I'm a do that!

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 18:25

hell! i've been approaching this the wrong way. 7bit, your way is pretty but i don't think regex will save me there because i need the variables to expand at the same time sed is writing the substitution, and it doesn't, which makes sense because it's not his job to do that. i think i may have to settle for a slightly more redundant way of doing this until i can think of something novel.

User avatar
sth
2 girls 1 cuprubber

17 Jul 2014, 19:19

so's there anyone around that uses gtk and openbox? also, anyone who uses other window managers that have theme files using hex colors in the config file?

User avatar
scottc

17 Jul 2014, 21:59

Why not just use lxappearance? It's small, lightweight, very few dependencies, and easier than writing your own gtkrc.

Post Reply

Return to “Off-topic”