Wednesday, September 7, 2016

Emoji: Converting from and to UTF-8 Hexadecimal

Command:

$ echo -e "\xF0\x9F\x98\x80"


Result:

😀


Command:

$ echo -n 😀 | hexdump


Result:

0000000 f0 9f 98 80                                  
0000004


GNU Fortran: Hello World

Command:

$ cat myfile.f90

program hello
print *, "Hello World!"
end program hello


Result:

$ gfortran myfile.f90 -o myfile

$ ./myfile
 Hello World!


Syntax error because of the file extension


Command:

$ cat myfile.f


Result:

program hello
print *, "Hello World!"
end program hello


Command:

$ gfortran myfile.f -o myfile


Result:

myfile.f:1:1:

 program hello
 1
Error: Non-numeric character in statement label at (1)
myfile.f:1:1:

 program hello
 1
Error: Unclassifiable statement at (1)
myfile.f:2:1:

 print *, "Hello World!"
 1
Error: Non-numeric character in statement label at (1)
myfile.f:2:1:

 print *, "Hello World!"
 1
Error: Unclassifiable statement at (1)
myfile.f:3:1:

 end program hello
 1
Error: Non-numeric character in statement label at (1)
myfile.f:3:1:

 end program hello
 1
Error: Unclassifiable statement at (1)

OS X: GNU Fortran

Command:

$ brew install gfortran


Result:

Error: No available formula with the name "gfortran" 
GNU Fortran is now provided as part of GCC, and can be installed with:
  brew install gcc


Command:

$ gfortran --version


Result:

GNU Fortran (Homebrew gcc 5.3.0) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

OS X: Installing Clozure CL

Command:

$ brew install clozure-cl


Result:

==> Downloading http://ccl.clozure.com/ftp/pub/release/1.11/ccl-1.11-darwinx86.tar.gz
######################################################################## 100.0%
🍺  /usr/local/Cellar/clozure-cl/1.11: 1,568 files, 178.5M, built in 1 minute 46 seconds
$ ccl --version
Version 1.11-r16635  (DarwinX8632)

Tuesday, September 6, 2016

Aki Okui (奥井亜紀): 晴れてハレルヤ

Aki Okui

Narumi Tamaki (玉置成美): Believe

Narumi Tamaki

Folder5: Believe

ZONE: secret base ~君がくれたもの~

Kana Hanazawa (花澤 香菜): 恋愛サーキュレーション

Kana Hanazawa

Crontab: Tweet Random Line without Modulo Bias

Command:

$ crontab -l


Result:

*/30 * * * * perl -le 'sleep rand 360' && csv="list.csv"; wc=$[`wc -l < $csv` - 1]; rand=$[`./rand_nobias.sh $wc`]; head -$[$[$rand \% $wc] + 2] $csv | tail -1 | /usr/local/bin/gawk -f formatcsv.awk | ruby tweet.rb 

Bourne shell: Generating Random Number without Modulo Bias

Command: 

$ cat rand_nobias.sh


Result:

#!/bin/sh

numlines=$1;
randmax=32767;
max=$((($randmax/$numlines)*$numlines)); 
rand=$RANDOM;

until [ $rand -lt $max ] 
do 
rand=$RANDOM;
done 


echo $rand;