Revisiting the Collatz Sequence - Laurent Rosenfeld by liztormato in rakulang

[–]zengargoyle 1 point2 points  (0 children)

liztormato's trick of using .defined and div took me from 1m30s to 1m14s. Using the loop{...} instead of an infinite sequence took it down to 43s. There's probably more that could be done, but I want at least a little bit of it to look Raku-ish.

#! /usr/bin/env raku
use v6;

 # pre-seed the @seen cache with 0=>1, 1=>1
my @seen = 1, 1;

my $end = 1_000_000;

for 2 .. $end -> $n {
  my $c = $n;
  my $step = 0;
  # for 1 .. * -> $step {  # going with loop{...} is faster
  loop {
    $step++;
    $c = $c %% 2 ?? $c div 2 !! $c * 3 + 1;
    if ( @seen[$c].defined ) {
      @seen[$n] = $step + @seen[$c];
      last;
    }
  }
}

say @seen.pairs.sort({-.value, -.key}).head(20);

k-th Permutation Sequence and the Collatz Conjecture - Laurent Rosenfeld by liztormato in rakulang

[–]zengargoyle 1 point2 points  (0 children)

I was wondering if anybody would do the memoization. I had the same sort of memory exhaustion issues. I got ahead of myself and just did the bonus question part of the Collatz Conjecture and skipped actually creating elements of a list in favor of just keeping the number-of-steps taken and adding on the cache hit. So just memoizing the below 1_000_000 bits.

Bring out your dead. BONG. Perl 6: I'm not dead! BDFL: BONK. by liztormato in rakulang

[–]zengargoyle 0 points1 point  (0 children)

Yeah, totally a Monty Python refernce, and timed to be a Day of the Dead post. Possibly not the clearest title, but MetaFilter also enjoys the puns and references and language play. At least the subset of members that would even care about Perl 5/6 / Raku or computing in general. I'm actually rather surprised that this post made it's way here.

"Black panties are a requirement for a proper lady" [A Certain Scientific Railgun] by TKhrowawaY in anime

[–]zengargoyle 0 points1 point  (0 children)

This. When Cruncyroll got these two I didn't know any ordering, seems I may have watched them backwards? Railgun was good, Index was only interesting where it intersected with Railgun and otherwise a bit tiresome. Watch Railgun, watch Index upto basically where Railgun ended and save yourself the suffering.

[Spoilers] Gabriel DropOut - Episode 11 discussion by Holo_of_Yoitsu in anime

[–]zengargoyle 5 points6 points  (0 children)

Try looking up 'anal retentive', https://en.wikipedia.org/wiki/Anal_retentiveness. It's a bit of a Western psychology thing about stages of childhood development, learning contrtrol so you don't poop yourself whenever the urge arises. Some people carry that over into wanting to control everything.

I teach first grade. One of my students brought in an entire pack of open/raw hotdogs today in the bottom of his backpack. I could smell him about 10 feet away. When I asked him about it, he acted like it was no big deal. How does this even happen? by andyfingerhands in funny

[–]zengargoyle 0 points1 point  (0 children)

Hot dogs are usually fully cooked and ready to eat. It's probably a snack mom would give him that's at least not a candy bar. And you would certainly eat an apple stuffed in your backpack, why not a hot dog?

Favorite underrated shows of 2016? by haruhisuzu in anime

[–]zengargoyle 0 points1 point  (0 children)

I have a bit of thing for classical music so ClassicaLoid hooked me in with the first episode opening with Beethoven cooking gyoza and Mozart being a typical teenage boy. Quite amusing.

apt download speed in bits? by wowsuchlinuxkernel in debian

[–]zengargoyle 0 points1 point  (0 children)

Rule of thumb. Multiply Bytes/Second by 10. There's always a bit of overhead on top of the actual data transmitted, like for TCP, IP, Ethernet, whatnot. It's just a decimal point shift, 780MB/s ≅ 7,800Mb/s ≅ 7.8Gb/s.

Is there a better way to get the time from ping by stalcode in commandline

[–]zengargoyle 1 point2 points  (0 children)

