1077GitHub Desktop not pushing to server?
Increase the http.postBuffer:
git config http.postBuffer 524288000
Increase the http.postBuffer:
git config http.postBuffer 524288000
openssl rand -base64 12
rand
Generate pseudo-random bytes.
base64
Base64 Encoding
An evolving list of JS Image Sliders and Lightboxes.
TODO:
Notes for changing Wordpress Multisite Subdirectories:
Update siteurl & home in wp_X_options
Don’t forget the trailing slash
Change corresponding paths in wp_blogs
Clear Caches
Check Image upload folders
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
The Node Version Manager allows for the installation and use of different versions of node and npm.
nvm install v18.20.4
Downloading and installing node v18.20.4...
Downloading https://nodejs.org/dist/v18.20.4/node-v18.20.4-darwin-x64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v18.20.4 (npm v10.7.0)
nvm use v18.20.4
Now using node v18.20.4 (npm v10.7.0)
npm -v
10.7.0
node -v # v18.20.4
The traditional Custom Fields in Wordpress have been around since the beginning, gives some degree of customability to the posts. They are very basic, but the work.
Soon after, the Advanced Custom Fields become the norm, adding a nice UI on top of the custom fields, and enabling things like checkboxes, time/date, repeater, etc.
All was great in Wordpressland, but the ACF were sold to WP Enginge who are now trying hard to monetize the ACFs. Instead of payment per installation, they now moved ACFs to a monthly/yearly subscription model.
I still keep using ACFs for client work, but try to remove it from my personal sites - like this one. All it did was to have a checkbox to enable/disable Markdown on the posts.
Markdown is now by default on, ACF no longer needed.
Also, I was stuggling to show the original Custom Fields:
Only AFTER I uninstalled ACF, the option showed up again!
ProcessWire's way of selecting ("getting") child pages is usually like this:
Get all children
$events = $page->children();
This can be fine-tuned with the Selector string.
Get all children, where the date or end_date is later than today, sort the results by date.
$events = $page->children("date|end_date>today,sort=date");
This works great, by we recently had a case, where a schedule talk had to be postponed to an unknown date in the future. I left the date
field in the Backend empty, we need to modify the selection
string:
Get all children, where the date or end_date is later than today OR where date is empty, sort the results by date.
$events = $page->children("(date|end_date >today), (date=), sort=date");
It's beautiful, that it's just a small change in the selection string:
()
around (date|end_date >today)
and (date=)
specify an OR relation. Default is AND, here it means: select children with either (date|end_date >today)
OR (date=)
- no date.date=
means that the date field is emptyIt happens to best of us: You have an local installation of your favourite CMS - and then you can't remember the password! Login throtteling kicks in, you still can't remember it. And this being a local XAMPP installation, you can't send an email to recover the password.
Here is Ryan1 to the resuce:
You can always reset your password just by pasting this temporarily into any one of your templates, and then viewing a page that uses the template:
$u = $users->get('admin'); // or whatever your username is $u->of(false); $u->pass = 'your-new-password'; $u->save();
1 Who is Ryan? Ryan Cramer is the founder and lead developer of ProcessWire.
ACFs are a great (legacy?) way of storing additional data in a ClassicPress/Wordpress installtion. But things can get a but ugly when you have thousands of posts, each with ACFs maybe nested Repeater ACFs. Getting data out of larger installation with get_posts
and WP_Query
can quickly hit the limits of the DB installation and fail.
The solution? A raw, hand-crafted MySQL query:
SELECT wp_postmeta.meta_value // return the meta_value
FROM wp_posts, wp_postmeta
WHERE wp_posts.post_status = 'publish' // publish posts only
AND wp_posts.ID = wp_postmeta.post_id
AND wp_postmeta.meta_key = 'my_key' // get value from 'my_key'
Getting the results with $wpdb->get_results()
.
$results = $wpdb->get_results($query);
Array
(
[0] => stdClass Object
(
[meta_value ] => 123
)
[1] => stdClass Object
(
[meta_value ] => 456
)
)
That works great, if you want to get one Custom Field, but how about multiple Custom Fields?
Custom fields are stored in the wp_postmeta
table and defined by the meta_key
and meta_value
column.
SELECT p.ID, m1.meta_value as v1, m2.meta_value as v2
FROM wp_posts p
LEFT JOIN wp_postmeta m1 ON p.ID = m1.post_id
LEFT JOIN wp_postmeta m2 ON p.ID = m2.post_id
WHERE p.post_status='publish'
AND m1.meta_key = 'my_key'
AND m2.meta_key = 'my_other_key'
Is it important to note - and slightly unintuitive - that the select line also declares aliases which will be used in the rest of the query:
p
in p.ID
is a shortcut for wp_posts
m1
in m1.meta_value
is a shortcut for wp_postmeta
m2
, but we want to select and JOIN different meta key we also need to have two shortcuts for wp_postmeta
.meta_value as v1
is also important. If we would not use ... as v1
then the return array would include meta_value
as a key and m2
would overwrite m1
. Does not have to be v1
and v2
, use whatever you like.Array
(
[0] => stdClass Object
(
[ID] => 123
[v1] => 33
[v2] => 20130402
)
[1] => stdClass Object
(
[ID] => 456
[v1] => 22
[v2] => 20130404
)
)
The ACF Repeater fields also stores its values in wp_postmeta
, following this schema:
repeatername_nr_fieldname
. Let's say we have a repeater field called videos
and a sub-field called video
, the meta_key
s in wp_postmeta
would look like this:
videos_0_video
videos_1_video
videos_2_video
videos_3_video
...
That means we need to modify the previous query, because the we can't be sure how many meta_key
we have.
SELECT p.ID, m1.meta_value as v1, m2.meta_value as v2
FROM wp_posts p
LEFT JOIN wp_postmeta m1 ON p.ID = m1.post_id
LEFT JOIN wp_postmeta m2 ON p.ID = m2.post_id
WHERE p.post_status='publish'
AND m1.meta_key REGEXP '[[:<:]]videos_[0-9]*_video[[:>:]]'
AND m1.meta_value > 0
AND m2.meta_key = 'my_key'
AND m1.meta_key REGEXP '[[:<:]]videos_[0-9]*_video[[:>:]]'
is a regular expression with some MySQL-specific syntax: [[:<:]]
means beginning of string and [[:>:]]
stands for end of string.
Organizing meeting across time-zones can lead to mis-communication of the meeting start-times, especially when daylight-saving-time changes are involed.
Show the Meeting Start Time AND the current Local Time at the Meeting Website.
var f = new Intl.DateTimeFormat([], {
timeZone: 'Asia/Tokyo',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hourCycle: 'h23'
})
var setTime = () => document.getElementById('time').innerHTML = f.format(new Date())
setTime()
setInterval(() => setTime(), 1000)
</script>
Intl.DateTimeFormat
creates a new Intl formatter. Time to be displayed: Asia/Tokyo
. Displayed are only: hour
, minute
and second
. The hourCycle' option
h23` sets the display to a 24h clock.
setTime
is a function that sets the innerHTML
of id element time
to the current Date, formatted with the Intl date.
setTime()
call the function once on load.
setInterval()
repeatetly calls the setTime()
function to update the clock.