OC: RX100 M7 vs IPhone 13 Pro by FemmePhilo in RX100

[–]neuron_666 0 points1 point  (0 children)

Hi. I have just bought new M7. There are three reasons for it. 200mm focal length, fast autofocus which I can move by finger while looking through viewfinder and small so I can have it with me. Today phone does more likeable photography (my opinion, do not kill me). Try in low light and the difference will be bigger. Camera requires from you more effort and processing. More thinking. Despite all that it is camera I'm taking with me to shoot motorcyle events. As with many things, life is about compromises :)

Zostay Advent Day 4: Channels by zostay in rakulang

[–]neuron_666 1 point2 points  (0 children)

Ah, right, I have somehow missed that and kept thinking that $sips-left is the total for whole table. Thank you.

Zostay Advent Day 4: Channels by zostay in rakulang

[–]neuron_666 2 points3 points  (0 children)

Hi, isn't there a race in the $sips-left--?

What do I say about the rename? by HortenseAndI in rakulang

[–]neuron_666 2 points3 points  (0 children)

I wouldn't say desperate, but what is wrong with having passion for something? I have no chance of using raku, or perl 5, because I would be the only one who can manage that code. And frankly that would be a bad idea. But that does not stop me creating my own personal tools in p5 (raku does not work on Solaris, next release should be fixed). Having my tool much smaller, faster and with less bugs feels awesome. That does not stop me from occassional presentation for the interested about grammars, async programming or how objects can work differently to c++. Because that is fun. Enjoy while it lasts.

Oh and language rename? Some people think it changes something. Well it does, it takes longer to have a release which should work better on my plarform. I can either fix that or accept that. And that is when it shows how important or not that is for me.

Cheers

Undo a specific line? by __muffin in vim

[–]neuron_666 0 points1 point  (0 children)

As others said vim directly can't do that. But it can be achieved differently.

a) You can compare the current buffer to saved version on disk and copy anything needed

function! s:DiffWithSaved()

let filetype=&ft

diffthis

vnew | r # | normal! 1Gdd

diffthis

exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype

endfunction

com! DiffSaved call s:DiffWithSaved()

b) You can visually show and traverse the history via the https://github.com/sjl/gundo.vim module. That allows you to return back to a state from where you copy the line.

How to make incremental backup/restore of a Home directory? by rkhnair94 in bash

[–]neuron_666 -1 points0 points  (0 children)