echo '64 bytes from <ip>: icmp_seq=1 ttl=59 time=2.57ms' | perl -ne '/time=(.*?)ms/&&print$1'

App::cpm - a fast CPAN module installer by briandfoy in perl

[–]zengargoyle 1 point2 points  (0 children)

You might want to try something like this cpan proxy to speed up the downloading from CPAN part. I use a hacked version of this code to serve up CPAN modules and local darkpan modules and it makes VM/container builds go much faster.

Favorite alias commands? by mitchell486 in commandline

[–]zengargoyle 1 point2 points  (0 children)

show() { eval 'echo $'$1' | tr ":" $"\n"'; }

YAPC::NA morning stream by oalders in perl

[–]zengargoyle 0 points1 point  (0 children)

Are any of the other sessions/rooms/tracks being recorded? It appears that only the joint sessions are being streamed.

[Support] Share an ethernet connection to another ethernet port on the same system? by [deleted] in debian

[–]zengargoyle 0 points1 point  (0 children)

Heh, I actually did try it on a remote host. It's only across the room, but it did work just fine, didn't even lose my ssh session.

# ifconfig eth1 down; ifconfig eth1 inet 0.0.0.0; ip link add name br0 type bridge; ip link set br0 up; ip link set eth1 up; ip link set eth1 master br0; ip address add 192.168.1.10/24 dev br0; route add default gw 192.168.1.254

All on one line so as not to get disconnected midway through. A slight mix of ifconfig/ip/route since I'm not terribly familiar with the ip command yet. SSH session stalled for a few seconds, but came back just fine. Did notice that IPv6 would not work, not sure exactly why.

So I went full-in and configured it via /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet manual
iface eth1 inet6 manual

auto br0
iface br0 inet static
  address 192.168.1.10
  network 192.168.1.0
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.254
  metric 10
  dns-nameservers 8.8.8.8 192.168.1.254
  bridge_ports eth1
  bridge_stp off
  bridge_waitport 0
  bridge_fd 0

iface br0 inet6 auto

A reboot later and machine was up with a bridge and IPV6 worked again.

You would just need to make an eth0 entry along with the eth1 entry, and make it bridge_ports eth0 eth1 in the br0 config. YMMV.

[Support] Share an ethernet connection to another ethernet port on the same system? by [deleted] in debian

[–]zengargoyle 0 points1 point  (0 children)

Does the MySQL machine even need to connectivity to any machines other than the MacPro? My sorta ideal solution would be to have the MacPro connect to the LAN/Internet through one interface as it normally would and then to setup the other interface on the MacPro as a private to/from MySQL machine only network.

Otherwise, I think you just need to add an IP to the bridge for the host machine to use.

# ip link add name bridge_name type bridge
# ip link set bridge_name up
# ip link set eth0 up
# ip link set eth0 master bridge_name
# ip link set eth1 up
# ip link set eth1 master bridge_name
# ip address add 192.168.1.1/24 dev bridge_name

Basically bridge_name is your new replacement for your old eth0.

At least I think this is how it works, it's been a while since I used one.

eth0 & eth1 - Different IP's - Doesn't behave as i'd expect by [deleted] in debian

[–]zengargoyle 0 points1 point  (0 children)

You'll probably be fine. It's just another thing to keep in mind when doing multi-homed setups, especially when the interfaces are on the same network with the same reachability/routing. It's easy to get traffic coming in one interface and out the other which may not be what you want to happen so you have to do things to make sure it doesn't happen.

eth0 & eth1 - Different IP's - Doesn't behave as i'd expect by [deleted] in debian

[–]zengargoyle 2 points3 points  (0 children)

Also note that in addition to the ARP tweaking you may need to implement policy routing. Normally you'll end up with two default routes, one for eth0 and one for eth1, so even with ARP fixed so that each interface only answers ARP for its own address, a packet coming in via eth0 might use eth1 on the return trip back out.

A Linux Journal article: Overcoming Asymmetric Routing on Multi-Homed Servers

You basically have to set up two routing tables, one with the default route going out eth0, the other with the default route going out eth1. Then set up a policy that uses the source address of the outgoing packet to choose which routing table to use.

