McCarthyism is alive and well on the liberal left

…individuals with aggressive, rule-breaking and anti-social tendencies…are over-represented among benefit recipients. 

Share

Princeton Study - U.S. No Longer An Actual Democracy

American democracy no longer exists. I think the average American is aware of this - hence the popularity of Donald Trump. Throw the bums out!

Share

No parking here

Share

Euler-98

https://projecteuler.net/problem=98

By replacing each of the letters in the word CARE with 1, 2, 9, and 6 respectively, we form a square number: 1296 = 36^2. What is remarkable is that, by using the same digital substitutions, the anagram, RACE, also forms a square number: 9216 = 96^2. We shall call CARE (and RACE) a square anagram word pair and specify further that leading zeroes are not permitted, neither may a different letter have the same digital value as another letter.

Using words.txt, a 16K text file containing nearly two-thousand common English words, find all the square anagram word pairs (a palindromic word is NOT considered to be an anagram of itself).

What is the largest square number formed by any member of such a pair?

NOTE: All anagrams formed must be contained in the given text file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

rm(list=ls(all=TRUE))
#I want all large integers manipulated without scientific notation
options( scipen = 20 ) ##don't use scientific notation
options(digits=22)

words <- scan( file= paste(getwd(),"p098_words.txt", sep="/"), what="list", sep=",",skip=0, quote="\"")


> words <- scan( file= paste(getwd(),"p098_words.txt", sep="/"), what="list", sep=",",skip=0, quote="\"")
Read 1786 items
>
> counts <- nchar(words)
> max.counts <- max(counts)
> max.counts
[1] 14
>
> min.counts <- min(counts)
> min.counts
[1] 1
>
> words.len <- length(words)
>
> d <- data.frame(counts, words)
> head(d)
counts words
1 1 A
2 7 ABILITY
3 4 ABLE
4 5 ABOUT
5 5 ABOVE
6 7 ABSENCE
> tail(d)
counts words
1781 3 YET
1782 3 YOU
1783 5 YOUNG
1784 4 YOUR
1785 8 YOURSELF
1786 5 YOUTH
>

There are 1786 words, the longest is 14 characters and the smallest is 1 character. Since we have already been given the square anagram word pair CARE / RACE I will assume the answer is greater than 4 characters and ignore all 1-4 character words.

Write a function compare.word that will take 2 words, sort the characters and determine if the two words have the same characters.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
> compare.word <- function( a, b){
+ aa <-sort(strsplit (a,"")[[1]])
+ bb <-sort(strsplit (b,"")[[1]])
+ (length(aa)==sum(aa==bb))
+ }
>

##process through all words looking for words that have the same characters
##get words from d by counts. Only consider words with 5 or more characters

for(i in 5:14){


d2 <- d[d$counts==i,]
d2.len <- nrow(d2)
col.index <- 2
row.index <- 1

for(row in row.index:d2.len){
for(col in col.index:d2.len){
if(compare.word(as.character(d2[col,2]), as.character(d2[row,2]))){
mywords <- rbind(mywords,c(i,row,col,as.character(d2[row,2]),as.character(d2[col,2])))
}
}
if(col.index < d2.len) col.index <- col.index+1
}


}

mywords <- mywords[!is.na(mywords$a),]
> mywords$same <- mywords$a!=mywords$b
> mywords <- mywords[mywords$same==TRUE,]
> mywords
len row col a b same
21 5 18 175 ARISE RAISE TRUE
22 5 31 36 BOARD BROAD TRUE
23 5 68 101 EARTH HEART TRUE
24 5 118 219 LEAST STEAL TRUE
25 5 141 237 NIGHT THING TRUE
26 5 157 194 PHASE SHAPE TRUE
27 5 172 173 QUIET QUITE TRUE
28 5 196 236 SHEET THESE TRUE
29 5 199 208 SHOUT SOUTH TRUE
30 5 240 279 THROW WORTH TRUE
32 6 53 228 CENTRE RECENT TRUE
33 6 69 272 COURSE SOURCE TRUE
34 6 71 89 CREDIT DIRECT TRUE
35 6 74 135 DANGER GARDEN TRUE
36 6 110 111 EXCEPT EXPECT TRUE
37 6 132 231 FORMER REFORM TRUE
38 6 144 234 IGNORE REGION TRUE
41 8 35 125 CREATION REACTION TRUE
43 9 62 87 INTRODUCE REDUCTION TRUE
>
> nrow(mywords)
[1] 19
>
> len.of.int <- unique(mywords$len)
> len.of.int
[1] 5 6 8 9
>

