Suicide Linux
qntm.org
qntm.org
function promptCommand()
{
LAST_STATUS=$?
# Set title of window to dir, then add new line to prompt.
PS1='\[\e]0;\w\a\]\n'
if [ $LAST_STATUS -eq 0 ]; then
((successes++))
PS1+='\[\033[1;32m\][$successes]'
else
successes=0
PS1+='\[\033[1;31m\][0 $LAST_STATUS]'
fi
PS1+='\[\033[0;32m\] '
PS1+='\w $(date +%H:%M) \$ \[\033[0m\]'
}
lastStatus=0
successes=-1
PROMPT_COMMAND="promptCommand"
My prompt: [0] /home/bar/g3 14:19 $ echo "boo"
boo
[1] /home/bar/g3 14:19 $ echo foo | grep bar | cat
is successful. Of course, this works for any command. echo foo | grep bar || true echo foo | grep bar || :In the former, if a result can't be found it will return `nil` but in the latter it expects the record to exist and so will raise an exception if it can't be found.
IMO returning nil instead of an exception for the above is practical for me. Much easier to work with.
Having `find(4)` raising an exception is because you'll typical use it in your member actions for a controller where it's reasonable to want an exception if something can't be found.
It's just Rails being Rails (practical sometimes at the expense of possible interpretation of correctness). You do have to retain stuff like this in your head, but it becomes habit pretty quickly.
I've have found `find_by!` useful though. Say you want to raise an exception with `find_by!(email: "asd@asd.com")` or `find_by!(slug: "parameterized-string")` etc.
Not to mention tar which is just impossible to get right on the first try.
Somehow related, a coworker at a previous place unmounted some disks on an old AIX production box. It took him a solid minute to realise he had mistakenly unmounted / due to a typo (yes it was possible) as old processes with already opened files were happily serving stuff and only new attempts at opening files were beginning to produce errors.
Also, a similar interactive mishap in the heat of the action:
somebox:~$ rm * .o
rm: .o: No such file or directory
somebox:~$ # ...
somebox:~$ # *stares a prompt*
somebox:~$ # Wait, what? _Please_ tell me those C files were versioned! (The answer was, obviously, "no")rm *>o <-- kept shift held down while he pressed period
Been using "make clean" ever since.
So then I typed:
$ shred -n1 -v /dev/sda
Took me about 4 seconds to realize what I did before hitting Ctrl-C.
Then, I sighed. Considered whether I could save anything. Realized there wasn't anything on there worth saving, and reinstalled. :)
I'm usually much more cautious than that and I'm thankful it happened on a dumb test machine at home and not something important, but it was still a bummer and my first real sysadmin-type screw up. Mistakes happen, though. Even Linus once dialed his hard drive [0].
As luck would have it, I had the output of fdisk -l /dev/sda in my terminal scrollback buffer and was able to recreate the partition table with no damage done.
I work at a technological youth centre, teaching kids cool things to do with computers, programming, music and whatnot. All the hardware we get is donated from businesses, schools, etc. (because volunteers / zero-budget).
And this is just ... ahh. I usually cope by trying not to notice and focus on the screen instead. Sometimes though the ick overwhelms and I fail, curse and go on a hunt for a slightly less gross keyboard. And wash my hands after--though I kind of wonder if that even really makes a difference in this particular scenario (except for the idea of it), afaik the main benefit of washing your hands (in these situations, not if you're a surgeon or a cook etc) is some kind of herd-immunity deal isn't it? And given the keyboards stay dirty, and the kids continue to work on them hands-to-keyboard-to-nose-to-mouse-to-mouth-to-keyboard-to-everything-repeat (esp. the younger ones).
You know what would be really nice? Dishwasher-safe keyboards.
And yeah (before anyone replies with a link), I'm sure those exist already. Except that many of the places that need them don't budget for new (or specialty) keyboards but rely on donated used ones. But it would be really nice to have :) :)
Alternative keyboards weren't an option in those Sun 3 days, but I've brought my own chair, keyboard, and mouse to work for decades now.
Luckily I was able to recover its contents, while hoping not to lose the network connection during the process.
That was possibly the best unix/linux learning experience of my life. Rebuilding /etc sufficient to rescue my files I cared about before a reinstall. Rescue CDs weren't really a thing, USB was a new thing at the time, and I was on dial-up.
Another fun one: "killall" on Linux kills processes with names matching a string. "killall" on Solaris reboots the machine ...
(Hilarious and unnerving)
One should NEVER do anything non-scripted on a production system. ALWAYS enter it into a file and then do the "run-sql-from-a-file" command.
EDIT: Yes, I also realize that "rm -rf /" can theoretically happen if you have a bad variable substitution, but you MUST turn on the flags that cause your shell to error out instead of just substituting the empty string.
It's really about NOT getting into the habit of "just fix it in production". That way lies madness.
Try adding “echo “ in front of the rm command line to see how it expands. (That, by the way, is often a good idea.)
If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.
Source: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm...
What? No, what's that about?
From TFA:
"Update 2015-04-18 -- I suppose I should finally clear this up: The autocorrect functionality I originally described here was a feature of the first Linux systems I ever used, so I assumed it was how every Linux system worked by default. Since then I've come to understand that it's a completely optional extra doodad."
It would make a good prank to set up on someone that left their machine unlocked. Not sure if it’s more funny than changing their background to goatse.
I have my priorities.
gt git status ga git add gdd git diff to develop gdn same but name in only
also
`gitv` = git diff
`gitvc` = git diff --cached
git status -> gs
git add -> ga
git commit -> gc
...
[0]: https://github.com/scmbreeze/scm_breeze alias add='git add'
alias st='git status'
alias ci='git commit'
alias br='git branch'
alias di='git diff' ~ $ abbr | grep git | sort
abbr af 'git kit autofixup'
abbr amend 'git commit --amend'
abbr fixup 'git commit --fixup'
abbr gb 'git branch'
abbr gcan 'git commit --amend --no-edit'
abbr gcm 'git commit -m'
abbr gco 'git checkout'
abbr gcop 'git checkout -p'
abbr gfa 'git fetch --all -p'
abbr gkdm 'git kit del_merged'
abbr gl 'git log --oneline --color --decorate -n20 --graph'
abbr gp 'git pull --ff-only --all -p'
abbr gph 'git push -u origin HEAD'
abbr gre 'git rebase'
abbr grec 'git rebase --continue'
abbr grem 'git rebase -i master'
abbr greom 'git rebase -i origin/master'
abbr greum 'git rebase -i upstream/master'
abbr gs 'git status'
abbr gxa 'gitx --all'
abbr namend 'git commit --amend --no-edit' [alias]
co = checkout
psuh = push
s = status
l = log
d = diff
And then alias g=git in your shell configuration. "g s", "g l", etc. But nowadays I just use magit.I was in a sys admin class with a friend of mine and we both had access to the same machine to work on our assignments. I aliased each and every common command to `sl -f` on my friend's user as a prank (he never actually logged in as it turns out). However, my instructor, while projecting his screen to 150+ students (and recording) picked our box and my friend's user to use as an example. My instructor was flabbergasted for a few minutes and the class got a kick out of flying trains. :D
$ ls -F
dammit!
$ sl -F
So I guess it's corrected my typos already :)
=========================================================
WARNING: Suicide Linx installed
(http://sourceforge.net/projects/suicide-linux/)
=========================================================
I'm wondering if the typo is a subtle joke.Edit: The video in question: https://www.youtube.com/watch?v=Q_pgnMWgd34
:-)