Skip to content

Instantly share code, notes, and snippets.

View rustam-swe's full-sized avatar
🎯

Rustam rustam-swe

🎯
View GitHub Profile
@rustam-swe
rustam-swe / recalculate-acf-locations.php
Created January 19, 2021 11:54 — forked from RadGH/recalculate-acf-locations.php
Get latitude and longitude for addresses saved in Advanced Custom Fields, using Google's GeoLocation API
<?php
global $acf_recalc_settings;
// IMPORTANT: Customize these settings for your website.
$acf_recalc_settings = array(
// How many updates to do each page load. As of November 2018, Google's GeoLocation API limit is 100 per second.
'posts_per_run' => 16,
@rustam-swe
rustam-swe / get-svg-dimensions.php
Created May 3, 2021 09:56
Returns dimensions (width and height) of a given svg (by url)
/**
* Returns dimensions (width and height) of a given svg (by url)
*
* @param string $image_url
* @source https://stackoverflow.com/a/6532357/9214537
*
* @return string
*/
function get_svg_dimensions( string $image_url ): string {
$parsed_xml = simplexml_load_string( file_get_contents( $image_url ) );
@rustam-swe
rustam-swe / concat_rows.sql
Last active September 22, 2021 06:42
Concat cells (rows) of one column by another column
# column_name - column name filter by
# column_name_2 - column name to concat
# table_name - table name :)
SELECT column_name,
GROUP_CONCAT(DISTINCT column_name_2 SEPARATOR ',')
FROM table_name
GROUP BY column_name;