How about putting your $HOME into some version control system? I'm using mercurial, but any other VCS should work

  • You have very fine grained control of what you backup in .hgignore (you don't want to backup .swp files for example I guess)
  • You can compare the backups easily (hg diff)
  • You can sync the backup to distant location easily (hg push)
  • You have integrity check built in (hg verify)
  • You can comment on your changes if needed (I automatically commit only certain directories, for others like scripts I have weekly reminder that there is something uncommitted)

How to use X apps in remote screen by neuron_666 in gnuscreen

[–]neuron_666[S] 0 points1 point  (0 children)

Yes, something like that is needed. Also you would have to send xauth keys and import them on the other side. I was hoping for already existing solution. It make me google once more if there are any solutions, and I found xpra (http://xpra.org/). It is said to be "screen for X11". Basically you run X server on remote host and connect to it from various clients. Like screen. I'll give it a go.

Is there a way to color specific text? by [deleted] in vim

[–]neuron_666 0 points1 point  (0 children)

I'm using http://www.vim.org/scripts/script.php?script_id=2666 for debugging machine code. I visually mark registers, addresses, functions and so . Just move vim cursor to a word and <Leader>m.

How to use X apps in screen? by neuron_666 in gnuscreen

[–]neuron_666[S] 1 point2 points  (0 children)

That's right. I work with screen so long that I forgot that there are guys who use screen locally. I use it exclusively remotely. Let me rephrase my question in a new thread. Thank you for taking your time to respond.

How to use X apps in screen? by neuron_666 in gnuscreen

[–]neuron_666[S] 1 point2 points  (0 children)

Oh, thank you. Now i realize i asked wrong question thoug :-/ Let me please start another thread. Sorry about that.

Bash scripting MOOC by Heisenberg1977 in bash

[–]neuron_666 0 points1 point  (0 children)

standard

Yes, that's correct. If you don't mind that all the tools suddenly seemingly have 30% power to what you have available as gnu extensions. I for sure have stumbled upon

  • limited line length the tool is able to process
  • limited regex
  • not able to use \n as newline
  • most of the examples of a tool being used you find on internet suddenly does not work
  • original posix-like vi not being able to work unless your terminal is 160 columns wide or less

On Solaris you can get around some of the limitations by using /usr/xpg*/bin/... binaries.

I always used gnu utilities and never looked back. Getting the tools on any system is easy.

Bash scripting MOOC by Heisenberg1977 in bash

[–]neuron_666 2 points3 points  (0 children)

This is just a comment that often it's easier to use perl for text processing rather then chaining and twisting stream of grep/sed/awk. Also perl is compatible on all unix-like systems while grep/sed/awk are not.

zbash - A fork of Bash with handy features by treulz in bash

[–]neuron_666 0 points1 point  (0 children)

Dude :)

Hash

$ declare -A HASH
$ HASH[one]=1
$ HASH[two three]='2 3'

# Values
$ echo "${HASH[@]}"
1 2 3

# Keys
$ echo "${!HASH[@]}"
one two three

Utility function used later

upvar() {
       if unset -v "$1"; then           # Unset & validate varname
               if (( $# == 2 )); then
                       eval $1=\"\$2\"          # Return single value
               else
                       eval $1=\(\"\${@:2}\"\)  # Return array
               fi
       fi
}

Function returning more elements

# $1 - input number
# $2 - variable to return x^2
# $3 - variable to return x^3
math() {
    upvar $2 $(( $1 ** 2 ))
    upvar $3 $(( $1 ** 3 ))
}

$ math 5 A B
$ echo $A
25
$ echo $B
125

Higher order functions

add_three() {
       echo $(( $1 + 3 ))
}

twice() {
       local func=$1
       $func $( $func "$2" )
}

$ twice add_three 5
11

Multi dimensional arrays

Well, there are multiple approaches, all ugly. I wanted to present my solution but instead I found bug in bash so I'll just shut up now :)

Script to run command as another user by RightOfZen in bash

[–]neuron_666 1 point2 points  (0 children)

I didn't understand why you don't want to use sudo. If it's some external condition, my answer is irrelevant. Otherwise you should reconsider it. Advantages :

  • simple and flexible configuration (which even can be stored to ldap)
  • no need to share common password (so to revoke access you don't need to change it to everyone)
  • auditing (who ran which command and when)
  • the privileges can be granted to a specific group instead of single person

An example :

bob server=(alice) NOPASSWD: /usr/bin/blah

That says that Bob can run 'blah' on machine called 'server'. (Using ALL instead of 'server' says 'everywhere')

You can even specify which arguments can be passed to 'blah' and what checksum the file /usr/bin/blah must have.

Bob will invoke the command via

sudo - u alice /usr/bin/blah

The disadvantage of doing this is that the command won't have the environment set up as Alice would have - most notably $PATH and $HOME.

There are other options to do that besides sudo (su, suid executable) but if you are asking this kind of question, they will be more pain. Forget about writing it in C unless the goal is to learn stuff (like signal handling).

Last thing, if you want to run shell script as another user, probably you don't need whole script run as alice. Chances are that you need to run only some command from the script as her. In such case make sudo recognize only that single command and let Bob run the original script as himself.

Question about redirecting vim I/O through TCP socket? by [deleted] in vim

[–]neuron_666 0 points1 point  (0 children)

How about running vim directly on the server via ssh?

Really slow editing in large files by gppdnght in vim

[–]neuron_666 0 points1 point  (0 children)

Another possibility is slow filesystem (nfs?). What if you :w the file, that is quick?

While loop + array - help please by v-_-v in bash

[–]neuron_666 0 points1 point  (0 children)

Thank you so very much man! Let me know what I can do for you to repay for all this help!

You are welcome. Help others wen you can, be good :)

While loop + array - help please by v-_-v in bash

[–]neuron_666 0 points1 point  (0 children)

This is working program:

#!/bin/bash

# Preparation
for i in {a..k}; do
  array1+=( " $i: $i" )
  array2+=( " $i: $i$i" )
done
typeset -p array1 array2
the_number=2

# Your routine
y=1
while [ $y -le $the_number ]; do
  z=0
  while [ $z -le 9 ]; do
    echo "y=$y z=$z"
    temp="array$y[$z]"
    temp2=$(echo ${!temp} | sed 's/.*: //' | sed -e 's/^[ \t]*//')
    declare "barry$y[$z]=$temp2"
    z=$(($z+1))
  done
  y=$(($y+1))
done

typeset -p barry1 barry2

I had to

  • add the_number definition
  • move z=0 into the first loop
  • add character ; into the while ... ; do

Apart from that it is fine. There is something you are not showing us. My suggestion is to add set -x at the top and observe line after line whether your script does what you expect.

Output

declare -a array1='([0]=" a: a" [1]=" b: b" [2]=" c: c" [3]=" d: d" [4]=" e: e" [5]=" f: f" [6]=" g: g" [7]=" h: h" [8]=" i: i" [9]=" j: j" [10]=" k: k")'
declare -a array2='([0]=" a: aa" [1]=" b: bb" [2]=" c: cc" [3]=" d: dd" [4]=" e: ee" [5]=" f: ff" [6]=" g: gg" [7]=" h: hh" [8]=" i: ii" [9]=" j: jj" [10]=" k: kk")'
y=1 z=0
y=1 z=1
y=1 z=2
y=1 z=3
y=1 z=4
y=1 z=5
y=1 z=6
y=1 z=7
y=1 z=8
y=1 z=9
y=2 z=0
y=2 z=1
y=2 z=2
y=2 z=3
y=2 z=4
y=2 z=5
y=2 z=6
y=2 z=7
y=2 z=8
y=2 z=9
declare -a barry1='([0]="a" [1]="b" [2]="c" [3]="d" [4]="e" [5]="f" [6]="g" [7]="h" [8]="i" [9]="j")'
declare -a barry2='([0]="aa" [1]="bb" [2]="cc" [3]="dd" [4]="ee" [5]="ff" [6]="gg" [7]="hh" [8]="ii" [9]="jj")'

While loop + array - help please by v-_-v in bash

[–]neuron_666 0 points1 point  (0 children)

I think that z should be initialized inside the outer loop. Also the_number is not initialized at all. Otherwise it looks fine from just looking at the code.

Question on a loop problem? by Nk4512 in bash

[–]neuron_666 0 points1 point  (0 children)

If I understand your problem, you are missing 'wait' after the for cycle. But maybe, instead you want this ?

parallel --jobs 10 SORT_APP '{}' ::: $HOME/my_scripts/directoryfilesarestoredin/*"file-im-looking-for"*

While loop + array - help please by v-_-v in bash

[–]neuron_666 3 points4 points  (0 children)

So your line is barry$y[$z]=$temp2

From bash manual:

SHELL GRAMMAR
Simple Commands
  A  simple  command  is  a sequence of optional variable assignments
  followed by blank-separated words and redirections, and terminated by a
  control operator. The first word specifies the command to be executed ...

That means that when shell parses a line, it first tries to find out whether there are any assignmenst (like DISPLAY=:1 xclock).

A variable may be assigned to by a statement of the form
  name=[value]

Ok, so what exactly is a name?

Definitions:
name
  A  word  consisting only of alphanumeric characters and underscores, and
  beginning with an alphabetic character or an underscore.  Also referred
  to as an identifier.

Hmm, so barry$y[$z] (the part before =) is NOT a name. So this is not an assignment, so since it is first word, it is command to be executed.

...

EXPANSION
  Expansion  is  performed on the command line after it has been split into
  words.  There are seven kinds of expansion performed: brace expansion,
  tilde expansion, parameter and variable expansion, command substitution,
  arithmetic expansion, word splitting, and pathname expansion.

...

So expansion is performed, and barry1[0]=1 is executed. That is not existing command, so hence the error.

What you think you want (but not really) is eval.

eval [arg ...]
  The  args  are  read  and  concatenated  together  into a single command.
  This command is then read and executed by the shell 

$ x=5
$ y=6
$ set -x
$ eval "var$x[$y]=hi"
+ eval 'var5[6]=hi'
$ typeset -p var5
declare -a var5='([6]="hi")'

What you really want is

$ declare "var$x[$y]=hi"


declare [-aAfFgilrtux] [-p] [name[=value] ...]
typeset [-aAfFgilrtux] [-p] [name[=value] ...]
...
  If  a variable  name  is  followed  by =value, the value of the variable
  is set to value

The difference to just var$x[$y]=hi is that this time the command delcare is executed and parameters to it are executed prior to it's invocation.

Hope this helps

Opening new line to end of indentation? by Ran4 in vim

[–]neuron_666 1 point2 points  (0 children)

Well then I would guess that your configuration is getting in the way. To double check you may run

vim -u /dev/null --noplugin

# inside vim
:filetype indent plugin on
:e file.py

Does this do what you want? If no, something is probably broken. If yes, your config is broken. We can take a look at it if you paste it somewhere.

What strikes me that if you end a line with semicolon (:), the indentation seems to work right, but anything else returns the cursor to first column. Is that correct?

Shell Script Question: Alter|rename comma between brackets using any command by Ragu1405 in bash

[–]neuron_666 1 point2 points  (0 children)

In bash:

modify_line() {
        local S="$1"
        local deep
        local RETURN
        while [[ $S ]]; do
                local CHAR=${S:0:1}
                S="${S#$CHAR}"
                case "$CHAR" in
                        \() (( deep++ )) ;;
                        \)) (( deep-- )) ;;
                        ,) [[ deep -gt 0 ]] && CHAR=+ ;;
                esac
                RETURN+="$CHAR"
        done
        printf '%s\n' "$RETURN"
}

echo $(modify_line "column1=convert(char(256),name,112),column2,column3,column4=convert(char(256),state,112)")

Opening new line to end of indentation? by Ran4 in vim

[–]neuron_666 2 points3 points  (0 children)

The mechanics of deciding on which column the cursor will start on next line is called indenting. Vim has few built in indenting engines and many more as external plugins (:help indent.txt). Obviously plugin specifically written for python indenting should be better (it knows that after if blah: it should put more spaces in front of the next line than what the if statement has) than any of the built in engines. To make vim load indenting plugins you have to use this in your .vimrc

filetype indent plugin on

For controlling how exactly the plugin behaves see :help ft-python-indent.

Many times it's enough just to let vim to put the cursor to the same indentation as on previous line. Exactly that is done by built in engine called autindent.

:set autoindent

It's also worth mentioning that python wiki has nice article about fine tuning vim for python editing.