Ubuntu: Cannot set LC ALL to default locale
Problem
$ sudo dpkg-reconfigure tzdata
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "zh_TW.UTF-8",
LC_ADDRESS = "zh_TW.UTF-8",
LC_MONETARY = "zh_TW.UTF-8",
LC_NUMERIC = "zh_TW.UTF-8",
LC_TELEPHONE = "zh_TW.UTF-8",
LC_IDENTIFICATION = "zh_TW.UTF-8",
LC_MEASUREMENT = "zh_TW.UTF-8",
LC_TIME = "zh_TW.UTF-8",
LC_NAME = "zh_TW.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Fix
$ sudo locale-gen zh\_TW.UTF-8
Generating locales...
zh_TW.UTF-8... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_US.UTF-8... done
zh_TW.UTF-8... up-to-date
Generation complete.
Rails 4 enum
example: https://github.com/frsnic/rails4-enum
app/models/user.rb
class User < ActiveRecord::Base
enum role: [:admin, :manager, :client]
end
db/seeds.rb
User.create(name: 'Admin', role: User.roles[:admin])
User.create(name: 'Manager', role: User.roles[:manager])
User.create(name: 'Client', role: User.roles[:client])
User.all.pluck(:name, :role)
User Load (0.1ms) SELECT "users"."name", "users"."role" FROM "users"
=> [["Admin", 0], ["Manager", 1], ["Client", 2]]
User.last.role
User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
=> "client"
User.first.admin?
User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> true
User.first.client?
User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> false
User.where(role: User.roles[:client]) (P.S It's roles, not role)
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."role" = ? [["role", 2]]
=> #<ActiveRecord::Relation [#<User id: 3, name: "Client", role: 2, created_at: "2015-09-17 02:06:51", updated_at: "2015-09-17 02:06:51">]>
Wordpress Not Found.
If you get the same error like me
Not Found
The requested URL /your_url was not found on this server.
Check below
1. apache defualt is disable ".htaccess", you need to manual enable it.
$ sudo vi /etc/apache2/sites-available/$site
<VirtualHost *:80>
....
<Directory "/var/www/$site">
AllowOverride All
</Directory>
...
</VirtualHost>
2. apache default not load rewrite.load
cd /etc/apache2/mods-enabled
ln -s ../mods-available/rewrite.load
3. last check your apache can write to your .htaccess
$ ls -l your_project/.htaccess
-rwxrwxr-- 1 www-data www-data 436 6月 21 15:20 .htaccess
Recursion search file content in Linux
grep --color=auto -nH 'DIR' *
-n, --line-number
Prefix each line of output with the 1-based line number within its input file. (-n is specified by POSIX.)
-H, --with-filename
Print the file name for each match. This is the default
when there is more than one file to search.
*, file path
Ubuntu share NTFS partition
sudo ntfs-3g -o uid=1000,gid=1000 /dev/sda3 ntfs