There are 19 anagrams with lengths of 5, 6, 8, or 9 characters.

Now figure out how many squares of length 5,6,8, or 9 exist.

These squares will be between 100^2 to 31623^2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

nums <- vector(mode="numeric", 31523)

counter <- 1
for(i in 100:31623){
nums[counter] <- as.numeric(i^2)
counter <- counter +1
}

num.lengths <- nchar(nums)

d.nums <- data.frame(nums, num.lengths)

> head(d.nums)
nums num.lengths
1 10000 5
2 10201 5
3 10404 5
4 10609 5
5 10816 5
6 11025 5
> tail(d.nums)
nums num.lengths
31519 999697924 9
31520 999761161 9
31521 999824400 9
31522 999887641 9
31523 999950884 9
31524 1000014129 10
>

mynums <- data.frame(matrix(nrow=1,ncol=5))
names(mynums) <- c("len","row","col","a","b")

for( i in len.of.int){

##d.nums is the data.frame that holds the squares
##and their lengths
temp.nums <- as.numeric(d.nums[d.nums$num.lengths==i,"nums"])
temp.len <- length(temp.nums)

col.index <- 2
row.index <- 1

for(row in row.index:temp.len){
for(col in col.index:temp.len){
if(compare.square(as.integer(temp.nums[col]),as.integer(temp.nums[row]))){
mynums <- rbind(mynums, c(i,col,row,temp.nums[col],temp.nums[row]))
}
}
if(col.index < temp.len) col.index <- col.index+1
}
}

> head(mynums)
len row col a b
2 5 11 2 12100 10201
3 5 21 3 14400 10404
4 5 102 3 40401 10404
5 5 111 3 44100 10404
6 5 31 4 16900 10609
7 5 41 4 19600 10609
> tail(mynums)
len row col a b
40991 9 21612 21516 999255321 993195225
40992 9 21526 21517 993825625 993258256
40993 9 21589 21530 997801744 994077841
40994 9 21574 21538 996854329 994582369
40995 9 21594 21573 998117649 996791184
40996 9 21623 21623 999950884 999950884

> nrow(mynums)
[1] 40994
>

There are about 41,000 squares. Assign a square to a word, rearrange according to the square pair, determine if the new word is in the anagram list.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

scramble <- function( w, n1, n2){
#w: the word; n1: the first square; n2 the rearranged square

w.vector <-strsplit(w,"")[[1]]
n1.vector <- as.integer(strsplit(as.character(n1),"")[[1]])
n2.vector <- as.integer(strsplit(as.character(n2),"")[[1]])

d1 <-data.frame(col1=w.vector, col2= n1.vector, stringsAsFactors = FALSE)

paste(as.character(d1$col1[match(n2.vector, d1$col2)]),sep="", collapse="")

}

holder <- data.frame(matrix(nrow=1,ncol=5))
names(holder) <- c("len","wa","wb","na","nb")


for(i in len.of.int){
temp.words <- mywords[mywords3len==i,]
temp.nums <- mynums[mynums$len==i,]
for(j in 1:nrow(temp.words)){
for(k in 1:nrow(temp.nums)){
new.word <-temp.words[ match(scramble(temp.words[j,"a"], temp.nums[k,"a"], temp.nums[k,"b"]),temp.words$a), "a"]
if( !is.na( new.word)){
holder <- rbind(holder,c(i, temp.words[j,"a"], as.character(new.word),temp.nums[k,"a"], temp.nums[k,"b"] ))
}
}
}
}


> holder
len wa wb na nb
1 5 BROAD BOARD 18769 17689
2 6 CENTRE RECENT 436921 214369

