Skip to content

Instantly share code, notes, and snippets.

@twtw
Last active August 16, 2020 01:02
Show Gist options
  • Save twtw/401944 to your computer and use it in GitHub Desktop.
Save twtw/401944 to your computer and use it in GitHub Desktop.
Random Chinese names and Lorem ipsum.
#!/bin/sh
# simple script to generate random chines names from richyli's website.
if [ "$#" -eq 0 ]; then
COUNT=3
else
COUNT=$1
fi
curl -s -d name_count=$COUNT\&break=2 http://www.richyli.com/name/index.asp | piconv -f big5 -t utf8 | sed -n 88p | awk -F', #' '{print $1}' | sed -e 's/ //g'
#!/bin/sh
# simple script to generate random chines fake articles from richyli's website.
if [ "$#" -eq 0 ]; then
COUNT=100
else
COUNT=$1
fi
curl -s -d words=$COUNT http://www.richyli.com/tool/loremipsum/ | piconv -f big5 -t utf8 | sed -n 36p
# generate chines random names, text.
# use 'random_text' gem to generate Lorem ipsum text
get '/names' do
`/usr/local/bin/chinese_random_names.sh`
end
get '/names/:id' do
`/usr/local/bin/chinese_random_names.sh #{params[:id]}`
end
get '/zhtxt' do
`/usr/local/bin/chinese_random_text.sh`
end
get '/zhtxt/:id' do
num = params[:id]
words = case num.length
when 1 then "#{num}00"
when 2 then "#{num}0"
when 3 then "#{num}"
else "500"
end
`/usr/local/bin/chinese_random_text.sh #{words}`
end
get '/random' do
require 'random_text'
text = (RandomText::Lorem.paragraphs 5).join('<p />')
"#{text}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment