mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   jvang (https://www.mersenneforum.org/forumdisplay.php?f=153)
-   -   ¿Learning how to learn… (https://www.mersenneforum.org/showthread.php?t=23429)

Xyzzy 2018-08-24 13:25

[QUOTE=jvang;494555]Is there a way to easily see my aliases that have already been set?[/QUOTE]Are you using [C].bashrc[/C] to store them? If so, [C]grep alias .bashrc[/C] should work.

:mike:

paulunderwood 2018-08-24 13:31

[QUOTE=Xyzzy;494578]Are you using [C].bashrc[/C] to store them? If so, [C]grep alias .bashrc[/C] should work.

:mike:[/QUOTE]

Just [c]alias[/c] works for me. :smile:

Xyzzy 2018-08-24 13:32

We learn something new every day!

:mike:

jvang 2018-08-24 23:28

[QUOTE=paulunderwood;494579]Just [c]alias[/c] works for me. :smile:[/QUOTE]

Oh, I guess it's that simple :max:

For one of my online concurrent classes (Intro to Computer Coding, maybe?) we were supposed to do a little section on cryptography. It wanted us to use a little sheet for a cipher that basically moved a letter forwards in the alphabet by a number of steps equal to its index (plus 1). Since there wasn't much else to do in the class, I coded some Haskell for it, using [C]ord[/C] and [C]chr[/C] instead of repeated [C]succ[/C]s:

[CODE]import Data.List
import Data.Char
import Data.Maybe
ciph xs = map (\x -> chr (ord x + (fromJust (elemIndex x xs) + 1))) xs
ciph xs = map (\x -> chr . (+1) . ord x . fromJust . elemIndex x xs) xs
[C]-- I tried to do a pointfree version on the last line but it won't run; something to do with types :([/C][/CODE]

This doesn't handle wrapping from z to a; I was too lazy to copypaste that from a kata I did a while back. But that wouldn't have helped much anyways, since the encoding/decoding process was described incorrectly; I tried running the test string forwards and backwards and everything was gibberish. Eventually I guessed based on the length of the string and ended up correct, but it was a very poor question and example of cryptography.

jvang 2018-08-25 16:39

[URL="https://www.codewars.com/kata/least-common-multiple/"]Least common multiple[/URL] was a nice kata. It reminded me that I never learned how to calculate LCM properly. At first I was trying to do some really complicated thing where I checked if any element of the input was a multiple of the others, then removed them and took the product of it. It was very convoluted and didn't work very well; after learning about the right way to take the LCM of two numbers I ended up with this:

[CODE]module LeastCommonMultiple where
import Prelude hiding (lcm)
import Data.List (foldl1')
lcm :: Integral a => [a] -> a
lcm xs = if any (==0) xs then 0 else foldl1' newLCM xs
newLCM x y = x * (div y (gcd x y))[/CODE]

I'm reading the [URL="https://en.wikipedia.org/wiki/Virtual_memory"]Wikipedia page on virtual memory[/URL] to try and figure out how it works. From what I can figure out, it has to do with swap space on the hard drive and paging.

It seems that each process has its own address in the computer's RAM, which is managed by the MMU. By creating and translating between real addresses and virtual addresses (stored in the swap space?), the computer is able to utilize part of the hard drive and use more RAM than is available... is that how that works?

chalsall 2018-08-25 17:14

[QUOTE=henryzz;494362][url]https://www.howtogeek.com/howto/33552/htg-explains-which-linux-file-system-should-you-choose/[/url] is a fairly good description.[/QUOTE]

And when you're ready for the next level of storage excellence, wrapping your head around deploying [URL="https://en.wikipedia.org/wiki/RAID"]Redundant Array of Independent Disks (RAID)[/URL] is very valuable.

RAID sits beneath whatever file system(s) you choose to use, and is invaluable for production systems.

jvang 2018-08-28 00:25

[QUOTE=chalsall;494686]And when you're ready for the next level of storage excellence, wrapping your head around deploying [URL="https://en.wikipedia.org/wiki/RAID"]Redundant Array of Independent Disks (RAID)[/URL] is very valuable.

RAID sits beneath whatever file system(s) you choose to use, and is invaluable for production systems.[/QUOTE]

I think I'll avoid trying to figure that out for now; I need to learn more about the underlying technology that supports that :unsure:

More Haskell: [URL="https://www.codewars.com/kata/ready-for-prime-time/"](Ready for) Prime Time[/URL]. I reused the primality test from an earlier kata, applied it to all numbers between 1 and the input, then filtered out the Falses (I used 0 instead of a False value because /= wanted an Int type). It's probably really inefficient, but I wasn't sure how to make an infinite list of primes and take the first n elements...

[CODE]module PrimeTime where
prime :: Int -> [Int]
prime n = if n < 2 then [] else filter (/=0) [if isPrime x then x else 0 | x <- [2..n]]
isPrime x = if x < 2 then False else if any (== 0) [mod x n | n <- [2..(floor (sqrt (fromIntegral x)))]] then False else True[/CODE]

Learned a bit about [C]dmesg[/C] for Linux today. My dad uses it a lot to see where a USB drive is mounted, or for similar purposes since the buffer prints in chronological order. There are a lot of options but none of them seem usable in ordinary circumstances. I'd assume that if you needed specific information you could pipe [C]dmesg[/C] through [C]grep[/C] to return only the relevant lines.

jvang 2018-08-29 00:35

There's a surprising amount of documentation on something as simple as the message of the day.

After a successful login, but before executing the login shell, the contents of [C]/etc/motd[/C] are displayed. [C]pam_motd[/C] (which retrieves and prints it) is surprisingly versatile, and you can make an motd that updates based on changing information, such as the output from the NOAA/NWS weather utility. I heard that there was a recent controversy where Ubuntu servers were showing advertisements in the motd :ermm:

chalsall 2018-08-29 00:56

[QUOTE=jvang;494826]There's a surprising amount of documentation on something as simple as the message of the day.[/QUOTE]

As root, "tail -f /var/log/messages" can be really quite informative.

jvang 2018-08-31 01:13

[QUOTE=chalsall;494829]As root, "tail -f /var/log/messages" can be really quite informative.[/QUOTE]

[URL="https://help.ubuntu.com/community/LinuxLogFiles"]This wiki page[/URL] is pretty informative too. It's neat that just about everything of importance that occurs is recorded. I'd assume that you can view [C]/var/log/dmesg[/C] manually, but it would just be a long version of [C]dmesg[/C]. And a lot of applications/programs have log files in [C]/var/log/[/C], which seems useful.

jvang 2018-09-01 00:04

My dad shared some more info with me on [C]/var/log/[/C]. I noticed that some files had the same filenames as others, but with a number on the end. These are older log files; the computer rotates through files to keep from making any of them too large. The older ones are compressed, and have [C].gz[/C] in addition to the number. A way to read them is to use [C]zcat[/C], which decompresses the file before printing it.

Edit: The rotation of the log files is controlled by [C]logrotate[/C]. As usual, there's a lot of documentation on it; the manpage on it is several pages long! There's a bunch of parameters for its configuration file too, such as what to do when rotating, when to rotate, how many rotations to keep after the most recent, the cutoff filesize for a forced rotation, etc.


All times are UTC. The time now is 21:53.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.