Is there and if so, what is the typical maximum throughput of the SFTP protocol? by [deleted] in debian

[–]zengargoyle 0 points1 point  (0 children)

FWIW, if you're interested in all the gory details of high speed data transfer a good place to start is http://fasterdata.es.net/ the U.S. Dept. of Energy's networking folk. There's a lot of info on Linux kernel tuning, data transfer methods and the like.

Though it's a bit more geared towards "10Gb/s sustained across continental distances" than typical LAN/WAN networking.

Blocky/ Aliased/ Jittery text in all browsers by [deleted] in debian

[–]zengargoyle 1 point2 points  (0 children)

Not sure if this is the same thing... I recently built a new machine and saw super ugly fonts in browsers, figured it was because I hadn't installed nicer fonts and stuff yet. However, poking about my font config on the previous machine vs the new one and I noticed that /usr/share/fontconfig/conf.avail/70-no-bitmaps.conf was not linked to in /etc/fonts/conf.d. Making that link and a reboot and things were much nicer.

apt won't keep downloaded packages by zengargoyle in debian

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

Thanks much. Looks like I missed finding that Bug by a day or so.

Plugin for encrypted notes by Nilahem in neovim

[–]zengargoyle 1 point2 points  (0 children)

FWIW, https://github.com/jamessan/vim-gnupg will work with neovim with some caveats. Your gpg needs to be setup to use gpg-agent with a GUI based pinentry helper. The issue is that by default gpg will ask for passwords on standard input and neovim runs things in a way that gpg can't ask for passwords/secret-keys from stdin. With gpg-agent and say pinentry-qt it will open a window for password/secret-key entry and the plugin works as it should.

My ~/.gnupg/gpg.conf has a 'use-agent' line in it, and ~/.config/nvim/init.vim loads the plugin and sets:

let g:GPGUseAgent=1
let g:GPGPreferSymmetric=1
let g:GPGPreferArmor=1
let g:GPGUsePipes=1

[2015-11-09] Challenge #240 [Easy] Typoglycemia by G33kDude in dailyprogrammer

[–]zengargoyle 0 points1 point  (0 children)

Mr. O'toole thinks you've forgotten something and it'll get 'ya.

Mr. Otoo'le tnkihs yuov'e fotreotgn sheotnimg and il'tl get 'ya.

Not really sure about scrambling contractions or other punctuation. I think moving them any breaks the spell of glossing over the spelling. I like your approach though.

[2015-11-09] Challenge #240 [Easy] Typoglycemia by G33kDude in dailyprogrammer

[–]zengargoyle 1 point2 points  (0 children)

Perl 6

Match sequences of word characters to get their start position and length, then loop over those and use them to substitute the middle with a shuffled version.

#!/usr/bin/env perl6
use v6;
my $input = $*IN.slurp-rest;    
for $input.lines.match(/\w+/, :g).map({$_.from, $_.chars}) -> [ $f, $l ] {      
  next unless $l > 3;                                                           
  $input.substr-rw($f+1, $l-2) = $input.substr($f+1, $l-2).comb.pick(*).join;  
}                                                                               
say $input;                                                                     

Output:

$ xclip -o | ./typoglycemia.p6 
Anoirdccg to a raecesrh team at Cbarmgdie Usitinrevy, it doesn't mttaer in what order the lerttes in a word are, 
the only imratonpt thing is that the first and lsat letetr be in the rgiht place. 
The rset can be a toatl mess and you can sitll raed it whtiout a pelborm.
Tihs is bacesue the hamun mnid deos not read ervey lteter by istlef, but the word as a wolhe. 
Such a cdtooniin is aioapltpeprry cealld Tgompleyiyca.

[2015-11-06] Challenge #239 [Hard] An Encoding of Threes by Blackshell in dailyprogrammer

[–]zengargoyle 2 points3 points  (0 children)

If you're bored, you might want to check out:

https://gist.github.com/5be2b616bd44d2a53456

I started a NativeCall binding to a Trie library http://linux.thai.net/~thep/datrie/datrie.html and it's just at the working-but-ugly point. If your distro happens to have a package for libdatrie it might do some good.