1014Installing IIJmio Sim-Card on iPhone
Problem: IIJMIO Network not working: Solution: Dowload and Install Profile
- Go to https://t.iijmio.jp/en/apn/
- Download and Install the Profile
- That's it.
Problem: IIJMIO Network not working: Solution: Dowload and Install Profile
Working with XAMPP and and phpMyAdmin makes dealing with databases more visual, but importing large db dumb files can fail/take a long time.
Importing from the command line is faster and more stable.
mysql
, if there is not a global mysql
cd /Applications/XAMPP/xamppfiles/bin
mysql -u username -p db_name < ~/path/to/db/file.sql
mysql -u username -p -h hostname db_name < ~/path/to/db/file.sql
mysqladmin -u username -p -h hostname status
-p
asks for the password on executionI exported all the DB from one installatino as one, big localhost.sql
and then tried to import it in another one. That creates the following error:
ERROR 2006 (HY000) at line 127571: MySQL server has gone away
Some DBs have been imported, but not all.
Workaround: Export/Import DBs individually.
I've been trying to get data from an API, a async call is used to parse the data. I've be naively iterating over the responses with forEach
, calling await
in the forEach function
, and wondering why it is not producing the result I expected, i.e. wait for the data to settle.
NG:
async function getData() {
output = ""
results.forEach(async (block) => {
var b = await abc.parse(block)
output += b
})
}
Use a standard for
or for..of
to loop over the list:
async function getData() {
output = ""
for (const block of results) {
var b = await abc.parse(block)
output += b
}
}
The Regenerate Thumbnails Plug-in.
This option is usualy slower - and some hosting providers might confuse it for a malicious attach and block the IP.
WP-CLI is the command line interface for WordPress/ClassicPress.
From the WP-CLI Guide
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Run --info
from your WP root directory, to check if it works:
php wp-cli.phar --info
If you get a json_encode
error, it means your PHP version is not compatible with WP-CLI.
PHP 7 was the default on one server, it did not work.
which php
// /usr/bin/php
ls /usr/bin/php*
// php80 php81 php82 php83
Let's use the latest verson of PHP.
php83 wp-cli.phar --info
Regenerate all images, without confirmation.
php83 wp-cli.phar media regenerate --yes
Regenerate thumbnails only.
$ php83 wp-cli.phar media regenerate --image_size=thumbnail
More options for regenerating images with WP-CLI:
# Regenerate thumbnails for given attachment IDs.
php83 wp-cli.phar media regenerate 123 124 125
# Re-generate all thumbnails that have IDs between 100 and 200.
seq 100 200 | xargs php83 wp-cli.phar media regenerate
# Re-generate all thumbnails that have IDs between 100 and 200.
seq 100 200 | xargs php83 wp-cli.phar media regenerate
# Re-generate all thumbnails that have IDs between 100 and 200, only thumbnails
seq 100 200 | xargs php83 wp-cli.phar media regenerate --image_size=thumbnail
#### Error
`Error: Error establishing a database connection.`
When working on _localhost_, use `127.0.0.1` instead of `localhost` in wp.config
```php
define( 'DB_HOST', '127.0.0.1' );
Renaming a branch on Github is straight-forward:
The "Lean More" link has some instructions how to update the local environments:
Your members will have to manually update their local environments. We'll let them know when they visit the repository, or you can share the following commands.
git branch -m oldbranchname newbranchname
git fetch origin
Username for 'https://github.com': trembl
Password for 'https://trembl@github.com':
I tried automatically to log-in with my GitHub Password.
remote: Support for password authentication was removed on
August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-
authentication-requirements-for-git-operations/ for more information.
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
Ok, we need a Personal Access Token instead of the password!
Go to github.com > Settings > Developer Settings > Personal access tokens, and generate a new token with full repo access.
Once we use the token instead of the password, it works.
git branch -u origin/main main
# Branch 'main' set up to track remote branch 'main' from 'origin'.
git remote set-head origin -a
# origin/HEAD set to main
Traditionally Unix systems use crontab to schedule and run repetitive jobs, OSX uses launchd, an init and operating system service management daemon.
Here is a script that call my index.php every 120 seconds. (I am download snow webcams in the index.php.)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.trembl.snow</string>
<key>ServiceDescription</key>
<string>Getting Snow Pictures</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/XAMPP/bin/php</string>
<string>/Applications/XAMPP/xamppfiles/htdocs/snow/index.php</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>120</integer>
</dict>
</plist>
In Xcode, the same script looks like this:
I made a couple of errors, trying to get the script to run.
Permissions
sudo chown <user>:staff org.trembl.snow.plist
Incorrect permissions also cause the Load failed: 122: Path had bad ownership/permissions
The name of the file and the Label need to match. org.trembl.snow and org.trembl.snow.plist
The plist need to be placed into ~/Library/LaunchAgents.
If your Program has arguments, they need to be specified in an array:
<key>ProgramArguments</key>
<array>
<string>/Applications/XAMPP/bin/php</string>
<string>/Applications/XAMPP/xamppfiles/htdocs/snow/index.php</string>
</array>
Both strings need to be absolute. I got this error: Load failed: 122: Path had bad ownership/permissions
, which was caused by only saying index.php
instead of the whole absolute path.
Use launchctl bootstrap
and not the obsolete launchctl load
.
Launch with sudo launchctl bootstrap gui/`id -u` ~/Library/LaunchAgents/org.trembl.snow.plist
Stop: sudo launchctl bootout gui/`id -u` ~/Library/LaunchAgents/org.trembl.snow.plist
Stopping the flask server
with ⌃-Z (CRTL-Z), instead of the correct ⌃-C (CRTL-C), results in the server still bound to port 5000:
OSError: [Errno 48] Address already in use
Problem: After Flask crash, the port can still be occupied.
Check who is using port 5000
sudo lsof -i:5000
kill $PID
kill -9 $PID
Success:
[2] + killed flask run
Embedded Vimeo in HTML Page:
<iframe id="vi" src="https://player.vimeo.com/video/123"></iframe>
Pause:
var msg = JSON.stringify({method: "pause"}
Play:
var msg = JSON.stringify({method: "play"}
jQuery:
$("#vi")[0].contentWindow.postMessage(msg, "*")
Pure JS:
document.getElementById("vi").contentWindow.postMessage(msg, "*")
I am surprised that there is not a simple import function in mysql or phpMyAdmin, I did the following:
Make sure you check the box that converst the first line into the table structure.
When importing a larger table (in my case ~300M), the phpMyAdmin was complaining about memory (which I fixed), but then the script time out.
Solution? Import directly from mysql
Open the XAMPP mysql binary:
cd /Applications/XAMPP/xamppfiles/bin
./mysql -u root -p
LOAD DATA LOCAL INFILE '/path/to/table.csv'
INTO TABLE mydb.mytable FIELDS TERMINATED
BY ',' ENCLOSED BY '"' LINES TERMINATED
BY '\n' IGNORE 1 LINES;
(Line breaks are added for legibility.)
IGNORE 1 LINES
ignores the first line with the headersUse it to capture output and print it in one go. For example when debugging server function with an ajax call.
$message = "hello!\n";
$a = array(
'one' => 1,
'two' => 2
);
$message .= print_r($a, true);
print_r($output);
prints:
/*
hello!
Array
(
[one] => 1
[two] => 2
)
*/