CENTRE assigns different numbers to the ‘E’ violating one of the rules so BROAD/BOARD is the anagram pair and the largest square is 18769

Share

Euler-17

https://projecteuler.net/problem=17

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.

If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?

NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of “and” when writing out numbers is in compliance with British usage.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
rm(list=ls(all=TRUE))



a <- c("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten")
b <- c("eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen")

#don't use c as a variable

#this is to concatenate with each tens
d <- c("one", "two", "three", "four", "five", "six", "seven", "eight", "nine")

#21, 22, 23, 24, ...29
e <- c(rep("twenty", 10), d)

e

## [1] "twenty" "twenty" "twenty" "twenty" "twenty" "twenty" "twenty"
## [8] "twenty" "twenty" "twenty" "one" "two" "three" "four"
## [15] "five" "six" "seven" "eight" "nine"


#31, 32, 33, ....39
f <- c(rep("thirty", 10), d)
g <- c(rep("forty", 10), d)
h <- c(rep("fifty", 10), d)
i <- c(rep("sixty", 10), d)
j <- c(rep("seventy", 10), d)
k <- c(rep("eighty", 10), d)
l <- c(rep("ninety", 10), d)

#character count for 1 throu 99
through99 <- sum(nchar(c(a,b,e,f,g,h,i,j,k,l)))

through99

## [1] 854


#100, 200,300, ...900
m <- sum(nchar( c(rep("hundred",9),d))) #hundreds

#101-199
n <- sum(nchar(rep("onehundredand",99))) + through99
#201-299 etc.
o <- sum(nchar(rep("twohundredand",99))) + through99
p <- sum(nchar(rep("threehundredand",99))) + through99
q <- sum(nchar(rep("fourhundredand",99))) + through99
r <- sum(nchar(rep("fivehundredand",99))) + through99
s <- sum(nchar(rep("sixhundredand",99))) + through99
t <- sum(nchar(rep("sevenhundredand",99))) + through99
u <- sum(nchar(rep("eighthundredand",99))) + through99
v <- sum(nchar(rep("ninehundredand",99))) + through99
w <- sum(nchar("onethousand"))

results <- sum(through99,m,n,o,p,q,r,s,t,u,v,w)
results

## [1] 21124
Share

storj

Debian

I already have Node.js running so I only need to install the Storj related software.

1
2
3
4
$npm install -g storjshare-cli
$npm update -g storjshare-cli
$storjshare --help ;;to confirm installation
$storjshare setup

Accept defaults for all prompts.

1NLS7qEXNYCMt6LJvDxzk4zM9XQBNdPTDx is my Storj address
1P3YYh7QRQvWXYzaTzyPDGUeRRgJi1nF28 is counterparty address

default store at ~/.storj/contracts.db

To convert units use: convertunits.com/from/GB/to/byte

GB Bytes
100 107374182400
80 85899345920
60 64424509440
50 53687091200

Potential issues

To get contracts time must be synchronized properly.
Use NTP

1
2
3
4
5
6

#apt-get install ntp

$ntpq -p ;;to see servers I am syncing with
$date ;;to see if time changed. Should be synced within a minute

Share

Visudo

use as root command “groups” will tell you which groups you are in

visudo -f /etc/sudoers

Defaults=targetpw
ALL ALL=(ALL) ALL

You have two “modes”

  • Command mode – Press ‘ESC’ to access.

  • Insert mode – Press ‘I’ to access.
    You’re always in one or the other.

  • To move the insertion point around, press ‘ESC’ and use the arrow keys.

  • Once you’re where you want to be, press ‘I’ and start entering text.

  • To delete a character, you need to be in command mode, select the character and press the delete key. (Note: not the Backspace key) You can do this in insert mode, but it does some funky things with the text.

  • To save your changes, in command mode, type :w and press enter.

  • To quit, in command mode, type :q and press enter.

  • To quit without saving any changes, in command mode, type :q! and press enter.

To add your login to the sudo group:

$ su

adduser mbc sudo

FromRedhat

visudo

edit to look like:

Allows people in group wheel to run all commands

%wheel ALL=(ALL) ALL

save and exit

usermod -aG wheel mbc

Now test that it worked:

su USERNAME -

$ groups
mbc wheel

$sudo whoami

after password prompt should return “root”

Share

Arch

Arch Linux setup on Dell Inspiron 1720
https://wiki.archlinux.org/index.php/Beginners%27_Guide
http://lifehacker.com/5680453/build-a-killer-customized-arch-linux-installation-and-learn-all-about-linux-in-the-process

install script at http://pastebin.com/3Si2BDfv

to make a bootable flash drive:

wget http://archlinux.supersec.org/iso/2011.08.19/archlinux-2011.08.19-netinstall-i686.iso
also download sha1sums.txt
sha1sum –check sha1sums.txt (can eliminate all entries of no interest)

sudo blkid -o list -c /dev/null to see what USB is called
dd if=archlinux-2013.09.01-dual.iso of=/dev/sdb (!not /dev/sdb1)

pacman -Syu for a system upgrade
Do not use Unetbootin!

check /etc/hosts

Alt-F1 to switch to tty1

cfdisk /dev/sda1

Name Flags Part Type FS Type [Label] Size (MB)

sda1 Boot Primary Linux 160000

# mkfs.ext4 /dev/sda1
# lsblk /dev/sda1
# mount /dev/sda1 /mnt
# nano /etc/pacman.d/mirrorlist

use the rit server
Server = http://mirror.rit.edu/archlinux/$repo/os/$arch

# pacstrap -i /mnt base base-devel

# genfstab -U -p /mnt >> /mnt/etc/fstab
# nano /mnt/etc/fstab
# arch-chroot /mnt ;;use this to switch to /mnt
# nano /etc/locale.gen and uncomment en_US.UTF-8 UTF-8

;;;try /dev/sdb1, then /dev/sdc1 etc for usbs

# locale-gen (should see en_US.UTF-8 UTF-8… info)

# echo LANG=en_US.UTF-8 > /etc/locale.conf
# export LANG=en_US.UTF-8

# loadkeys us
# setfont Lat2-Terminus16

# nano /etc/vconsole.conf

echo KEYMAP=us > /etc/vconsole.conf
echo FONT=Lat2-Terminus16 >> /etc/vconsole.conf

# ls /usr/share/zoneinfo/US
# ln /usr/share/zoneinfo/US/Eastern /etc/localtime
# hwclock –systohc –utc
echo arch > /etc/hostname

# nano /etc/pacman.conf
# passwd root

;;to add user archie
# useradd -m -g users -G wheel -s /bin/bash archie
# passwd archie

# pacman -S sudo

# pacman -S grub-bions
# grub-install –target=i386-pc –recheck /dev/sda
# cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

must correct bug by editing /etc/default/grub
add the line GRUB_DISABLE_SUBMENU=y

# grub-mkconfig -o /boot/grub/grub.cfg

# pacman -S ntpd i3 dmenu chromium

######for hp server
systemctl enable dhcpcd@enp2s15.service

uses 8139too and 8139cp. do not black list anything
do not need to add modules in rc.conf
#############

# exit
# umount /mnt/home
# umount /mnt

lspci | grep # reboot

Pacman

# pacman -S base-devel
mkdir ~/builds install tar.gzs in here and build
adjust mirrors in /etc/pacman.d/mirrorlist

$ cd ~/builds
$ tar -xvzf foo.tar.gz

$ cd foo
$ nano PKGBUILD
$ nano foo.install
$ makepkg -s

# pacman -U foo-0.1-1-i686.pkg.tar.xz upgrade command
$ pacman -Qm list foreign packages
# pacman -Syu upgrade entire system
# pacman -R package_name remove package but not dependencies

# pacman -R package_name remove a single package
# pacman -Rs package_name remove package and dependencies
$ pacman -Ql package_name files installed by a package
$ pacman -Qdt list all orphaned files
$ whoneeds package_name packages needed by a package
# pacman -U /path/to/package/package_name-version.pkg.tar.xz install local package

–install software—————————-

