Rails
▼ Start the server in the background
rails s -d
▼ Also open to the public
rails s -d -b 0.0.0.0
Python
data = ["A","B" "C"]
if "B" in data:
print("B is found")
Mongo
▼ Start
mongo
▼ Select db
use dbName
▼ Collection display
show collections
▼ Display of the number of documents
db.colName.count()
▼ When referring to a special collection name (numbers, hyphens, etc.)
db.getCollection('2016-09-01'). ...
Use getCollection in the form of.
▼ Get documents that meet specific conditions
db.colName.find({keyName:value})
▼ Display all items
db.colName.find()
▼ csv export
mongoexport -d [Database name] -c [Collection name] -out[Output file name].csv --csv --fields xx,yy,zz
PHP
▼ Output an array
var_dump($array)
▼ Output JSON after arranging it
$json = '{"a":1,"b":2}';
$decode1 = json_decode($json)
$decode2 = json_decode($json)
//$decode1
object(stdClass)#1 (2) {
["a"] => int(1)
["b"] => int(2)
}
//$decode2
array(2) {
["a"] => int(1)
["b"] => int(2)
}
* Even though it is an array, if you use echo etc., "Error":I get an "Array to string conversion" error.
PHP I forgot after a long time^^;
▼ Output JSON beautifully
echo '<pre>';
var_dump($json);
echo '</pre>';
▼ Combo box
<select><option></option></select>
▼form
<form acition="..." method="...">
<input type="text" name="name" size="20"/>
<input type="submit" value="Send"/>
</form>
▼ Start
mysql.server start
▼ Interactive IF
mysql -uroot -p
▼CREATE TABLE
CREATE TABLE {TABLENAME}(email varchar(100),name varchar(100));
▼ Primary key
CREATE TABLE {TABLENAME}(email varchar(100) PRIMARY KEY);
▼ Default value
CREATE TABLE {TABLENAME}(email varchar(100),complete bit(1) DEFAULT 0);
▼ Granting authority
·Authorization
GRANT ALL PRIVILEGES ON {TABLENAME}.* TO {USERNAME}@{HOSTNAME} IDENTIFIED BY {PASSWORD}
·Change Password
SET PASSWORD FOR username@"hostname"=password('Password after change');
▼ INSERT statement
INSERT INTO {TABLENAME} (email) VALUES ('[email protected]');
▼ Check the schema
show columns from {TABLENAME};
▼ Column operation
·add to
ALTER TABLE <table name> ADD <Column name> <Type information>;
·Change
ALTER TABLE test CHANGE num number int;
·Delete
ALTER TABLE <table name> DROP <Column name>;
・ Initial value setting
ALTER TABLE <table name> ALTER <Column name> SET DEFAULT <initial value>;
▼ Function
UPDATE test SET num = num+1 WHERE name = "hoge";
Nodejs
▼ File output (overwrite)
fs.writeFile(filename, data, encoding='utf8', [callback])
fs.writeFileSync(filename, data, encoding='utf8', [callback])
* The top is asynchronous, the bottom is synchronous
▼ File output (additional note)
fs.appendFile(filename, data, encoding='utf8', [callback])
fs.appendFileSync(filename, data, encoding='utf8', [callback])
* The top is asynchronous, the bottom is synchronous
Authority related
▼ Confirmation of authority
ls -l <File name or path>
▼ Granting authority
sudo chmod <Access rights(Numbers)> <File name or path>
▼ Detailed authority settings
sudo chmod <Right holder> + /- <Access rights(Alphabet)> <File name or path>
▼ Owner change
chown root:root file