Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
@halgatewood
halgatewood / sticky.swift
Last active January 15, 2020 16:54
[**Requires LBTATools**] A sticky function to stick stuff using Swift to other sticky stuff. Padding approached from a web developers perspective.
// 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 October 8, 2019 01:43
WordPress function to get Dark Sky Weather data
<?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 July 18, 2019 05:41
Translating the Days of the Week through a WordPress filter.
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 July 10, 2018 21:22
Testimonial Rotator Three Little Pigs Theme – Hide two of the three testimonials on mobile devices.
@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 March 23, 2018 15:52
Creating weather background images based on day and night using the 24 hour clock. Requires new images for the night time.
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";
}
<?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 January 14, 2019 21:38
Calling the Awesome Weather Widget through AJAX.
<?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 July 24, 2022 15:28
Swift: Rotate Buttons Based On Device Orientation
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 November 8, 2017 03:38
Converting mps to knots with the Awesome Weather Widget Free Plugin
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 November 7, 2017 19:32
How to show the simple weather in a PHP template for Awesome Weather Widget PRO
<?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']; ?>