Skip to content

Instantly share code, notes, and snippets.

@halgatewood
halgatewood / sticky.swift
Last active Jan 15, 2020
[**Requires LBTATools**] A sticky function to stick stuff using Swift to other sticky stuff. Padding approached from a web developers perspective.
View sticky.swift
// USAGES:
// SQUARE WITH A TOP PADDING OF 20
icon.stick(top: view.topAnchor, padTop: 20, width: 80, height: 80)
// PADDING TOP AND RIGHT
label.stick(top: view.topAnchor, trailing: view.trailingAnchor, padding: [20,20,0,0] )
// PADDING TOP AND BOTTOM = 20, RIGHT AND LEFT = 0
label.stick(top: view.topAnchor, trailing: view.trailingAnchor, padding: [20,0] )
@halgatewood
halgatewood / awe_darksky_raw_data.php
Last active Oct 8, 2019
WordPress function to get Dark Sky Weather data
View awe_darksky_raw_data.php
<?php
/*
Parameters:
1. Latitude
2. Longitude
3. Format: all, currently, minutely, hourly, daily
4. Dark Sky Secret Key
5. Cache time in seconds (default: 15 minutes)
*/
@halgatewood
halgatewood / awesome_weather_spanish_days_of_week.php
Created Jul 18, 2019
Translating the Days of the Week through a WordPress filter.
View awesome_weather_spanish_days_of_week.php
function awesome_weather_spanish_days_of_week()
{
return array('Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa');
}
add_filter('awesome_weather_days_of_week', 'awesome_weather_spanish_days_of_week');
@halgatewood
halgatewood / one_on_mobile.css
Created Jul 10, 2018
Testimonial Rotator Three Little Pigs Theme – Hide two of the three testimonials on mobile devices.
View one_on_mobile.css
@media screen and (max-width: 640px)
{
.testimonial_rotator.template-threepigs .slide .testimonial_rotator_slide_inner:nth-child(2) { display: none; }
.testimonial_rotator.template-threepigs .slide .testimonial_rotator_slide_inner:nth-child(3) { display: none; }
}
@halgatewood
halgatewood / hg_day_night_weather_images.php
Created Mar 23, 2018
Creating weather background images based on day and night using the 24 hour clock. Requires new images for the night time.
View hg_day_night_weather_images.php
function hg_awesome_weather_bg_ext()
{
// 24 HOUR CLOCK:
// LESS THAN 8 AM OR GREATER THAN 9 PM
if( get_the_time('G') < 8 || get_the_time('21') > 9 )
{
return "night.jpg";
}
View awe_today_in_forecast.php
<?php if( isset($weather->data['current'])) { ?>
<div class="awesome-weather-forecast-day">
<?php if($weather->show_icons) { ?><i class="<?php echo $weather->data['current']['icon']; ?>"></i><?php } ?>
<div class="awesome-weather-forecast-day-abbr"><?php echo $weather->t->now; ?></div>
<div class="awesome-weather-forecast-day-temp"><?php echo $weather->data['current']['temp']; ?></div>
</div>
<?php } ?>
@halgatewood
halgatewood / awe_ajax.php
Last active Jan 14, 2019
Calling the Awesome Weather Widget through AJAX.
View awe_ajax.php
<?php
function hg_plugins_loaded()
{
if( isset($_GET['weather_widget']) )
{
echo awesome_weather_logic( array('location' => 'Boston', 'owm_city_id' => 4930956, 'use_user_location' => true, 'background_by_weather' => true ));
die;
}
}
add_filter('plugins_loaded', 'hg_plugins_loaded', 100);
@halgatewood
halgatewood / rotate_buttons.swift
Last active Nov 24, 2017
Swift: Rotate Buttons Based On Device Orientation
View rotate_buttons.swift
override func viewDidLoad()
{
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(rotate), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
}
@objc func rotate()
{
var rotation_angle: CGFloat = 0
@halgatewood
halgatewood / awe_mps_to_knots.php
Created Nov 8, 2017
Converting mps to knots with the Awesome Weather Widget Free Plugin
View awe_mps_to_knots.php
function hg_awesome_weather_wind_speed( $data, $speed, $direction )
{
$data['speed'] = round($data['speed'] * 1.94384);
$data['text'] = " knots";
return $data;
}
add_filter('awesome_weather_wind_speed', 'hg_awesome_weather_wind_speed', 10, 3);
@halgatewood
halgatewood / awe_show_weather.php
Last active Nov 7, 2017
How to show the simple weather in a PHP template for Awesome Weather Widget PRO
View awe_show_weather.php
<?php
$where = new stdclass;
$where->location = "Dublin";
$where->owm_city_id = 2964574;
$where->units = "F";
$weather = get_awesome_weather_openweathermaps( $where );
if( isset($weather->data['current'])) { ?>
<div class="awe-weather">
<i class="<?php echo $weather->data['current']['icon']; ?>"></i>
<?php echo $weather->data['current']['temp']; ?>&deg; <?php echo $weather->data['current']['description']; ?>