pacman -S unzip
pacman -S xulrunner
pacman -S pkgtools
pacman -S alsa-utils
pacman -S awesome
pacman -S git
pacman -S wget
pacman -S acpi (battery monitor and other stuff)
pacman -S libunistring required for Guile
pacman -S evince to read pdfs

– /etc/pacman.d/mirrorlist ——————

uncomment the rit.edu mirrors

–video—————————————

pacman -S xf86-video-intel
xorg-configure

chmod 755 /dev/mem

–shutdown———————————-

sudo shutdown -h now

–commands———————————
$ wgetpaste </path/to/file>
$ rm -r dir to rm dir and contetns
sudo chown -R mbc /home/mbc recursive claim ownership

–Xorg——————————————-
pacman -S xorg-server xorg-xinit xorg-utils xorg-server-utils xterm
$ lspci | grep VGA

# pacman -S xorg-twm xorg-xclock xterm
$ rm ~/.xinitrc (for testing)

pacman -S xorg-drivers (provides mouse support, 38 packages, may be able to reduce )

—sound—————————————

user must be made member of audio group
#gpasswd -a mbc audio (mbc is user login id)
must relogin for it to take effect

alsamixer turn speaker and headphones up;
headphones seems to control speakers!!!

speaker-test -c 8

—–manage keys——————————

pacman-key –init
pacman-key –populate archlinux
pacman -Syy

#to refresh keys
pacman -Sc && rm /var/lib/pacman/sync
pacman-key –refresh-keys

—Conkeror———————————–

pacman -S desktop-file-utils
git clone http://repo.or.cz/r/conkeror.git

nano conkeror.sh
#!/bin/bash
exec xulrunner /path/to/conkeror/application.ini “$@”

chmod 700 conkeror.sh

–USB stick—————————————

mkdir /mnt/usbstick
sudo blkid -o list -c /dev/null to see what it is called

sudo mount /dev/sdb1 /mnt/usbstick

sudo chown -R dad /mnt/usbstick ( -R for recursive)

autologin—————————————-

# cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/autologin@.service

/etc/systemd/system/autologin@.service

[Service]
[…]
ExecStart=-/sbin/agetty –noclear -a USERNAME %I 38400
[…]

# systemctl daemon-reload
# systemctl disable getty@tty1
# systemctl enable autologin@tty1
# systemctl start autologin@tty1

autostart X
~/.bash_profile include at end (spaces important)

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

shutdown——

shutdown now

LAN card

# lspci | grep -i Ethernet
$ ping -c 3 www.google.com

UDEV———————————

wifi module: ipw2200
pacman -Ss 2200-fw (2200BG Calexico2 is the card)

http://serverfault.com/questions/63764/create-home-directories-after-create-users

Create directory in compliance to /etc/passwd, usually there will be already a /home/login entry.
Copy initial files from /etc/skel

And finally set right permissions:

mkdir /home/YOU
cd /home/YOU
cp -r /etc/skel/.* /etc/skel/* .
chown -R YOU.YOURGROUP .
chmod -R go=u,go-w .
chmod go= .

for inspron1720

# lspci | grep -i Ethernet

/etc/rc.conf
MODULES=(b44)

ip link set eth0 up

WIFI———————————-

# lspci | grep -i net

# ip link set wlan0 up
# iwlist wlan0 scan
# iwconfig wlan0 essid “GFPF1” key 1F9024CF7C
# chatham ancientgiant595

#iwconfig ;;and look for name

#iwconfig wlan0 to check access

wifi-menu to generate config file

netctl enable wlan0-GFPF1 (config file is in /etc/netctl)

####time
pacman -S ntpd
systemctl enable ntpd

Android developmment————————

pacman -S jdk7-openjdk

download and unzip android-sdk_r16-linux.tgz

unrar x avd.rar
sudo chown -R mbc /home/mbc recursive claim ownership

cd /android-sdk-linux/tools/
$ ./android

Share

Economics

17% of working-age adults earned more from their house than from their job

Stock buybacks enrich the rich - Ralph Nader

Unearned income and the rent economy

What is wrong with the west’s economy?

Share